Skip to content

Commit b8eb725

Browse files
Fix NullPointerExceprion when getGID() was called on null (#688)
1 parent 6ccfa77 commit b8eb725

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/main/java/org/verapdf/pd/font/truetype/TrueTypeFontProgram.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ public float getWidth(int code) {
126126
width = getWidth(TrueTypePredefined.NOTDEF_STRING);
127127
}
128128
if (width == -1) {
129+
if (this.parser.getCmapParser() == null) {
130+
return 0;
131+
}
129132
int gid = this.parser.getCmapParser().getGID(code);
130133
return getWidthWithCheck(gid);
131134
}
@@ -221,6 +224,9 @@ private float getWidthSymbolic(int code) {
221224
gid = cmap10.getGlyph(code);
222225
return getWidthWithCheck(gid);
223226
}
227+
if (this.parser.getCmapParser() == null) {
228+
return 0;
229+
}
224230
gid = this.parser.getCmapParser().getGID(code);
225231
return getWidthWithCheck(gid);
226232
}

0 commit comments

Comments
 (0)