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;
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));
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 {
assertNull(family);
}
+ @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);