start adding kerning table as a break from compact font format

This commit is contained in:
Eliot Jones
2018-04-29 15:15:11 +01:00
parent b51ebfd70c
commit 1a213caf26
5 changed files with 62 additions and 9 deletions

View File

@@ -27,5 +27,7 @@
/// Where a character code isn't found it should map to index 0.
/// </summary>
public CMapTable CMapTable { get; set; }
public KerningTable KerningTable { get; set; }
}
}

View File

@@ -102,7 +102,7 @@
if (!tables.TryGetValue(TrueTypeHeaderTable.Glyf, out var glyphHeaderTable))
{
throw new InvalidOperationException("The glpyh table is required for non-PostScript fonts.");
throw new InvalidOperationException("The glyph table is required for non-PostScript fonts.");
}
// glyf
@@ -137,6 +137,10 @@
// os2
// kern
if (tables.TryGetValue(TrueTypeHeaderTable.Kern, out var kernHeaderTable))
{
tableRegister.KerningTable = KerningTable.Load(data, kernHeaderTable);
}
}
}
}

View File

@@ -0,0 +1,26 @@
namespace UglyToad.PdfPig.Fonts.TrueType.Tables.Kerning
{
using System;
[Flags]
internal enum KernCoverage
{
/// <summary>
/// The table is horizontal kerning data.
/// </summary>
Horizontal = 1,
/// <summary>
/// The table has minimum values rather than kerning values.
/// </summary>
Minimum = 1 << 1,
/// <summary>
/// Kerning is perpendicular to the flow of text.
/// If text is horizontal kerning will be in the up/down direction.
/// </summary>
CrossStream = 1 << 2,
/// <summary>
/// The value in this sub table should replace the currently accumulated value.
/// </summary>
Override = 1 << 3
}
}

View File

@@ -0,0 +1,28 @@
namespace UglyToad.PdfPig.Fonts.TrueType.Tables
{
using Kerning;
internal class KerningTable
{
public static KerningTable Load(TrueTypeDataBytes data, TrueTypeHeaderTable headerTable)
{
data.Seek(headerTable.Offset);
var version = data.ReadUnsignedShort();
var numberOfSubtables = data.ReadUnsignedShort();
for (var i = 0; i < numberOfSubtables; i++)
{
var subtableVersion = data.ReadUnsignedShort();
var subtableLength = data.ReadUnsignedShort();
var coverage = data.ReadUnsignedShort();
var kernCoverage = (KernCoverage) coverage;
var format = ((coverage & 255) >> 8);
}
return new KerningTable();
}
}
}

View File

@@ -1,7 +0,0 @@
namespace UglyToad.PdfPig
{
internal interface ICosUpdateInfo
{
bool NeedsToBeUpdated { get; set; }
}
}