org.apache.fop.fonts
Class Font
java.lang.Object
org.apache.fop.fonts.Font
public class Font
extends java.lang.Object
This class holds font state information and provides access to the font
metrics.
DEFAULT_FONT
public static final FontTriplet DEFAULT_FONT
Default fallback key
STYLE_ITALIC
public static final String STYLE_ITALIC
Italic font style
STYLE_NORMAL
public static final String STYLE_NORMAL
Normal font style
WEIGHT_BOLD
public static final int WEIGHT_BOLD
Bold font weight
WEIGHT_NORMAL
public static final int WEIGHT_NORMAL
Normal font weight
Font
public Font(String key,
FontTriplet triplet,
FontMetrics met,
int fontSize)
Main constructor
key
- key of the fonttriplet
- the font triplet that was used to lookup this font (may be null)met
- font metricsfontSize
- font size
getAscender
public int getAscender()
Returns the font's ascender.
getCapHeight
public int getCapHeight()
Returns the font's CapHeight.
getCharWidth
public int getCharWidth(char c)
Helper method for getting the width of a unicode char
from the current fontstate.
This also performs some guessing on widths on various
versions of space that might not exists in the font.
- the width of the character
getDescender
public int getDescender()
Returns the font's Descender.
getFontName
public String getFontName()
Returns the font's name.
getFontSize
public int getFontSize()
Returns the font size
getFontTriplet
public FontTriplet getFontTriplet()
- the font triplet that selected this font
getKernValue
public int getKernValue(char ch1,
char ch2)
Returns the amount of kerning between two characters.
ch1
- first characterch2
- second character
- the distance to adjust for kerning, 0 if there's no kerning
getKerning
public Map getKerning()
Returns the font's kerning table
getWidth
public int getWidth(int charnum)
Returns the width of a character
charnum
- character to look up
getWordWidth
public int getWordWidth(String word)
Calculates the word width.
word
- text to get width for
getXHeight
public int getXHeight()
Returns the XHeight
hasChar
public boolean hasChar(char c)
Determines whether this font contains a particular character/glyph.
- True if the character is supported, Falso otherwise
hasKerning
public boolean hasKerning()
- true if the font has kerning info
mapChar
public char mapChar(char c)
Map a java character (unicode) to a font character.
Default uses CodePointMapping.
toString
public String toString()
java.lang.Object.toString()
Copyright 1999-2007 The Apache Software Foundation. All Rights Reserved.