Package com.openhtmltopdf.java2d
Class Java2DFontResolver
- java.lang.Object
-
- com.openhtmltopdf.java2d.Java2DFontResolver
-
- All Implemented Interfaces:
FontResolver
public class Java2DFontResolver extends Object implements FontResolver
REsolves an AWT font instance from a list of CSS font families and characteristics.- Author:
- Joshua Marinacci
-
-
Constructor Summary
Constructors Constructor Description Java2DFontResolver(SharedContext sharedCtx, boolean useEnvironmentFonts)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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.voidflushCache()Deprecated.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)FSFontresolveFont(SharedContext renderingContext, FontSpecification spec)FSFontresolveFont(SharedContext ctx, String[] families, float size, IdentValue weight, IdentValue style, IdentValue variant)Resolves a list of font families.voidsetFontMapping(String name, Font font)Sets the fontMapping attribute of the FontResolver object
-
-
-
Constructor Detail
-
Java2DFontResolver
public Java2DFontResolver(SharedContext sharedCtx, boolean useEnvironmentFonts)
-
-
Method Detail
-
flushCache
@Deprecated public void flushCache()
Deprecated.
-
importFontFaces
public void importFontFaces(List<FontFaceRule> fontFaces)
-
addInputStreamFont
public void addInputStreamFont(FSSupplier<InputStream> fontSupplier, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride)
-
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.
-
resolveFont
public FSFont resolveFont(SharedContext ctx, String[] families, float size, IdentValue weight, IdentValue style, IdentValue variant)
Resolves a list of font families. Search order for each family is: 1. Concrete fonts with correct size that have already been used. 2. Font face fonts. 3. System fonts.
-
setFontMapping
public void setFontMapping(String name, Font font)
Sets the fontMapping attribute of the FontResolver object- Parameters:
name- The new fontMapping valuefont- The new fontMapping value
-
createFont
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.
-
getFontInstanceHashName
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. This incorporates size, weight, etc.
-
resolveFont
public FSFont resolveFont(SharedContext renderingContext, FontSpecification spec)
- Specified by:
resolveFontin interfaceFontResolver
-
-