fop 0.93

org.apache.fop.fonts
Class Font

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

public class Font
extends java.lang.Object

This class holds font state information and provides access to the font metrics.


Field Summary
static int BOLD
          Bold font weight
static FontTriplet DEFAULT_FONT
          Default fallback key
static int NORMAL
          Normal font weight
 
Constructor Summary
Font(java.lang.String key, FontTriplet triplet, FontMetrics met, int fontSize)
          Main constructor
 
Method Summary
 int getAscender()
          Returns the font's ascender.
 int getCapHeight()
          Returns the font's CapHeight.
 int getCharWidth(char c)
          Helper method for getting the width of a unicode char from the current fontstate.
 int getDescender()
          Returns the font's Descender.
 java.lang.String getFontName()
          Returns the font's name.
 int getFontSize()
          Returns the font size
 FontTriplet getFontTriplet()
           
 java.util.Map getKerning()
          Returns the font's kerning table
 int getKernValue(char ch1, char ch2)
          Returns the amount of kerning between two characters.
 int getWidth(int charnum)
          Returns the width of a character
 int getWordWidth(java.lang.String word)
          Calculates the word width.
 int getXHeight()
          Returns the XHeight
 boolean hasChar(char c)
          Determines whether this font contains a particular character/glyph.
 boolean hasKerning()
           
 char mapChar(char c)
          Map a java character (unicode) to a font character.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_FONT

public static final FontTriplet DEFAULT_FONT
Default fallback key


NORMAL

public static final int NORMAL
Normal font weight

See Also:
Constant Field Values

BOLD

public static final int BOLD
Bold font weight

See Also:
Constant Field Values
Constructor Detail

Font

public Font(java.lang.String key,
            FontTriplet triplet,
            FontMetrics met,
            int fontSize)
Main constructor

Parameters:
key - key of the font
triplet - the font triplet that was used to lookup this font (may be null)
met - font metrics
fontSize - font size
Method Detail

getAscender

public int getAscender()
Returns the font's ascender.

Returns:
the ascender

getCapHeight

public int getCapHeight()
Returns the font's CapHeight.

Returns:
the capital height

getDescender

public int getDescender()
Returns the font's Descender.

Returns:
the descender

getFontName

public java.lang.String getFontName()
Returns the font's name.

Returns:
the font name

getFontTriplet

public FontTriplet getFontTriplet()
Returns:
the font triplet that selected this font

getFontSize

public int getFontSize()
Returns the font size

Returns:
the font size

getXHeight

public int getXHeight()
Returns the XHeight

Returns:
the XHeight

hasKerning

public boolean hasKerning()
Returns:
true if the font has kerning info

getKerning

public java.util.Map getKerning()
Returns the font's kerning table

Returns:
the kerning table

getKernValue

public int getKernValue(char ch1,
                        char ch2)
Returns the amount of kerning between two characters.

Parameters:
ch1 - first character
ch2 - second character
Returns:
the distance to adjust for kerning, 0 if there's no kerning

getWidth

public int getWidth(int charnum)
Returns the width of a character

Parameters:
charnum - character to look up
Returns:
width of the character

mapChar

public char mapChar(char c)
Map a java character (unicode) to a font character. Default uses CodePointMapping.

Parameters:
c - character to map
Returns:
the mapped character

hasChar

public boolean hasChar(char c)
Determines whether this font contains a particular character/glyph.

Parameters:
c - character to check
Returns:
True if the character is supported, Falso otherwise

toString

public java.lang.String toString()
See Also:
Object.toString()

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.

Parameters:
c - character to inspect
Returns:
the width of the character

getWordWidth

public int getWordWidth(java.lang.String word)
Calculates the word width.

Parameters:
word - text to get width for
Returns:
the width of the text

fop 0.93

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