public class FontInfo
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static org.apache.commons.logging.Log |
log
logging instance
|
Constructor and Description |
---|
FontInfo()
Main constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addFontProperties(java.lang.String internalFontKey,
FontTriplet triplet)
Adds a new font triplet.
|
void |
addFontProperties(java.lang.String name,
java.lang.String[] families,
java.lang.String style,
int weight)
Adds a series of new font triplets given an array of font family names.
|
void |
addFontProperties(java.lang.String name,
java.lang.String family,
java.lang.String style,
int weight)
Adds a new font triplet.
|
void |
addMetrics(java.lang.String internalFontKey,
FontMetrics metrics)
Adds font metrics for a specific font.
|
static FontTriplet |
createFontKey(java.lang.String family,
java.lang.String style,
int weight)
Creates a key from the given strings.
|
void |
dumpAllTripletsToSystemOut()
Diagnostic method for logging all registered fonts to System.out.
|
FontTriplet |
findAdjustWeight(java.lang.String family,
java.lang.String style,
int weight)
Find a font with a given family and style by trying
different font weights according to the spec.
|
FontTriplet[] |
fontLookup(java.lang.String[] families,
java.lang.String style,
int weight)
Looks up a set of fonts.
|
FontTriplet |
fontLookup(java.lang.String family,
java.lang.String style,
int weight)
Lookup a font.
|
Font |
getFontInstance(FontTriplet triplet,
int fontSize)
Retrieves a (possibly cached) Font instance based on a FontTriplet and a font size.
|
Font |
getFontInstanceForAWTFont(java.awt.Font awtFont)
Returns a suitable internal font given an AWT Font instance.
|
java.util.Map |
getFonts()
Gets a Map of all registered fonts.
|
java.lang.String |
getFontStyleFor(java.lang.String fontName)
Returns the font style for a particular font.
|
java.util.Map |
getFontTriplets()
Gets a Map of all registered font triplets.
|
int |
getFontWeightFor(java.lang.String fontName)
Returns the font weight for a particular font.
|
java.lang.String |
getInternalFontKey(FontTriplet triplet)
Returns the internal font key (F1, F2, F3 etc.) for a given triplet.
|
FontMetrics |
getMetricsFor(java.lang.String fontName)
Returns the FontMetrics for a particular font
|
FontTriplet |
getTripletFor(java.lang.String fontName)
Returns the first triplet matching the given font name.
|
java.util.List |
getTripletsFor(java.lang.String fontName)
Returns all font triplet matching the given font name.
|
java.util.Map |
getUsedFonts()
This is used by the renderers to retrieve all the
fonts used in the document.
|
boolean |
hasFont(java.lang.String family,
java.lang.String style,
int weight)
Determines if a particular font is available.
|
boolean |
isSetupValid()
Checks if the font setup is valid (At least the ultimate fallback font
must be registered.)
|
void |
setEventListener(FontEventListener listener)
Sets the font event listener that can be used to receive events about particular events
in this class.
|
java.lang.String |
toString() |
void |
useFont(java.lang.String internalName)
Tells this class that the font with the given internal name has been used.
|
public void setEventListener(FontEventListener listener)
listener
- the font event listenerpublic boolean isSetupValid()
public void addFontProperties(java.lang.String name, java.lang.String family, java.lang.String style, int weight)
name
- internal keyfamily
- font family namestyle
- font style (normal, italic, oblique...)weight
- font weightpublic void addFontProperties(java.lang.String name, java.lang.String[] families, java.lang.String style, int weight)
name
- internal keyfamilies
- an array of font family namesstyle
- font style (normal, italic, oblique...)weight
- font weightpublic void addFontProperties(java.lang.String internalFontKey, FontTriplet triplet)
internalFontKey
- internal font keytriplet
- the font triplet to associate with the internal keypublic void addMetrics(java.lang.String internalFontKey, FontMetrics metrics)
internalFontKey
- internal keymetrics
- metrics to registerpublic void useFont(java.lang.String internalName)
internalName
- the internal font name (F1, F2 etc.)public Font getFontInstance(FontTriplet triplet, int fontSize)
triplet
- the font triplet designating the requested fontfontSize
- the font sizepublic Font getFontInstanceForAWTFont(java.awt.Font awtFont)
awtFont
- the AWT fontpublic FontTriplet fontLookup(java.lang.String family, java.lang.String style, int weight)
family
- font familystyle
- font styleweight
- font weightpublic FontTriplet[] fontLookup(java.lang.String[] families, java.lang.String style, int weight)
families
- font families (priority list)style
- font styleweight
- font weightpublic FontTriplet findAdjustWeight(java.lang.String family, java.lang.String style, int weight)
family
- font familystyle
- font styleweight
- font weightpublic boolean hasFont(java.lang.String family, java.lang.String style, int weight)
family
- font familystyle
- font styleweight
- font weightpublic java.lang.String getInternalFontKey(FontTriplet triplet)
triplet
- the font tripletpublic static FontTriplet createFontKey(java.lang.String family, java.lang.String style, int weight)
family
- font familystyle
- font styleweight
- font weightpublic java.util.Map getFonts()
public java.util.Map getFontTriplets()
public java.util.Map getUsedFonts()
public FontMetrics getMetricsFor(java.lang.String fontName)
fontName
- internal keypublic java.util.List getTripletsFor(java.lang.String fontName)
fontName
- The font name we are looking forpublic FontTriplet getTripletFor(java.lang.String fontName)
fontName
- The font name we are looking forpublic java.lang.String getFontStyleFor(java.lang.String fontName)
fontName
- internal keypublic int getFontWeightFor(java.lang.String fontName)
fontName
- internal keypublic void dumpAllTripletsToSystemOut()
public java.lang.String toString()
toString
in class java.lang.Object
Copyright 1999-2010 The Apache Software Foundation. All Rights Reserved.