org.apache.fop.render.awt
Class AWTFontMetrics


public class AWTFontMetrics

This is a FontMetrics to be used for AWT rendering. It instanciates a font, depening on famil and style values. The java.awt.FontMetrics for this font is then created to be used for the actual measurement. Since layout is word by word and since it is expected that two subsequent words often share the same style, the Font and FontMetrics is buffered and only changed if needed.

Since FontState and FontInfo multiply all factors by size, we assume a "standard" font of FONT_SIZE.


Field Summary
 final static intFONT_FACTOR
          This factor multiplies the calculated values to scale to FOP internal measurements
 final static intFONT_SIZE
          Font size standard used for metric measurements
 (package private) Componentparent
          Component parent is needed to have an AWT reference from which to get the font metrics

Constructor Summary
AWTFontMetrics(Component parent)
          Constructs a new Font-metrics.

Method Summary
 intgetAscender(String family, int style, int size)
          Determines the font ascent of the Font described by this FontMetrics object
 intgetCapHeight(String family, int style, int size)
          The size of a capital letter measured from the font's baseline
 intgetDescender(String family, int style, int size)
          Determines the font descent of the Font described by this FontMetrics object
 java.awt.FontgetFont(String family, int style, int size)
          Returns a java.awt.Font instance for the desired family, style and size type.
 int[]getWidths(String family, int style, int size)
          Return widths (in 1/1000ths of point size) of all characters
 intgetXHeight(String family, int style, int size)
          Determines the typical font height of a small cap letter FontMetrics object
 intwidth(int i, String family, int style, int size)
          Returns width (in 1/1000ths of point size) of character at code point i

Field Detail

FONT_FACTOR

public final static int FONT_FACTOR
This factor multiplies the calculated values to scale to FOP internal measurements

FONT_SIZE

public final static int FONT_SIZE
Font size standard used for metric measurements

parent

Component parent
Component parent is needed to have an AWT reference from which to get the font metrics
Constructor Detail

AWTFontMetrics

public AWTFontMetrics(Component parent)
Constructs a new Font-metrics.
Parameters:
parent - an AWT component - this is needed so that we can get an instance of java.awt.FontMetrics
Method Detail

getAscender

public int getAscender(String family, int style, int size)
Determines the font ascent of the Font described by this FontMetrics object
Parameters:
family - font family (jave name) to use
style - font style (jave def.) to use
Returns: ascent in milliponts

getCapHeight

public int getCapHeight(String family, int style, int size)
The size of a capital letter measured from the font's baseline

getDescender

public int getDescender(String family, int style, int size)
Determines the font descent of the Font described by this FontMetrics object
Parameters:
family - font family (jave name) to use
style - font style (jave def.) to use
Returns: descent in milliponts

getFont

public java.awt.Font getFont(String family, int style, int size)
Returns a java.awt.Font instance for the desired family, style and size type. This is here, so that the font-mapping of FOP-defined fonts to java-fonts can be done in one place and does not need to occur in AWTFontRenderer.
Parameters:
family - font family (jave name) to use
style - font style (jave def.) to use
size - font size
Returns: font with the desired characeristics.

getWidths

public int[] getWidths(String family, int style, int size)
Return widths (in 1/1000ths of point size) of all characters
Parameters:
family - font family (jave name) to use
style - font style (jave def.) to use

getXHeight

public int getXHeight(String family, int style, int size)
Determines the typical font height of a small cap letter FontMetrics object
Parameters:
family - font family (jave name) to use
style - font style (jave def.) to use
Returns: font height in milliponts

width

public int width(int i, String family, int style, int size)
Returns width (in 1/1000ths of point size) of character at code point i
Parameters:
i - the character for which to get the width
family - font family (jave name) to use
style - font style (jave def.) to use
size - the of the font

Association Links

to Class java.awt.Font

Buffered font. f1 is bufferd for metric measurements during layout. fSized is buffered for display purposes

to Class java.lang.String

The family type of the font last used

to Class java.awt.FontMetrics

The FontMetrics object used to calculate character width etc.

to Class java.awt.Component

Component parent is needed to have an AWT reference from which to get the font metrics