Package org.xhtmlrenderer.pdf
Class ITextFontResolver
java.lang.Object
org.xhtmlrenderer.pdf.ITextFontResolver
- All Implemented Interfaces:
FontResolver
- Direct Known Subclasses:
CJKFontResolver
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<String,
FontDescription> private final Map<String,
FontFamily> private static final org.slf4j.Logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addCourier
(Map<String, FontFamily> result) void
void
void
void
addFont
(String path, String fontFamilyNameOverride, String encoding, boolean embedded, String pathToPFB) void
addFontDirectory
(String dir, boolean embedded) private void
addFontFaceFont
(String fontFamilyNameOverride, IdentValue fontWeightOverride, IdentValue fontStyleOverride, String uri, String encoding, boolean embedded, byte[] afmttf, byte[] pfb) private void
addHelvetica
(Map<String, FontFamily> result) private void
addSymbol
(Map<String, FontFamily> result) private void
addTimes
(Map<String, FontFamily> result) private void
addZapfDingbats
(Map<String, FontFamily> result) static int
convertWeightToInt
(IdentValue weight) private com.lowagie.text.pdf.BaseFont
createFont
(String name) private com.lowagie.text.pdf.BaseFont
createFont
(String name, String encoding, boolean embedded) void
void
private boolean
fontSupported
(String uri) getDistinctFontFamilyNames
(String path, String encoding, boolean embedded) Utility method which uses iText libraries to determine the family name(s) for the font at the given path.private FontFamily
getFontFamily
(String fontFamilyName) getFonts()
void
importFontFaces
(List<FontFaceRule> fontFaces, UserAgentCallback userAgentCallback) protected Map<String,
FontFamily> (package private) String
normalizeFontFamily
(String fontFamily) private byte[]
private FSFont
resolveFont
(String[] families, float size, IdentValue weight, IdentValue style) private FSFont
resolveFont
(String fontFamily, float size, IdentValue weight, IdentValue style) resolveFont
(SharedContext renderingContext, FontSpecification spec)
-
Field Details
-
log
private static final org.slf4j.Logger log -
_fontFamilies
-
_fontCache
-
-
Constructor Details
-
ITextFontResolver
public ITextFontResolver()
-
-
Method Details
-
getFonts
-
getDistinctFontFamilyNames
public static Set<String> getDistinctFontFamilyNames(String path, String encoding, boolean embedded) Utility method which uses iText libraries to determine the family name(s) for the font at the given path. The iText APIs seem to indicate there can be more than one name, but this method will return a set of them. Use a name from this list when referencing the font in CSS for PDF output. Note that family names as reported by iText may vary from those reported by the AWT Font class, e.g. "Arial Unicode MS" for iText and "ArialUnicodeMS" for AWT.- Parameters:
path
- local path to the font fileencoding
- same as what you would use foraddFont(String, String, boolean)
embedded
- same as what you would use foraddFont(String, String, boolean)
- Returns:
- set of all family names for the font file, as reported by iText libraries
-
flushCache
public void flushCache()- Specified by:
flushCache
in interfaceFontResolver
-
flushFontFaceFonts
public void flushFontFaceFonts() -
importFontFaces
-
addFontDirectory
public void addFontDirectory(String dir, boolean embedded) throws com.lowagie.text.DocumentException, IOException - Throws:
com.lowagie.text.DocumentException
IOException
-
addFont
public void addFont(String path, boolean embedded) throws com.lowagie.text.DocumentException, IOException - Throws:
com.lowagie.text.DocumentException
IOException
-
addFont
public void addFont(String path, String encoding, boolean embedded) throws com.lowagie.text.DocumentException, IOException - Throws:
com.lowagie.text.DocumentException
IOException
-
addFont
public void addFont(String path, String encoding, boolean embedded, String pathToPFB) throws com.lowagie.text.DocumentException, IOException - Throws:
com.lowagie.text.DocumentException
IOException
-
addFont
public void addFont(String path, String fontFamilyNameOverride, String encoding, boolean embedded, String pathToPFB) throws com.lowagie.text.DocumentException, IOException - Throws:
com.lowagie.text.DocumentException
IOException
-
fontSupported
-
addFontFaceFont
private void addFontFaceFont(String fontFamilyNameOverride, IdentValue fontWeightOverride, IdentValue fontStyleOverride, String uri, String encoding, boolean embedded, byte[] afmttf, byte[] pfb) throws com.lowagie.text.DocumentException, IOException - Throws:
com.lowagie.text.DocumentException
IOException
-
readFile
- Throws:
IOException
-
getFontFamily
-
resolveFont
private FSFont resolveFont(@Nullable String[] families, float size, IdentValue weight, IdentValue style) -
normalizeFontFamily
-
resolveFont
-
convertWeightToInt
-
loadFonts
-
createFont
-
createFont
-
addCourier
-
addTimes
-
addHelvetica
-
addSymbol
-
addZapfDingbats
-