Package net.sourceforge.jeuclid.font
Class DefaultFontFactory
java.lang.Object
net.sourceforge.jeuclid.font.FontFactory
net.sourceforge.jeuclid.font.DefaultFontFactory
Concrete FontFactory implementation that does simple caching of Fonts
loaded via
Font.createFont(int, File) APIs.- Version:
- $Revision: 2907029e5fad $
-
Field Summary
Fields inherited from class net.sourceforge.jeuclid.font.FontFactory
SANSSERIF -
Method Summary
Modifier and TypeMethodDescriptionCreate a font object with specified properties.Create a font object which is able to display the requested code point.Retrieve a list of all fonts registered with this fontFactory.registerFont(int format, File fontFile) Load an external font from a file and 'register' (aka 'cache') it for future use.registerFont(int format, InputStream fontStream) Load an external font from a stream and 'register' (aka 'cache') it for future use.Methods inherited from class net.sourceforge.jeuclid.font.FontFactory
getInstance
-
Method Details
-
getFont
Create a font object with specified properties. Font name may refer to either 'built-in' or loaded externally and 'cached' font.- Specified by:
getFontin classFontFactory- Parameters:
name- font name or font family namestyle- font stylesize- font size- Returns:
- Font instance
- See Also:
-
getFont
Create a font object which is able to display the requested code point. Uses one of the list of preferred fonts is possible. If no matching font is found null is returned.- Specified by:
getFontin classFontFactory- Parameters:
preferredFonts- List of preferred fontscodepoint- code point which must be displayablestyle- font stylesize- font size- Returns:
- a valid Font instance or null if no font could be found.
-
registerFont
Load an external font from a file and 'register' (aka 'cache') it for future use.- Specified by:
registerFontin classFontFactory- Parameters:
format- font format (TTF or TYPE_1 currently supported by the platform)fontFile- file which contains the font- Returns:
- The newly created Font instance
- Throws:
FontFormatException- if font contained in the file doesn't match the specified formatIOException- in case of problem while reading the file- See Also:
-
registerFont
public Font registerFont(int format, InputStream fontStream) throws IOException, FontFormatException Load an external font from a stream and 'register' (aka 'cache') it for future use.- Specified by:
registerFontin classFontFactory- Parameters:
format- font format (TTF or TYPE_1 currently supported by the platform)fontStream- file which contains the font- Returns:
- The newly created Font instance
- Throws:
FontFormatException- if font contained in the stream doesn't match the specified formatIOException- in case of problem while reading the stream- See Also:
-
listFontNames
Retrieve a list of all fonts registered with this fontFactory.- Specified by:
listFontNamesin classFontFactory- Returns:
- A set of recognized font names
-