always use cidtogid map over truetype cmap where available

This commit is contained in:
Eliot Jones
2018-04-17 00:14:53 +01:00
parent 8d591ca913
commit 4b66addf6d
3 changed files with 16 additions and 13 deletions

View File

@@ -8,9 +8,9 @@
/// </summary>
internal interface ICidFontProgram
{
bool TryGetBoundingBox(int characterCode, out PdfRectangle boundingBox);
bool TryGetBoundingBox(int characterIdentifier, out PdfRectangle boundingBox);
bool TryGetBoundingBox(int characterCode, Func<int, int> characterIdentifierToGlyphIndex, out PdfRectangle boundingBox);
bool TryGetBoundingBox(int characterIdentifier, Func<int, int> characterIdentifierToGlyphIndex, out PdfRectangle boundingBox);
bool TryGetBoundingAdvancedWidth(int characterCode, out decimal width);

View File

@@ -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()

View File

@@ -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<int, int> characterIdentifierToGlyphIndex, out PdfRectangle boundingBox)
public bool TryGetBoundingBox(int characterIdentifier, out PdfRectangle boundingBox) => TryGetBoundingBox(characterIdentifier, null, out boundingBox);
public bool TryGetBoundingBox(int characterIdentifier, Func<int, int> 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;
}