fop 0.90alpha1

org.apache.fop.fonts
Class FontInfo

java.lang.Object
  extended byorg.apache.fop.fonts.FontInfo

public class FontInfo
extends java.lang.Object

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.


Field Summary
protected static org.apache.commons.logging.Log log
          logging instance
 
Constructor Summary
FontInfo()
          Main constructor
 
Method Summary
 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 name, FontMetrics metrics)
          Adds font metrics for a specific font.
static java.lang.String createFontKey(java.lang.String family, java.lang.String style, int weight)
          Creates a key from the given strings.
 java.lang.String 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.
 java.lang.String fontLookup(java.lang.String family, java.lang.String style, int weight)
          Lookup a font.
 java.util.Map getFonts()
          Gets a Map of all registred fonts.
 java.lang.String getFontStyleFor(java.lang.String fontName)
          Returns the font style for a particular font.
 java.lang.String getFontWeightFor(java.lang.String fontName)
          Returns the font weight for a particular font.
 FontMetrics getMetricsFor(java.lang.String fontName)
          Returns the FontMetrics for a particular font
 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.)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
logging instance

Constructor Detail

FontInfo

public FontInfo()
Main constructor

Method Detail

isSetupValid

public boolean isSetupValid()
Checks if the font setup is valid (At least the ultimate fallback font must be registered.)

Returns:
True if valid

addFontProperties

public void addFontProperties(java.lang.String name,
                              java.lang.String family,
                              java.lang.String style,
                              int weight)
Adds a new font triplet.

Parameters:
name - internal key
family - font family name
style - font style (normal, italic, oblique...)
weight - font weight

addMetrics

public void addMetrics(java.lang.String name,
                       FontMetrics metrics)
Adds font metrics for a specific font.

Parameters:
name - internal key
metrics - metrics to register

fontLookup

public java.lang.String fontLookup(java.lang.String family,
                                   java.lang.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.

Parameters:
family - font family
style - font style
weight - font weight
Returns:
internal key

findAdjustWeight

public java.lang.String 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.

Parameters:
family - font family
style - font style
weight - font weight
Returns:
internal key

hasFont

public boolean hasFont(java.lang.String family,
                       java.lang.String style,
                       int weight)
Determines if a particular font is available.

Parameters:
family - font family
style - font style
weight - font weight
Returns:
True if available

createFontKey

public static java.lang.String createFontKey(java.lang.String family,
                                             java.lang.String style,
                                             int weight)
Creates a key from the given strings.

Parameters:
family - font family
style - font style
weight - font weight
Returns:
internal key

getFonts

public java.util.Map getFonts()
Gets a Map of all registred fonts.

Returns:
a read-only Map with font key/FontMetrics pairs

getUsedFonts

public java.util.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.

Returns:
a read-only Map with font key/FontMetrics pairs

getMetricsFor

public FontMetrics getMetricsFor(java.lang.String fontName)
Returns the FontMetrics for a particular font

Parameters:
fontName - internal key
Returns:
font metrics

getFontStyleFor

public java.lang.String getFontStyleFor(java.lang.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.

Parameters:
fontName - internal key
Returns:
font style

getFontWeightFor

public java.lang.String getFontWeightFor(java.lang.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.

Parameters:
fontName - internal key
Returns:
font weight

fop 0.90alpha1

Copyright 1999-2005 The Apache Software Foundation. All Rights Reserved.