The FontInfo for the layout and rendering of a fo document.
This stores the list of available fonts that are setup by
the renderer. The font name can be retrieved for the
family style and weight.
Currently font supported font-variant small-caps is not
implemented.
addFontProperties
public void addFontProperties(String name,
String family,
String style,
int weight)
Adds a new font triplet.
name
- internal keyfamily
- font family namestyle
- font style (normal, italic, oblique...)weight
- font weight
addFontProperties
public void addFontProperties(String name,
FontTriplet triplet)
Adds a new font triplet.
name
- internal keytriplet
- the font triplet to associate with the internal key
addMetrics
public void addMetrics(String name,
FontMetrics metrics)
Adds font metrics for a specific font.
name
- internal keymetrics
- metrics to register
createFontKey
public static FontTriplet createFontKey(String family,
String style,
int weight)
Creates a key from the given strings.
family
- font familystyle
- font styleweight
- font weight
findAdjustWeight
public FontTriplet findAdjustWeight(String family,
String style,
int weight)
Find a font with a given family and style by trying
different font weights according to the spec.
family
- font familystyle
- font styleweight
- font weight
fontLookup
public FontTriplet fontLookup(String family,
String style,
int weight)
Lookup a font.
Locate the font name for a given family, style and weight.
The font name can then be used as a key as it is unique for
the associated document.
This also adds the font to the list of used fonts.
family
- font familystyle
- font styleweight
- font weight
- the font triplet of the font chosen
fontLookup
public FontTriplet fontLookup(String[] family,
String style,
int weight)
Lookup a font.
Locate the font name for a given family, style and weight.
The font name can then be used as a key as it is unique for
the associated document.
This also adds the font to the list of used fonts.
family
- font family (priority list)style
- font styleweight
- font weight
- font triplet of the font chosen
getFontInstance
public Font getFontInstance(FontTriplet triplet,
int fontSize)
Retrieves a (possibly cached) Font instance based on a FontTriplet and a font size.
triplet
- the font triplet designating the requested fontfontSize
- the font size
- the requested Font instance
getFontStyleFor
public String getFontStyleFor(String fontName)
Returns the font style for a particular font.
There may be multiple font styles matching this font. Only the first
found is returned. Searching is done on a sorted list to guarantee consistent
results.
getFontWeightFor
public int getFontWeightFor(String fontName)
Returns the font weight for a particular font.
There may be multiple font weights matching this font. Only the first
found is returned. Searching is done on a sorted list to guarantee consistent
results.
getFonts
public Map getFonts()
Gets a Map of all registred fonts.
- a read-only Map with font key/FontMetrics pairs
getInternalFontKey
public String getInternalFontKey(FontTriplet triplet)
Returns the internal font key (F1, F2, F3 etc.) for a given triplet.
triplet
- the font triplet
- the associated internal key or null, if not found
getMetricsFor
public FontMetrics getMetricsFor(String fontName)
Returns the FontMetrics for a particular font
getTripletFor
public FontTriplet getTripletFor(String fontName)
Returns the first triplet matching the given font name.
As there may be multiple triplets matching the font name
the result set is sorted first to guarantee consistent results.
fontName
- The font name we are looking for
- The first triplet for the given font name
getUsedFonts
public Map getUsedFonts()
This is used by the renderers to retrieve all the
fonts used in the document.
This is for embedded font or creating a list of used fonts.
- a read-only Map with font key/FontMetrics pairs
hasFont
public boolean hasFont(String family,
String style,
int weight)
Determines if a particular font is available.
family
- font familystyle
- font styleweight
- font weight
isSetupValid
public boolean isSetupValid()
Checks if the font setup is valid (At least the ultimate fallback font
must be registered.)
useFont
public void useFont(String internalName)
Tells this class that the font with the given internal name has been used.
internalName
- the internal font name (F1, F2 etc.)