use missing width for type 1 fonts when not in pdf array

This commit is contained in:
Eliot Jones
2019-05-18 14:43:22 +01:00
parent 7a3b89ece1
commit 8a74d5b2f3

View File

@@ -127,7 +127,7 @@
boundingBox = matrix.Transform(boundingBox);
var width = matrix.TransformX(widths[characterCode - firstChar]);
var width = matrix.TransformX(GetWidth(characterCode, boundingBox));
var result = new CharacterBoundingBox(boundingBox, width);
@@ -135,6 +135,23 @@
return result;
}
private decimal GetWidth(int characterCode, PdfRectangle boundingBox)
{
var widthIndex = characterCode - firstChar;
if (widthIndex >= 0 && widthIndex < widths.Length)
{
return widths[widthIndex];
}
if (fontDescriptor?.MissingWidth != null)
{
return fontDescriptor.MissingWidth;
}
return boundingBox.Width;
}
private PdfRectangle GetBoundingBoxInGlyphSpace(int characterCode)
{