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 classprivate static classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final HashMap<String, FontFamily<Java2DFontResolver.FontDescription>> private final SharedContextMap 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 voidaddFontFaceFont(String fontFamilyNameOverride, IdentValue fontWeightOverride, IdentValue fontStyleOverride, String uri) voidaddFontFile(File fontFile, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride) Add a font using a existing file.voidaddInputStreamFont(FSSupplier<InputStream> fontSupplier, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride) protected static FontcreateFont(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.voidDeprecated.getFontFamily(String fontFamilyName) protected static StringgetFontInstanceHashName(SharedContext ctx, String name, float size, IdentValue weight, IdentValue style, IdentValue variant) Gets the hash key for a concrete instance of a font.voidimportFontFaces(List<FontFaceRule> fontFaces) private voidinit()private StringnormalizeFontFamily(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 FontresolveFontFaceBaseFont(String normalizedFontFamily, float size, IdentValue weight, IdentValue style) voidsetFontMapping(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
-