diff --git a/src/UglyToad.PdfPig/Fonts/TrueType/Parser/ITrueTypeTableParser.cs b/src/UglyToad.PdfPig/Fonts/TrueType/Parser/ITrueTypeTableParser.cs new file mode 100644 index 00000000..e5d88ae0 --- /dev/null +++ b/src/UglyToad.PdfPig/Fonts/TrueType/Parser/ITrueTypeTableParser.cs @@ -0,0 +1,9 @@ +namespace UglyToad.PdfPig.Fonts.TrueType.Parser +{ + using Tables; + + internal interface ITrueTypeTableParser where T : ITable + { + T Parse(TrueTypeHeaderTable header, TrueTypeDataBytes data, TableRegister.Builder register); + } +} \ No newline at end of file diff --git a/src/UglyToad.PdfPig/Fonts/TrueType/Parser/Os2TableParser.cs b/src/UglyToad.PdfPig/Fonts/TrueType/Parser/Os2TableParser.cs new file mode 100644 index 00000000..315be850 --- /dev/null +++ b/src/UglyToad.PdfPig/Fonts/TrueType/Parser/Os2TableParser.cs @@ -0,0 +1,104 @@ +namespace UglyToad.PdfPig.Fonts.TrueType.Parser +{ + using System.Text; + using Tables; + + internal class Os2TableParser : ITrueTypeTableParser + { + public Os2Table Parse(TrueTypeHeaderTable header, TrueTypeDataBytes data, TableRegister.Builder register) + { + data.Seek(header.Offset); + + var version = data.ReadUnsignedShort(); + + var xAvgCharWidth = data.ReadSignedShort(); + var weightClass = data.ReadUnsignedShort(); + var widthClass = data.ReadUnsignedShort(); + var typeFlags = data.ReadUnsignedShort(); + var ySubscriptXSize = data.ReadSignedShort(); + var ySubscriptYSize = data.ReadSignedShort(); + var ySubscriptXOffset = data.ReadSignedShort(); + var ySubscriptYOffset = data.ReadSignedShort(); + var ySuperscriptXSize = data.ReadSignedShort(); + var ySuperscriptYSize = data.ReadSignedShort(); + var ySuperscriptXOffset = data.ReadSignedShort(); + var ySuperscriptYOffset = data.ReadSignedShort(); + var yStrikeoutSize = data.ReadSignedShort(); + var yStrikeoutPosition = data.ReadSignedShort(); + var familyClass = data.ReadSignedShort(); + var panose = data.ReadByteArray(10); + var ulCharRange1 = (uint)data.ReadUnsignedInt(); + var ulCharRange2 = (uint)data.ReadUnsignedInt(); + var ulCharRange3 = (uint)data.ReadUnsignedInt(); + var ulCharRange4 = (uint)data.ReadUnsignedInt(); + var vendorId = data.ReadByteArray(4); + var selectionFlags = data.ReadUnsignedShort(); + var firstCharacterIndex = data.ReadUnsignedShort(); + var lastCharacterIndex = data.ReadUnsignedShort(); + var unicodeCharRange = new[] {ulCharRange1, ulCharRange2, ulCharRange3, ulCharRange4}; + + /* + * Documentation for OS/2 version 0 in Apple’s TrueType Reference Manual stops at the usLastCharIndex field + * and does not include the last five fields of the table as it was defined by Microsoft. + * Some legacy TrueType fonts may have been built with a shortened version 0 OS/2 table. + * Applications should check the table length for a version 0 OS/2 table before reading these fields. + */ + if (version == 0 && header.Length == 68) + { + return new Os2Table(header, version, xAvgCharWidth, + weightClass, widthClass, typeFlags, ySubscriptXSize, + ySubscriptYSize, + ySubscriptXOffset, + ySubscriptYOffset, + ySuperscriptXSize, + ySuperscriptYSize, + ySuperscriptXOffset, + ySuperscriptYOffset, + yStrikeoutSize, + yStrikeoutPosition, + familyClass, + panose, + unicodeCharRange, + Encoding.Unicode.GetString(vendorId), + selectionFlags, + firstCharacterIndex, + lastCharacterIndex); + } + + var sTypoAscender = data.ReadSignedShort(); + var sTypoDescender = data.ReadSignedShort(); + var sTypoLineGap = data.ReadSignedShort(); + var usWinAscent = data.ReadUnsignedShort(); + var usWinDescent = data.ReadUnsignedShort(); + + if (version == 0) + { + return null; + } + + var ulCodePageRange1 = data.ReadUnsignedInt(); + var ulCodePageRange2 = data.ReadUnsignedInt(); + if (version == 1) + { + return null; + } + + var sxHeight = data.ReadSignedShort(); + var sCapHeight = data.ReadSignedShort(); + var usDefaultChar = data.ReadUnsignedShort(); + var usBreakChar = data.ReadUnsignedShort(); + var usMaxContext = data.ReadUnsignedShort(); + + if (version < 5) + { + return null; + } + + var usLowerOpticalPointSize = data.ReadUnsignedShort(); + var usUpperOpticalPointSize = data.ReadUnsignedShort(); + + + return null; + } + } +} \ No newline at end of file diff --git a/src/UglyToad.PdfPig/Fonts/TrueType/Parser/TableParser.cs b/src/UglyToad.PdfPig/Fonts/TrueType/Parser/TableParser.cs index 4e3fa1ea..b8da39d0 100644 --- a/src/UglyToad.PdfPig/Fonts/TrueType/Parser/TableParser.cs +++ b/src/UglyToad.PdfPig/Fonts/TrueType/Parser/TableParser.cs @@ -16,48 +16,4 @@ throw new NotImplementedException(); } } - - internal class Os2TableParser : ITrueTypeTableParser - { - public Os2Table Parse(TrueTypeHeaderTable header, TrueTypeDataBytes data, TableRegister.Builder register) - { - data.Seek(header.Offset); - - var version = data.ReadUnsignedShort(); - - var xAvgCharWidth = data.ReadSignedShort(); - var usWeightClass = data.ReadUnsignedShort(); - var usWidthClass = data.ReadUnsignedShort(); - var fsType = data.ReadSignedShort(); - var ySubscriptXSize = data.ReadSignedShort(); - var ySubscriptYSize = data.ReadSignedShort(); - var ySubscriptXOffset = data.ReadSignedShort(); - var ySubscriptYOffset = data.ReadSignedShort(); - var ySuperscriptXSize = data.ReadSignedShort(); - var ySuperscriptYSize = data.ReadSignedShort(); - var ySuperscriptXOffset = data.ReadSignedShort(); - var ySuperscriptYOffset = data.ReadSignedShort(); - var yStrikeoutSize = data.ReadSignedShort(); - var yStrikeoutPosition = data.ReadSignedShort(); - var sFamilyClass = data.ReadSignedShort(); - var panose = data.ReadByteArray(10); - var ulCharRange1 = data.ReadUnsignedInt(); - var ulCharRange2 = data.ReadUnsignedInt(); - var ulCharRange3 = data.ReadUnsignedInt(); - var ulCharRange4 = data.ReadUnsignedInt(); - var vendorId = data.ReadByteArray(4); - var fsSelection = data.ReadUnsignedShort(); - var fsFirstCharIndex = data.ReadUnsignedShort(); - var fsLastCharIndex = data.ReadUnsignedShort(); - - var bytesRead = data.Position - header.Offset; - - return null; - } - } - - internal interface ITrueTypeTableParser where T : ITable - { - T Parse(TrueTypeHeaderTable header, TrueTypeDataBytes data, TableRegister.Builder register); - } } diff --git a/src/UglyToad.PdfPig/Fonts/TrueType/Tables/CMapSubTables/HighByteMappingCMapTable.cs b/src/UglyToad.PdfPig/Fonts/TrueType/Tables/CMapSubTables/HighByteMappingCMapTable.cs index a0388a2a..fb180dfa 100644 --- a/src/UglyToad.PdfPig/Fonts/TrueType/Tables/CMapSubTables/HighByteMappingCMapTable.cs +++ b/src/UglyToad.PdfPig/Fonts/TrueType/Tables/CMapSubTables/HighByteMappingCMapTable.cs @@ -77,7 +77,7 @@ { int characterCode = (i << 8) + (subHeader.FirstCode + j); - var p = data.ReadUnsignedShort(); + var p = (int)data.ReadUnsignedShort(); if (p > 0) { diff --git a/src/UglyToad.PdfPig/Fonts/TrueType/Tables/Os2RevisedVersion0Table.cs b/src/UglyToad.PdfPig/Fonts/TrueType/Tables/Os2RevisedVersion0Table.cs new file mode 100644 index 00000000..83e1687d --- /dev/null +++ b/src/UglyToad.PdfPig/Fonts/TrueType/Tables/Os2RevisedVersion0Table.cs @@ -0,0 +1,72 @@ +namespace UglyToad.PdfPig.Fonts.TrueType.Tables +{ + using System.Collections.Generic; + + /// + /// Version 0 was defined in TrueType revision 1.5 and includes fields not in the Apple specification. + /// + internal class Os2RevisedVersion0Table : Os2Table + { + public short TypographicAscender { get; } + + public short TypographicDescender { get; } + + public short TypographicLineGap { get; } + + public ushort WindowsAscent { get; } + + public ushort WindowsDescent { get; } + + public Os2RevisedVersion0Table(TrueTypeHeaderTable directoryTable, ushort version, short xAverageCharacterWidth, ushort weightClass, + ushort widthClass, + ushort typeFlags, + short ySubscriptXSize, + short ySubscriptYSize, + short ySubscriptXOffset, + short ySubscriptYOffset, + short ySuperscriptXSize, + short ySuperscriptYSize, + short ySuperscriptXOffset, + short ySuperscriptYOffset, + short yStrikeoutSize, + short yStrikeoutPosition, + short familyClass, + IReadOnlyList panose, + IReadOnlyList unicodeRanges, + string vendorId, + ushort fontSelectionFlags, + ushort firstCharacterIndex, + ushort lastCharacterIndex, + short typographicAscender, + short typographicDescender, + short typographicLineGap, + ushort windowsAscent, + ushort windowsDescent) : base(directoryTable, version, xAverageCharacterWidth, weightClass, + widthClass, + typeFlags, + ySubscriptXSize, + ySubscriptYSize, + ySubscriptXOffset, + ySubscriptYOffset, + ySuperscriptXSize, + ySuperscriptYSize, + ySuperscriptXOffset, + ySuperscriptYOffset, + yStrikeoutSize, + yStrikeoutPosition, + familyClass, + panose, + unicodeRanges, + vendorId, + fontSelectionFlags, + firstCharacterIndex, + lastCharacterIndex) + { + TypographicAscender = typographicAscender; + TypographicDescender = typographicDescender; + TypographicLineGap = typographicLineGap; + WindowsAscent = windowsAscent; + WindowsDescent = windowsDescent; + } + } +} \ No newline at end of file diff --git a/src/UglyToad.PdfPig/Fonts/TrueType/Tables/Os2Table.cs b/src/UglyToad.PdfPig/Fonts/TrueType/Tables/Os2Table.cs index 99c75cae..10c5e955 100644 --- a/src/UglyToad.PdfPig/Fonts/TrueType/Tables/Os2Table.cs +++ b/src/UglyToad.PdfPig/Fonts/TrueType/Tables/Os2Table.cs @@ -1,9 +1,178 @@ namespace UglyToad.PdfPig.Fonts.TrueType.Tables { + using System.Collections.Generic; + + /// + /// The most basic format of the OS/2 table, excluding the fields not included in the Apple version of the specification. + /// internal class Os2Table : ITable { public string Tag => TrueTypeHeaderTable.Os2; public TrueTypeHeaderTable DirectoryTable { get; } + + /// + /// The version number 0 - 5 detailing the layout of the OS/2 table. + /// + public ushort Version { get; } + + /// + /// The average width of all non-zero width characters in the font. + /// + public short XAverageCharacterWidth { get; } + + /// + /// Indicates the visual weight of characters in the font from 1 - 1000. + /// + public ushort WeightClass { get; } + + /// + /// The percentage difference from normal of the aspect ratio for this font. + /// + public ushort WidthClass { get; } + + /// + /// The font embedding licensing rights for this font. + /// + public ushort TypeFlags { get; } + + /// + /// The recommended horizontal size for subscripts using this font. + /// + public short YSubscriptXSize { get; } + + /// + /// The recommended vertical size for subscripts using this font. + /// + public short YSubscriptYSize { get; } + + /// + /// The recommended horizontal offset (from the previous glyph origin to the subscript's origin) for subscripts using this font. + /// + public short YSubscriptXOffset { get; } + + /// + /// The recommended vertical offset (from the previous glyph origin to the subscript's origin) for subscripts using this font. + /// + public short YSubscriptYOffset { get; } + + /// + /// The recommended horizontal size for superscripts using this font. + /// + public short YSuperscriptXSize { get; } + + /// + /// The recommended vertical size for superscripts using this font. + /// + public short YSuperscriptYSize { get; } + + /// + /// The recommended horizontal offset (from the previous glyph origin to the superscript's origin) for superscripts using this font. + /// + public short YSuperscriptXOffset { get; } + + /// + /// The recommended vertical offset (from the previous glyph origin to the superscript's origin) for superscripts using this font. + /// + public short YSuperscriptYOffset { get; } + + /// + /// Thickness of the strikeout stroke. + /// + public short YStrikeoutSize { get; } + + /// + /// Position of the top of the strikeout stroke relative to the baseline. + /// Positive values being above the baseline, negative values below. + /// + public short YStrikeoutPosition { get; } + + /// + /// Value registered by IBM for each font family to find substitutes. + /// The high byte is the family class, the low byte is the family subclass. + /// + public short FamilyClass { get; } + + /// + /// The PANOSE definition of 10 bytes defines various information about the + /// font enabling matching fonts based on requirements. The meaning of each + /// byte in the PANOSE definition depends on the preceding bytes. The first byte + /// is the family type, Lating, Latin Hand Written, etc. + /// + public IReadOnlyList Panose { get; } + + /// + /// Specifies Unicode blocks supported by the font file for the Microsoft platform. + /// + public IReadOnlyList UnicodeRanges { get; } + + /// + /// The four-character identifier for the vendor of the given type face. + /// + public string VendorId { get; } + + /// + /// Contains information concerning the nature of the font patterns. + /// + public ushort FontSelectionFlags { get; } + + /// + /// The minimum Unicode character code in this font. + /// + public ushort FirstCharacterIndex { get; } + + /// + /// The maximum Unicode character code in this font. + /// + public ushort LastCharacterIndex { get; } + + /// + /// Create a new . + /// + public Os2Table(TrueTypeHeaderTable directoryTable, ushort version, short xAverageCharacterWidth, ushort weightClass, + ushort widthClass, + ushort typeFlags, + short ySubscriptXSize, + short ySubscriptYSize, + short ySubscriptXOffset, + short ySubscriptYOffset, + short ySuperscriptXSize, + short ySuperscriptYSize, + short ySuperscriptXOffset, + short ySuperscriptYOffset, + short yStrikeoutSize, + short yStrikeoutPosition, + short familyClass, + IReadOnlyList panose, + IReadOnlyList unicodeRanges, + string vendorId, + ushort fontSelectionFlags, + ushort firstCharacterIndex, + ushort lastCharacterIndex) + { + DirectoryTable = directoryTable; + Version = version; + XAverageCharacterWidth = xAverageCharacterWidth; + WeightClass = weightClass; + WidthClass = widthClass; + TypeFlags = typeFlags; + YSubscriptXSize = ySubscriptXSize; + YSubscriptYSize = ySubscriptYSize; + YSubscriptXOffset = ySubscriptXOffset; + YSubscriptYOffset = ySubscriptYOffset; + YSuperscriptXSize = ySuperscriptXSize; + YSuperscriptYSize = ySuperscriptYSize; + YSuperscriptXOffset = ySuperscriptXOffset; + YSuperscriptYOffset = ySuperscriptYOffset; + YStrikeoutSize = yStrikeoutSize; + YStrikeoutPosition = yStrikeoutPosition; + FamilyClass = familyClass; + Panose = panose; + UnicodeRanges = unicodeRanges; + VendorId = vendorId; + FontSelectionFlags = fontSelectionFlags; + FirstCharacterIndex = firstCharacterIndex; + LastCharacterIndex = lastCharacterIndex; + } } } diff --git a/src/UglyToad.PdfPig/Fonts/TrueType/Tables/Os2Version1Table.cs b/src/UglyToad.PdfPig/Fonts/TrueType/Tables/Os2Version1Table.cs new file mode 100644 index 00000000..23b6ab6d --- /dev/null +++ b/src/UglyToad.PdfPig/Fonts/TrueType/Tables/Os2Version1Table.cs @@ -0,0 +1,55 @@ +namespace UglyToad.PdfPig.Fonts.TrueType.Tables +{ + using System.Collections.Generic; + + /// + /// Version 1 was defined in TrueType revision 1.66. Version 1 has two additional fields beyond those in version 0. + /// + internal class Os2Version1Table : Os2RevisedVersion0Table + { + /// + /// This field is used to specify the code pages encompassed by the font file in the 'cmap' subtable for the Microsoft platform(3), Unicode BMP encoding (1). + /// + public byte CodePage1 { get; } + + /// + /// This field is the second byte used to specify the code pages encompassed by the font file in the 'cmap' subtable for the Microsoft platform(3), Unicode BMP encoding (1). + /// + public byte CodePage2 { get; } + + public Os2Version1Table(TrueTypeHeaderTable directoryTable, ushort version, short xAverageCharacterWidth, ushort weightClass, ushort widthClass, + ushort typeFlags, + short ySubscriptXSize, + short ySubscriptYSize, + short ySubscriptXOffset, + short ySubscriptYOffset, + short ySuperscriptXSize, + short ySuperscriptYSize, + short ySuperscriptXOffset, + short ySuperscriptYOffset, + short yStrikeoutSize, + short yStrikeoutPosition, + short familyClass, + IReadOnlyList panose, + IReadOnlyList unicodeRanges, + string vendorId, + ushort fontSelectionFlags, + ushort firstCharacterIndex, + ushort lastCharacterIndex, + short typographicAscender, + short typographicDescender, + short typographicLineGap, + ushort windowsAscent, + ushort windowsDescent, + byte codePage1, + byte codePage2) : base(directoryTable, version, xAverageCharacterWidth, weightClass, widthClass, + typeFlags, ySubscriptXSize, ySubscriptYSize, ySubscriptXOffset, ySubscriptYOffset, ySuperscriptXSize, + ySuperscriptYSize, ySuperscriptXOffset, ySuperscriptYOffset, yStrikeoutSize, yStrikeoutPosition, + familyClass, panose, unicodeRanges, vendorId, fontSelectionFlags, firstCharacterIndex, lastCharacterIndex, + typographicAscender, typographicDescender, typographicLineGap, windowsAscent, windowsDescent) + { + CodePage1 = codePage1; + CodePage2 = codePage2; + } + } +} \ No newline at end of file diff --git a/src/UglyToad.PdfPig/Fonts/TrueType/Tables/Os2Version2To4OpenTypeTable.cs b/src/UglyToad.PdfPig/Fonts/TrueType/Tables/Os2Version2To4OpenTypeTable.cs new file mode 100644 index 00000000..eb531dd3 --- /dev/null +++ b/src/UglyToad.PdfPig/Fonts/TrueType/Tables/Os2Version2To4OpenTypeTable.cs @@ -0,0 +1,92 @@ +namespace UglyToad.PdfPig.Fonts.TrueType.Tables +{ + using System.Collections.Generic; + + /// + /// Version 4 was defined in OpenType 1.5. Version 4 has the same fields as in version 2 and version 3. + /// Although new fields were not added beyond those in version 2 and 3, the specification of certain fields was revised. + /// + internal class Os2Version2To4OpenTypeTable : Os2Version1Table + { + + /// + /// This metric specifies the distance between the baseline and the approximate height of non-ascending lowercase letters. + /// + public short XHeight { get; } + + /// + /// This metric specifies the distance between the baseline and the approximate height of uppercase letters. + /// + public short CapHeight { get; } + + /// + /// This is the Unicode code point, in UTF-16 encoding, of a character that can be used for a default glyph if a requested character is not supported. + /// If the value of this field is zero, glyph Id 0 is to be used for the default character. + /// + public ushort DefaultCharacter { get; } + + /// + /// This is the Unicode code point, in UTF-16 encoding, of a character that can be used as a default break character. + /// The break character is used to separate words and justify text. + /// Most fonts specify U+0020 SPACE as the break character. + /// + public ushort BreakCharacter { get; } + + /// + /// The maximum distance in glyphs that any feature of this font is capable of effecting. For example + /// kerning has a value of 2 (1 for each glyph in the kerning pair). + /// Fonts with the 'f f i' ligature would have a value of 3. + /// + public ushort MaximumContext { get; } + + /// + /// Create a new . + /// + public Os2Version2To4OpenTypeTable(TrueTypeHeaderTable directoryTable, ushort version, + short xAverageCharacterWidth, + ushort weightClass, + ushort widthClass, + ushort typeFlags, + short ySubscriptXSize, + short ySubscriptYSize, + short ySubscriptXOffset, + short ySubscriptYOffset, + short ySuperscriptXSize, + short ySuperscriptYSize, + short ySuperscriptXOffset, + short ySuperscriptYOffset, + short yStrikeoutSize, + short yStrikeoutPosition, + short familyClass, + IReadOnlyList panose, + IReadOnlyList unicodeRanges, + string vendorId, + ushort fontSelectionFlags, + ushort firstCharacterIndex, + ushort lastCharacterIndex, + short typographicAscender, + short typographicDescender, + short typographicLineGap, + ushort windowsAscent, + ushort windowsDescent, + byte codePage1, + byte codePage2, + short xHeight, + short capHeight, + ushort defaultCharacter, + ushort breakCharacter, + ushort maximumContext) : base(directoryTable, version, xAverageCharacterWidth, weightClass, widthClass, + typeFlags, ySubscriptXSize, ySubscriptYSize, ySubscriptXOffset, ySubscriptYOffset, ySuperscriptXSize, + ySuperscriptYSize, ySuperscriptXOffset, ySuperscriptYOffset, yStrikeoutSize, yStrikeoutPosition, + familyClass, panose, unicodeRanges, vendorId, fontSelectionFlags, firstCharacterIndex, lastCharacterIndex, + typographicAscender, typographicDescender, typographicLineGap, windowsAscent, windowsDescent, + codePage1, codePage2) + { + XHeight = xHeight; + CapHeight = capHeight; + DefaultCharacter = defaultCharacter; + BreakCharacter = breakCharacter; + MaximumContext = maximumContext; + } + } +} \ No newline at end of file diff --git a/src/UglyToad.PdfPig/Fonts/TrueType/Tables/Os2Version5OpenTypeTable.cs b/src/UglyToad.PdfPig/Fonts/TrueType/Tables/Os2Version5OpenTypeTable.cs new file mode 100644 index 00000000..915f93aa --- /dev/null +++ b/src/UglyToad.PdfPig/Fonts/TrueType/Tables/Os2Version5OpenTypeTable.cs @@ -0,0 +1,75 @@ +namespace UglyToad.PdfPig.Fonts.TrueType.Tables +{ + using System.Collections.Generic; + + /// + /// Version 5 was defined in OpenType 1.7. + /// Version 5 has two additional fields beyond those in versions 2 - 4. + /// + internal class Os2Version5OpenTypeTable : Os2Version2To4OpenTypeTable + { + /// + /// This value is the lower value of the size range for which this font has been designed. + /// The units for this field are TWIPs (one-twentieth of a point, or 1440 per inch). + /// This is the inclusive lower bound. + /// + public ushort LowerOpticalPointSize { get; } + + /// + /// This value is the upper value of the size range for which this font has been designed. + /// The units for this field are TWIPs (one-twentieth of a point, or 1440 per inch). + /// This is the exclusive upper bound. + /// + public ushort UpperOpticalPointSize { get; } + + /// + /// Create a new . + /// + public Os2Version5OpenTypeTable(TrueTypeHeaderTable directoryTable, + ushort version, short xAverageCharacterWidth, + ushort weightClass, + ushort widthClass, + ushort typeFlags, + short ySubscriptXSize, + short ySubscriptYSize, + short ySubscriptXOffset, + short ySubscriptYOffset, + short ySuperscriptXSize, + short ySuperscriptYSize, + short ySuperscriptXOffset, + short ySuperscriptYOffset, + short yStrikeoutSize, + short yStrikeoutPosition, + short familyClass, + IReadOnlyList panose, + IReadOnlyList unicodeRanges, + string vendorId, + ushort fontSelectionFlags, + ushort firstCharacterIndex, + ushort lastCharacterIndex, + short typographicAscender, + short typographicDescender, + short typographicLineGap, + ushort windowsAscent, + ushort windowsDescent, + byte codePage1, + byte codePage2, + short xHeight, + short capHeight, + ushort defaultCharacter, + ushort breakCharacter, + ushort maximumContext, + ushort lowerOpticalPointSize, + ushort upperOpticalPointSize) : base(directoryTable, version, xAverageCharacterWidth, weightClass, + widthClass, typeFlags, ySubscriptXSize, ySubscriptYSize, ySubscriptXOffset, ySubscriptYOffset, + ySuperscriptXSize, ySuperscriptYSize, ySuperscriptXOffset, ySuperscriptYOffset, yStrikeoutSize, + yStrikeoutPosition, familyClass, panose, unicodeRanges, vendorId, fontSelectionFlags, + firstCharacterIndex, lastCharacterIndex, typographicAscender, typographicDescender, + typographicLineGap, windowsAscent, windowsDescent, codePage1, codePage2, xHeight, + capHeight, defaultCharacter, breakCharacter, maximumContext) + { + LowerOpticalPointSize = lowerOpticalPointSize; + UpperOpticalPointSize = upperOpticalPointSize; + } + } +} \ No newline at end of file diff --git a/src/UglyToad.PdfPig/Fonts/TrueType/TrueTypeDataBytes.cs b/src/UglyToad.PdfPig/Fonts/TrueType/TrueTypeDataBytes.cs index 3a408624..7e24d9e4 100644 --- a/src/UglyToad.PdfPig/Fonts/TrueType/TrueTypeDataBytes.cs +++ b/src/UglyToad.PdfPig/Fonts/TrueType/TrueTypeDataBytes.cs @@ -31,11 +31,11 @@ return unchecked((short)((internalBuffer[0] << 8) + (internalBuffer[1] << 0))); } - public int ReadUnsignedShort() + public ushort ReadUnsignedShort() { ReadBuffered(internalBuffer, 2); - return (internalBuffer[0] << 8) + (internalBuffer[1] << 0); + return (ushort)((internalBuffer[0] << 8) + (internalBuffer[1] << 0)); } public int ReadUnsignedByte()