List of usage examples for com.itextpdf.text Font getFamily
public FontFamily getFamily()
From source file:adams.core.io.PdfFont.java
License:Open Source License
/** * Turns the font family into the String constant of the font family. * * @param font the font to analyze/* w w w . j a va2 s . c o m*/ * @return the font family name */ public static String getFontFamily(Font font) { return getFontFamily(font.getFamily().ordinal()); }
From source file:org.ganttproject.impex.htmlpdf.fonts.TTFontCache.java
License:Open Source License
public FontMapper getFontMapper(final FontSubstitutionModel substitutions, final String charset) { return new FontMapper() { private Map<Font, BaseFont> myFontCache = new HashMap<Font, BaseFont>(); @Override//from ww w.ja v a 2 s . co m public BaseFont awtToPdf(Font awtFont) { if (myFontCache.containsKey(awtFont)) { return myFontCache.get(awtFont); } String family = awtFont.getFamily().toLowerCase(); Function<String, BaseFont> f = myMap_Family_ItextFont.get(family); if (f != null) { BaseFont result = f.apply(charset); myFontCache.put(awtFont, result); return result; } family = family.replace(' ', '_'); if (myProperties.containsKey("font." + family)) { family = String.valueOf(myProperties.get("font." + family)); } FontSubstitution substitution = substitutions.getSubstitution(family); if (substitution != null) { family = substitution.getSubstitutionFamily(); } f = myMap_Family_ItextFont.get(family); if (f != null) { BaseFont result = f.apply(charset); myFontCache.put(awtFont, result); return result; } BaseFont result = getFallbackFont(charset); if (result == null) { GPLogger.log(new RuntimeException("Font with family=" + awtFont.getFamily() + " not found. Also tried family=" + family + " and fallback font")); } return result; } @Override public Font pdfToAwt(BaseFont itextFont, int size) { return null; } }; }