Skip to content

Commit 134e202

Browse files
committed
PDFBOX-5920: check whether the name exists in PDType1CFont.getWidth(), as suggested by Andreas Lehmkühler
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1922920 13f79535-47bb-0310-9956-ffa450edef68
1 parent ac3891a commit 134e202

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,12 @@ public float getStringWidth(String string) throws IOException
424424
{
425425
int codePoint = string.codePointAt(i);
426426
String name = getGlyphList().codePointToName(codePoint);
427+
if (!cffFont.hasGlyph(string))
428+
{
429+
throw new IllegalArgumentException(
430+
String.format("U+%04X ('%s') is not available in font %s",
431+
codePoint, name, getName()));
432+
}
427433
width += cffFont.getType1CharString(name).getWidth();
428434
}
429435
return width;

0 commit comments

Comments
 (0)