mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-20 11:37:57 +08:00
handle case insensitive truetype table tags and missing tables for postscript fonts
This commit is contained in:
@@ -18,7 +18,6 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// This table contains the data that defines the appearance of the glyphs in the font.
|
/// This table contains the data that defines the appearance of the glyphs in the font.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NotNull]
|
|
||||||
public GlyphDataTable GlyphTable { get; }
|
public GlyphDataTable GlyphTable { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -36,7 +35,6 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// This table stores the offsets to the locations of the glyphs (relative to the glyph table).
|
/// This table stores the offsets to the locations of the glyphs (relative to the glyph table).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NotNull]
|
|
||||||
public IndexToLocationTable IndexToLocationTable { get; }
|
public IndexToLocationTable IndexToLocationTable { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -73,10 +71,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
HeaderTable = builder.HeaderTable ?? throw new ArgumentException("The builder did not contain the header table");
|
HeaderTable = builder.HeaderTable ?? throw new ArgumentException("The builder did not contain the header table");
|
||||||
GlyphTable = builder.GlyphDataTable ?? throw new ArgumentException("The builder did not contain the glyph data table.");
|
GlyphTable = builder.GlyphDataTable;
|
||||||
HorizontalHeaderTable = builder.HorizontalHeaderTable ?? throw new ArgumentException("The builder did not contain the horizontal header table.");
|
HorizontalHeaderTable = builder.HorizontalHeaderTable ?? throw new ArgumentException("The builder did not contain the horizontal header table.");
|
||||||
HorizontalMetricsTable = builder.HorizontalMetricsTable;
|
HorizontalMetricsTable = builder.HorizontalMetricsTable;
|
||||||
IndexToLocationTable = builder.IndexToLocationTable ?? throw new ArgumentException("The builder did not contain the index to location table.");
|
IndexToLocationTable = builder.IndexToLocationTable;
|
||||||
MaximumProfileTable = builder.MaximumProfileTable ?? throw new ArgumentException("The builder did not contain the maximum profile table.");
|
MaximumProfileTable = builder.MaximumProfileTable ?? throw new ArgumentException("The builder did not contain the maximum profile table.");
|
||||||
NameTable = builder.NameTable;
|
NameTable = builder.NameTable;
|
||||||
PostScriptTable = builder.PostScriptTable;
|
PostScriptTable = builder.PostScriptTable;
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
int rangeShift = data.ReadUnsignedShort();
|
int rangeShift = data.ReadUnsignedShort();
|
||||||
// ReSharper restore UnusedVariable
|
// ReSharper restore UnusedVariable
|
||||||
|
|
||||||
var tables = new Dictionary<string, TrueTypeHeaderTable>();
|
var tables = new Dictionary<string, TrueTypeHeaderTable>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
for (var i = 0; i < numberOfTables; i++)
|
for (var i = 0; i < numberOfTables; i++)
|
||||||
{
|
{
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
var length = data.ReadUnsignedInt();
|
var length = data.ReadUnsignedInt();
|
||||||
|
|
||||||
// skip tables with zero length (except glyf)
|
// skip tables with zero length (except glyf)
|
||||||
if (length == 0 && !string.Equals(tag, TrueTypeHeaderTable.Glyf))
|
if (length == 0 && !string.Equals(tag, TrueTypeHeaderTable.Glyf, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -68,7 +68,8 @@
|
|||||||
{
|
{
|
||||||
boundingBox = default(PdfRectangle);
|
boundingBox = default(PdfRectangle);
|
||||||
|
|
||||||
if (!TryGetGlyphIndex(characterIdentifier, characterCodeToGlyphId, out var index))
|
if (!TryGetGlyphIndex(characterIdentifier, characterCodeToGlyphId, out var index)
|
||||||
|
|| TableRegister.GlyphTable == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -112,6 +113,13 @@
|
|||||||
|
|
||||||
private bool TryGetBoundingAdvancedWidthByIndex(int index, out decimal width)
|
private bool TryGetBoundingAdvancedWidthByIndex(int index, out decimal width)
|
||||||
{
|
{
|
||||||
|
width = 0;
|
||||||
|
|
||||||
|
if (TableRegister.HorizontalMetricsTable == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
width = TableRegister.HorizontalMetricsTable.GetAdvanceWidth(index);
|
width = TableRegister.HorizontalMetricsTable.GetAdvanceWidth(index);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user