Package com.openhtmltopdf.java2d
Class Java2DFontResolver
java.lang.Object
com.openhtmltopdf.java2d.Java2DFontResolver
- All Implemented Interfaces:
FontResolver
REsolves an AWT font instance from a list of CSS font families and characteristics.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
private static class
private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final HashMap
<String, FontFamily<Java2DFontResolver.FontDescription>> private final SharedContext
Map of base fonts, from which we can derive a concrete instance at the correct size, weight, etc.Map of concrete instances of fonts including size, weight, etc. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addFontFaceFont
(String fontFamilyNameOverride, IdentValue fontWeightOverride, IdentValue fontStyleOverride, String uri) void
addFontFile
(File fontFile, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride) Add a font using a existing file.void
addInputStreamFont
(FSSupplier<InputStream> fontSupplier, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride) protected static Font
createFont
(SharedContext ctx, Font rootFont, float size, IdentValue weight, IdentValue style, IdentValue variant) Creates a concrete instance of a font at specified size, weight, style and variant.void
Deprecated.getFontFamily
(String fontFamilyName) protected static String
getFontInstanceHashName
(SharedContext ctx, String name, float size, IdentValue weight, IdentValue style, IdentValue variant) Gets the hash key for a concrete instance of a font.void
importFontFaces
(List<FontFaceRule> fontFaces) private void
init()
private String
normalizeFontFamily
(String fontFamily) resolveFont
(SharedContext renderingContext, FontSpecification spec) resolveFont
(SharedContext ctx, String[] families, float size, IdentValue weight, IdentValue style, IdentValue variant) Resolves a list of font families.private Font
resolveFontFaceBaseFont
(String normalizedFontFamily, float size, IdentValue weight, IdentValue style) void
setFontMapping
(String name, Font font) Sets the fontMapping attribute of the FontResolver object
-
Field Details
-
instanceHash
Map of concrete instances of fonts including size, weight, etc. -
availableFontsHash
Map of base fonts, from which we can derive a concrete instance at the correct size, weight, etc. Note: The value is initially null until we need the given base font. -
_fontFamilies
-
-
Constructor Details
-
Method Details
-
init
private void init() -
flushCache
Deprecated. -
importFontFaces
-
addInputStreamFont
public void addInputStreamFont(FSSupplier<InputStream> fontSupplier, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride) -
addFontFaceFont
private void addFontFaceFont(String fontFamilyNameOverride, IdentValue fontWeightOverride, IdentValue fontStyleOverride, String uri) -
addFontFile
public void addFontFile(File fontFile, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride) Add a font using a existing file. Does not handle true type collections. -
getFontFamily
-
normalizeFontFamily
-
resolveFontFaceBaseFont
private Font resolveFontFaceBaseFont(String normalizedFontFamily, float size, IdentValue weight, IdentValue style) -
setFontMapping
Sets the fontMapping attribute of the FontResolver object- Parameters:
name
- The new fontMapping valuefont
- The new fontMapping value
-