mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-19 10:47:56 +08:00
handle case insensitive truetype table tags and missing tables for postscript fonts
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
/// <summary>
|
||||
/// This table contains the data that defines the appearance of the glyphs in the font.
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
public GlyphDataTable GlyphTable { get; }
|
||||
|
||||
/// <summary>
|
||||
@@ -36,7 +35,6 @@
|
||||
/// <summary>
|
||||
/// This table stores the offsets to the locations of the glyphs (relative to the glyph table).
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
public IndexToLocationTable IndexToLocationTable { get; }
|
||||
|
||||
/// <summary>
|
||||
@@ -73,10 +71,10 @@
|
||||
}
|
||||
|
||||
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.");
|
||||
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.");
|
||||
NameTable = builder.NameTable;
|
||||
PostScriptTable = builder.PostScriptTable;
|
||||
|
@@ -20,7 +20,7 @@
|
||||
int rangeShift = data.ReadUnsignedShort();
|
||||
// ReSharper restore UnusedVariable
|
||||
|
||||
var tables = new Dictionary<string, TrueTypeHeaderTable>();
|
||||
var tables = new Dictionary<string, TrueTypeHeaderTable>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
for (var i = 0; i < numberOfTables; i++)
|
||||
{
|
||||
@@ -46,7 +46,7 @@
|
||||
var length = data.ReadUnsignedInt();
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
@@ -68,7 +68,8 @@
|
||||
{
|
||||
boundingBox = default(PdfRectangle);
|
||||
|
||||
if (!TryGetGlyphIndex(characterIdentifier, characterCodeToGlyphId, out var index))
|
||||
if (!TryGetGlyphIndex(characterIdentifier, characterCodeToGlyphId, out var index)
|
||||
|| TableRegister.GlyphTable == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -112,6 +113,13 @@
|
||||
|
||||
private bool TryGetBoundingAdvancedWidthByIndex(int index, out decimal width)
|
||||
{
|
||||
width = 0;
|
||||
|
||||
if (TableRegister.HorizontalMetricsTable == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
width = TableRegister.HorizontalMetricsTable.GetAdvanceWidth(index);
|
||||
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user