Top Description Fields Constructors Methods
com.openhtmltopdf.swing

public Class AWTFontResolver

extends Object
implements FontResolver
Class Inheritance
All Implemented Interfaces
com.openhtmltopdf.extend.FontResolver
Imports
com.openhtmltopdf.css.constants.IdentValue, com.openhtmltopdf.css.value.FontSpecification, com.openhtmltopdf.extend.FontResolver, com.openhtmltopdf.layout.SharedContext, com.openhtmltopdf.render.FSFont, java.awt.Font, .GraphicsEnvironment, java.util.ArrayList, .HashMap, .List, .Map

REsolves an AWT font instance from a list of CSS font families and characteristics.
Author
Joshua Marinacci

Field Summary

Modifier and TypeField and Description
private final Map<String, Font>
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.

private final Map<String, Font>
instanceHash

Map of concrete instances of fonts including size, weight, etc.

Constructor Summary

AccessConstructor and Description
public
AWTFontResolver()

Constructor

Method Summary

Modifier and TypeMethod and Description
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.

public void
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.

private void
init()

public FSFont
resolveFont(SharedContext ctx, String[] families, float size, IdentValue weight, IdentValue style, IdentValue variant)

Resolves a list of font families.

protected Font
resolveFont(SharedContext ctx, String font, float size, IdentValue weight, IdentValue style, IdentValue variant)

Resolves a single font name.

public FSFont
public void
setFontMapping(String
The new fontMapping value
name
,
Font
The new fontMapping value
font
)

Sets the fontMapping attribute of the FontResolver object

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

availableFontsHashback to summary
private final Map<String, Font> 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.

instanceHashback to summary
private final Map<String, Font> instanceHash

Map of concrete instances of fonts including size, weight, etc.

Constructor Detail

AWTFontResolverback to summary
public AWTFontResolver()

Constructor

Method Detail

createFontback to summary
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.

flushCacheback to summary
public void flushCache()
getFontInstanceHashNameback to summary
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.

initback to summary
private void init()
resolveFontback to summary
public FSFont resolveFont(SharedContext ctx, String[] families, float size, IdentValue weight, IdentValue style, IdentValue variant)

Resolves a list of font families.

resolveFontback to summary
protected Font resolveFont(SharedContext ctx, String font, float size, IdentValue weight, IdentValue style, IdentValue variant)

Resolves a single font name.

Todo

Make case insensitive.

resolveFontback to summary
public FSFont resolveFont(SharedContext renderingContext, FontSpecification spec)

Implements com.openhtmltopdf.extend.FontResolver.resolveFont.

setFontMappingback to summary
public void setFontMapping(String name, Font font)

Sets the fontMapping attribute of the FontResolver object

Parameters
name:String

The new fontMapping value

font:Font

The new fontMapping value