Skip to content

Commit 7797df7

Browse files
committed
Prevent font comparison from throwing NPE.
By mistake we didn't check that family font name exists. DEVSIX-3389
1 parent 96b8bfb commit 7797df7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

layout/src/main/java/com/itextpdf/layout/font/FontSelector.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,11 @@ private static int characteristicsSimilarity(String fontFamily, FontCharacterist
196196

197197
if (!fontFamilySetByCharacteristics) {
198198
// if alias is set, fontInfo's descriptor should not be checked
199-
if (!"".equals(fontFamily) && (null == fontInfo.getAlias() && fontInfo.getDescriptor().getFamilyNameLowerCase().equals(fontFamily) || (null != fontInfo.getAlias() && fontInfo.getAlias().toLowerCase().equals(fontFamily)))) {
199+
if (!"".equals(fontFamily)
200+
&& (null == fontInfo.getAlias()
201+
&& null != fontInfo.getDescriptor().getFamilyNameLowerCase()
202+
&& fontInfo.getDescriptor().getFamilyNameLowerCase().equals(fontFamily)
203+
|| (null != fontInfo.getAlias() && fontInfo.getAlias().toLowerCase().equals(fontFamily)))) {
200204
score += FONT_FAMILY_EQUALS_AWARD;
201205
} else {
202206
if (!isLastFontFamilyToBeProcessed) {

0 commit comments

Comments
 (0)