mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-14 10:55:04 +08:00
start adding kerning table as a break from compact font format
This commit is contained in:
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
@@ -88,7 +88,7 @@
|
||||
{
|
||||
tableRegister.PostScriptTable = PostScriptTable.Load(data, table, tableRegister.MaximumProfileTable);
|
||||
}
|
||||
|
||||
|
||||
if (!isPostScript)
|
||||
{
|
||||
if (!tables.TryGetValue(TrueTypeHeaderTable.Loca, out var indexToLocationHeaderTable))
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
28
src/UglyToad.PdfPig/Fonts/TrueType/Tables/KerningTable.cs
Normal file
28
src/UglyToad.PdfPig/Fonts/TrueType/Tables/KerningTable.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
namespace UglyToad.PdfPig
|
||||
{
|
||||
internal interface ICosUpdateInfo
|
||||
{
|
||||
bool NeedsToBeUpdated { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user