de.matthiasmann.twl.renderer
Interface FontMapper

All Superinterfaces:
Resource

public interface FontMapper
extends Resource

A font mapper which tries to retrieve the closest font for the specified parameters


Field Summary
static int REGISTER_WEAK
          Register this font is as a weak font.
static int STYLE_BOLD
           
static int STYLE_ITALIC
           
static int STYLE_NORMAL
           
 
Method Summary
 Font getFont(StringList fontFamilies, int fontSize, int style, StateSelect select, FontParameter... fontParams)
          Retrive the cloest font for the given parameters
 boolean registerFont(java.lang.String fontFamily, int style, java.net.URL url)
          Registers a font file
 boolean registerFont(java.lang.String fontFamily, java.net.URL url)
          Registers a font file and determines the style from the font itself.
 
Methods inherited from interface de.matthiasmann.twl.renderer.Resource
destroy
 

Field Detail

STYLE_NORMAL

static final int STYLE_NORMAL
See Also:
Constant Field Values

STYLE_BOLD

static final int STYLE_BOLD
See Also:
Constant Field Values

STYLE_ITALIC

static final int STYLE_ITALIC
See Also:
Constant Field Values

REGISTER_WEAK

static final int REGISTER_WEAK
Register this font is as a weak font.

If a font is already registered for the specified fontFamily and style then this registration is ignored.

If a non weak font is registered for the specified fontFamily and style then an existing weak font is replaced.

See Also:
Constant Field Values
Method Detail

getFont

Font getFont(StringList fontFamilies,
             int fontSize,
             int style,
             StateSelect select,
             FontParameter... fontParams)
Retrive the cloest font for the given parameters

Parameters:
fontFamilies - a list of family names with decreasing piority
fontSize - the desired font size in pixels
style - a combination of the STYLE_* flags
select - the StateSelect object
fontParams - the font parameters - must be exactly 1 more then the number of expressions in the select object
Returns:
the Font object or null if the font could not be found
Throws:
java.lang.NullPointerException - when one of the parameters is null
java.lang.IllegalArgumentException - when the number of font parameters doesn't match the number of state expressions

registerFont

boolean registerFont(java.lang.String fontFamily,
                     int style,
                     java.net.URL url)
Registers a font file

Parameters:
fontFamily - the font family for which to register the font
style - a combination of the STYLE_* and REGISTER_* flags
url - the URL for the font file
Returns:
true if the specified font could be registered

registerFont

boolean registerFont(java.lang.String fontFamily,
                     java.net.URL url)
                     throws java.io.IOException
Registers a font file and determines the style from the font itself.

Parameters:
fontFamily - the font family for which to register the font
url - the URL for the font file
Returns:
true if the specified font could be registered
Throws:
java.io.IOException - when the font could not be parsed