SourceForge.net Logo
aXSL API 0.1

org.axsl.fontR
Interface FontServer


public interface FontServer

FontServer provides some basic system-wide services such as listing available fonts.

Notes to creating implementations of FontServer:


Method Summary
 boolean fontOutputFactoryAvailable(java.lang.String mime)
          Reports on the availability of FontOutputFactory instances by mime-type.
 Font[] getAllFonts(boolean freeStandingFonts, boolean systemFonts)
          Returns an array of all Font instances.
 Encoding getEncoding(java.lang.String name)
          Returns an Encoding instance for the given name.
 java.lang.String getFontFamilyForAlias(java.lang.String alias)
          Finds the font-family that is associated with a given font-family alias.
 java.lang.String[] getSystemFontFamilyList()
          Exposes the list of font families registered with the operating system.
 java.awt.Font[] getSystemFontList()
          Exposes the list of fonts registered with the operating system.
 boolean isRegisteredFont(java.lang.String fontID)
          Indicates whether a font has already been registered for use by the system.
 boolean isRegisteredFontFamily(java.lang.String name)
          Indicates whether a font-family has already been registered for use by the system.
 FontConsumer makeFontConsumer()
          Creates an implementation-specific FontConsumer instance.
 void registerFont(java.lang.String fontID, java.lang.String fontFileDescription, byte[] fontFileContents, java.lang.String metricsFileDescription, byte[] metricsFileContents, java.lang.String collectionID, java.lang.String embed, java.lang.String systemName)
          Register a font for use by the system.
 void registerFont(java.lang.String fontID, java.net.URL fontFileURL, java.net.URL metricsFileURL, java.lang.String collectionID, java.lang.String embed, java.lang.String systemName)
          Register a font for use by the system.
 void registerFontDescription(java.lang.String fontFamily, java.lang.String fontID, Encoding encoding, byte style, short weight, byte variant, byte stretch, float simulatedSmallCaps, float simulatedOblique, float simulatedBackslant, float[] simulatedStretch)
          Register a font description for use by the system.
 void registerFontFamily(java.lang.String name)
          Register a font-family for use by the system.
 void registerFontFamilyAlias(java.lang.String alias, java.lang.String realFamily)
          Add a font-family alias.
 void registerFontOutputFactory(FontOutputFactory factory)
          Registers a FontOutputFactory for use by this server.
 

Method Detail

getAllFonts

public Font[] getAllFonts(boolean freeStandingFonts,
                          boolean systemFonts)
Returns an array of all Font instances.

Parameters:
freeStandingFonts - Set to true to include free-standing fonts in the returned array.
systemFonts - Set to true to include system fonts in the returned array.
Returns:
The array of all Font instances.

getSystemFontFamilyList

public java.lang.String[] getSystemFontFamilyList()
Exposes the list of font families registered with the operating system. The purpose of this method is to provide implementations with a way to report to their users the system fonts that they could possibly register, which may be useful in helping them debug font registration failure.

Returns:
The list of font families that are registered with the operating system. (Technically it is those font families available through the JVM, which is presumed to be those that are registered with the operating system).

getSystemFontList

public java.awt.Font[] getSystemFontList()
Exposes the list of fonts registered with the operating system. The purpose of this method is to provide implementations with a way to report to their users the system fonts that they could possibly register, which may be useful in helping them debug font registration failure.

Returns:
An array of fonts that are registered with the operating system. (Technically it is those fonts available through the JVM, which is presumed to be those that are registered with the operating system).

getEncoding

public Encoding getEncoding(java.lang.String name)
Returns an Encoding instance for the given name.

Parameters:
name - The name of the Encoding instance that is sought.
Returns:
The Encoding instance for name.

registerFontOutputFactory

public void registerFontOutputFactory(FontOutputFactory factory)
                               throws FontException
Registers a FontOutputFactory for use by this server. This method can be used both to support custom FontOutput types and to override standard types. Note that if a factory was previously registered for the mime-type of the factory now being registered, the new registration overrides the previous registration. If this behavior is not desired, check the return value of fontOutputFactoryAvailable(String) before registering the new factory.

Parameters:
factory - The factory which should be registered.
Throws:
FontException - If the factory cannot be registered.

fontOutputFactoryAvailable

public boolean fontOutputFactoryAvailable(java.lang.String mime)
Reports on the availability of FontOutputFactory instances by mime-type.

Parameters:
mime - The mime-type for which a factory is sought.
Returns:
True iff a factory has already been registered for the given mime-type.

registerFontFamily

public void registerFontFamily(java.lang.String name)
                        throws FontException
Register a font-family for use by the system.

Parameters:
name - The name of the font-family (e.g. "Courier").
Throws:
FontException - If the font-family is already registered.

isRegisteredFontFamily

public boolean isRegisteredFontFamily(java.lang.String name)
Indicates whether a font-family has already been registered for use by the system.

Parameters:
name - The name of the font-family (e.g. "Courier").
Returns:
True iff the font-family is already registered.

registerFontFamilyAlias

public void registerFontFamilyAlias(java.lang.String alias,
                                    java.lang.String realFamily)
                             throws FontException
Add a font-family alias.

Parameters:
alias - The name of the font-family alias (e.g. "sans-serif").
realFamily - The name of the real font-family to which this alias should be associated (e.g. "Helvetica").
Throws:
FontException - If the font-family alias is already registered, or if realFamily is not a registered font-family.

getFontFamilyForAlias

public java.lang.String getFontFamilyForAlias(java.lang.String alias)
Finds the font-family that is associated with a given font-family alias.

Parameters:
alias - The name of the font-family alias.
Returns:
The name of the font-family to which the alias is pointed, or null if there is no font-family alias registered for alias.

registerFont

public void registerFont(java.lang.String fontID,
                         java.net.URL fontFileURL,
                         java.net.URL metricsFileURL,
                         java.lang.String collectionID,
                         java.lang.String embed,
                         java.lang.String systemName)
                  throws FontException
Register a font for use by the system.

Parameters:
fontID - A unique ID for this font (e.g. "Courier-Bold").
fontFileURL - URL to the file containing the font.
metricsFileURL - URL to the file containing the font metrics. This is null for TrueType and OpenType fonts.
collectionID - For TrueType collections, indicates which font in the collection corresponds to this font.
embed - One of "none", "all", or "subset", indicating whether this font should be embedded in output documents.
systemName - For system fonts only, this is the name that should be supplied to the operating system font registry to obtain the font from it. For other fonts, set this to null.
Throws:
FontException - If a font with this fontID is already registered.

registerFont

public void registerFont(java.lang.String fontID,
                         java.lang.String fontFileDescription,
                         byte[] fontFileContents,
                         java.lang.String metricsFileDescription,
                         byte[] metricsFileContents,
                         java.lang.String collectionID,
                         java.lang.String embed,
                         java.lang.String systemName)
                  throws FontException
Register a font for use by the system. This is an overloaded version of registerFont(String, URL, URL, String, String, String) intended for situations where a font's contents have been extracted from a document.

Parameters:
fontID - A unique ID for this font (e.g. "Courier-Bold").
fontFileDescription - A description of the font file. This is used primarily in user messages. (The overloaded method that takes URLs just uses the path of the URL for descriptive user messages).
fontFileContents - Byte array containing the font file contents.
metricsFileDescription - A description of the metrics file. This is used primarily in user messages. (The overloaded method that takes URLs just uses the path of the URL for descriptive user messages).
metricsFileContents - Byte array containing the metrics contents. This is null for TrueType and OpenType fonts.
collectionID - For TrueType collections, indicates which font in the collection corresponds to this font.
embed - One of "none", "all", or "subset", indicating whether this font should be embedded in output documents.
systemName - For system fonts only, this is the name that should be supplied to the operating system font registry to obtain the font from it. For other fonts, set this to null.
Throws:
FontException - If a font with this fontID is already registered.

isRegisteredFont

public boolean isRegisteredFont(java.lang.String fontID)
Indicates whether a font has already been registered for use by the system.

Parameters:
fontID - The unique font ID for the font (e.g. "Courier-Bold").
Returns:
True iff a font with ID of fontID is already registered.

registerFontDescription

public void registerFontDescription(java.lang.String fontFamily,
                                    java.lang.String fontID,
                                    Encoding encoding,
                                    byte style,
                                    short weight,
                                    byte variant,
                                    byte stretch,
                                    float simulatedSmallCaps,
                                    float simulatedOblique,
                                    float simulatedBackslant,
                                    float[] simulatedStretch)
                             throws FontException
Register a font description for use by the system.

Parameters:
fontFamily - The name of the font-family in which this font should be registered.
fontID - The font ID for the font that should be registered.
encoding - The encoding, if any, that should be used by this font description. Set this value to null unless you wish to override the encoding for this font.
style - One of Font.FONT_STYLE_NORMAL, Font.FONT_STYLE_ITALIC, Font.FONT_STYLE_OBLIQUE, or Font.FONT_STYLE_BACKSLANT.
weight - One of Font.FONT_WEIGHT_NORMAL, Font.FONT_WEIGHT_BOLD, Font.FONT_WEIGHT_100, Font.FONT_WEIGHT_200, Font.FONT_WEIGHT_300, Font.FONT_WEIGHT_400, Font.FONT_WEIGHT_500, Font.FONT_WEIGHT_600, Font.FONT_WEIGHT_700, Font.FONT_WEIGHT_800,or Font.FONT_WEIGHT_900.
variant - One of Font.FONT_VARIANT_NORMAL, or Font.FONT_VARIANT_SMALL_CAPS.
stretch - One of Font.FONT_STRETCH_ULTRA_CONDENSED, Font.FONT_STRETCH_EXTRA_CONDENSED, Font.FONT_STRETCH_CONDENSED, Font.FONT_STRETCH_SEMI_CONDENSED, Font.FONT_STRETCH_NORMAL, Font.FONT_STRETCH_SEMI_EXPANDED, Font.FONT_STRETCH_EXPANDED, Font.FONT_STRETCH_EXTRA_EXPANDED, or Font.FONT_STRETCH_ULTRA_EXPANDED.
simulatedSmallCaps - To prevent this font-description from being used to simulate small-caps, set this value to Float.NaN. Otherwise, set it to the percentage which should be applied to the font-size for the small caps. For example, if set to 80%, and the font-size is 12 points, the resulting small-caps will be presented at 9.6 points.
simulatedOblique - To prevent this font-description from being used to simulate oblique, set this value to Float.NaN. Otherwise, set it to the number of degrees clockwise that the font should be skewed to simulate oblique.
simulatedBackslant - To prevent this font-description from being used to simulate backslant, set this value to Float.NaN. Otherwise, set it to the number of degrees counterclockwise that the font should be skewed to simulate backslant.
simulatedStretch - Array containing percentages by which the font should be stretched horizontally for various font-stretch values. Values greater than 100 will result in wider characters. Values less than 100 will result in narrower characters. Invalid or unset amounts are indicated by the value Float.NaN. Element 0 corresponds to ultra-condensed (the narrowest value), and element 7 corresponds to ultra-expanded (the widest value). Note that there is no element for "normal", since that does not need to be simulated.
Throws:
FontException - If fontFamily or fontID are not already registered.

makeFontConsumer

public FontConsumer makeFontConsumer()
Creates an implementation-specific FontConsumer instance.

Returns:
an implementation-specific FontConsumer instance.

SourceForge.net Logo
aXSL API 0.1

This documentation was created September 6 2006 by The aXSL Group and may be freely copied. See license for details.