diff options
-rw-r--r-- | fop-core/src/main/java/org/apache/fop/svg/font/FOPFontFamilyResolverImpl.java | 7 | ||||
-rw-r--r-- | fop-core/src/test/java/org/apache/fop/svg/font/FOPFontFamilyResolverTestCase.java | 9 |
2 files changed, 15 insertions, 1 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/svg/font/FOPFontFamilyResolverImpl.java b/fop-core/src/main/java/org/apache/fop/svg/font/FOPFontFamilyResolverImpl.java index 4305838da..a4e743571 100644 --- a/fop-core/src/main/java/org/apache/fop/svg/font/FOPFontFamilyResolverImpl.java +++ b/fop-core/src/main/java/org/apache/fop/svg/font/FOPFontFamilyResolverImpl.java @@ -21,6 +21,7 @@ package org.apache.fop.svg.font; import java.io.InputStream; import java.util.Map; +import java.util.Set; import org.apache.batik.bridge.FontFace; import org.apache.batik.gvt.font.GVTFontFace; @@ -68,7 +69,11 @@ public class FOPFontFamilyResolverImpl implements FOPFontFamilyResolver { Map<String, Typeface> fonts = fontInfo.getFonts(); for (Typeface font : fonts.values()) { if (font.hasChar(c)) { - String fontFamily = font.getFamilyNames().iterator().next(); + Set<String> familyNames = font.getFamilyNames(); + String fontFamily = font.getFontName(); + if (!familyNames.isEmpty()) { + fontFamily = familyNames.iterator().next(); + } return new FOPGVTFontFamily(fontInfo, fontFamily, new FontTriplet(fontFamily, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL), new GVTFontFace(fontFamily)); diff --git a/fop-core/src/test/java/org/apache/fop/svg/font/FOPFontFamilyResolverTestCase.java b/fop-core/src/test/java/org/apache/fop/svg/font/FOPFontFamilyResolverTestCase.java index d14752b90..4376779f9 100644 --- a/fop-core/src/test/java/org/apache/fop/svg/font/FOPFontFamilyResolverTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/svg/font/FOPFontFamilyResolverTestCase.java @@ -42,6 +42,7 @@ import static org.junit.Assert.assertTrue; import org.apache.batik.gvt.font.GVTFontFamily; import org.apache.batik.gvt.font.GVTLineMetrics; +import org.apache.fop.fonts.CustomFont; import org.apache.fop.fonts.FontInfo; public class FOPFontFamilyResolverTestCase { @@ -80,6 +81,14 @@ public class FOPFontFamilyResolverTestCase { } @Test + public void testGetFamilyThatCanDisplayNoFamily() { + CustomFont font = (CustomFont) fontInfo.getFonts().values().iterator().next(); + font.setFamilyNames(Collections.<String>emptySet()); + GVTFontFamily family = resolver.getFamilyThatCanDisplay('\u0180'); + assertEquals(font.getFontName(), family.getFamilyName()); + } + + @Test public void testDeriveFont() { FOPGVTFontFamily family = resolver.resolve(FontInfoBuilder.DEJAVU_LGC_SERIF); FOPGVTFont font = family.deriveFont(10, Collections.emptyMap()); |