diff --git a/src/UglyToad.PdfPig/Fonts/CidFonts/ICidFontProgram.cs b/src/UglyToad.PdfPig/Fonts/CidFonts/ICidFontProgram.cs index 23b7ab5f..379a3dbd 100644 --- a/src/UglyToad.PdfPig/Fonts/CidFonts/ICidFontProgram.cs +++ b/src/UglyToad.PdfPig/Fonts/CidFonts/ICidFontProgram.cs @@ -8,9 +8,9 @@ /// internal interface ICidFontProgram { - bool TryGetBoundingBox(int characterCode, out PdfRectangle boundingBox); + bool TryGetBoundingBox(int characterIdentifier, out PdfRectangle boundingBox); - bool TryGetBoundingBox(int characterCode, Func characterIdentifierToGlyphIndex, out PdfRectangle boundingBox); + bool TryGetBoundingBox(int characterIdentifier, Func characterIdentifierToGlyphIndex, out PdfRectangle boundingBox); bool TryGetBoundingAdvancedWidth(int characterCode, out decimal width); diff --git a/src/UglyToad.PdfPig/Fonts/Composite/Type0Font.cs b/src/UglyToad.PdfPig/Fonts/Composite/Type0Font.cs index c36dd898..048faedf 100644 --- a/src/UglyToad.PdfPig/Fonts/Composite/Type0Font.cs +++ b/src/UglyToad.PdfPig/Fonts/Composite/Type0Font.cs @@ -89,9 +89,9 @@ public PdfRectangle GetBoundingBoxInGlyphSpace(int characterCode) { - var cid = CMap.ConvertToCid(characterCode); + var characterIdentifier = CMap.ConvertToCid(characterCode); - return CidFont.GetBoundingBox(cid); + return CidFont.GetBoundingBox(characterIdentifier); } public TransformationMatrix GetFontMatrix() diff --git a/src/UglyToad.PdfPig/Fonts/TrueType/TrueTypeFont.cs b/src/UglyToad.PdfPig/Fonts/TrueType/TrueTypeFont.cs index f6de8d3f..01c21797 100644 --- a/src/UglyToad.PdfPig/Fonts/TrueType/TrueTypeFont.cs +++ b/src/UglyToad.PdfPig/Fonts/TrueType/TrueTypeFont.cs @@ -28,12 +28,12 @@ GlyphTable = tableRegister.GlyphDataTable; } - public bool TryGetBoundingBox(int characterCode, out PdfRectangle boundingBox) => TryGetBoundingBox(characterCode, null, out boundingBox); - public bool TryGetBoundingBox(int characterCode, Func characterIdentifierToGlyphIndex, out PdfRectangle boundingBox) + public bool TryGetBoundingBox(int characterIdentifier, out PdfRectangle boundingBox) => TryGetBoundingBox(characterIdentifier, null, out boundingBox); + public bool TryGetBoundingBox(int characterIdentifier, Func characterIdentifierToGlyphIndex, out PdfRectangle boundingBox) { boundingBox = default(PdfRectangle); - if (!TryGetGlyphIndex(characterCode, characterIdentifierToGlyphIndex, out var index)) + if (!TryGetGlyphIndex(characterIdentifier, characterIdentifierToGlyphIndex, out var index)) { return false; } @@ -85,16 +85,19 @@ { glyphIndex = 0; - if (CMapTable == null) - { - if (characterIdentifierToGlyphIndex == null) + if (characterIdentifierToGlyphIndex != null) { - return false; + glyphIndex = characterIdentifierToGlyphIndex(characterIdentifier); + + return true; } - glyphIndex = characterIdentifierToGlyphIndex(characterIdentifier); + if (CMapTable == null) + { + return false; } - else if (!CMapTable.TryGetGlyphIndex(characterIdentifier, out glyphIndex)) + + if (!CMapTable.TryGetGlyphIndex(characterIdentifier, out glyphIndex)) { return false; }