The aXSL Font Module



Information on this page reflects information about the current aXSL repository.

axslFont implementations provide font-related services to a client application (CA). The CA requests information, and the axslFont implementation provides it. Here are the general font-related requests that a document-processing application might have:

  • I have a font description. Please provide me with a font object.
  • I have some text. It <(should | should not) be converted for (ligatures | small-caps | old-style-figures, etc)>*. Please return the text that I should use.
  • I have some text. Please tell me how much ipd space will be needed to place this text.
  • I am ready to generate my document. Please tell me which fonts I have used, and provide the properly subsetted font information that I should embed in the document.

XSL-FO Conformance

aXSLFont is intended to provide an interface that can be used to build applications conformant to the XSL-FO standard. The following table lists items related to this conformance. Consult implementation documentation for implementation limitations or exceptions:

Standard Item XSL-FO 1.0 Citations Conformance
font-family 7.8.2 yes
font-selection-strategy 7.8.3 N/A. This is really an FO Tree issue. See "Notes on font-selection-strategy" below.
font-size 7.8.4 Yes.
font-stretch 7.8.5 Yes.
font-size-adjust 7.8.6 N/A. This is actually not a font system issue, but an FO Tree issue.
font-style 7.8.7 Yes.
font-variant 7.8.8 Yes. See also "Notes on simulated small-caps" below.
font-weight 7.8.9 Yes.


The following is an overview of the classes and interfaces that are exposed to the CA. The javadocs should also be consulted as they may contain more detailed documentation.


FontServer is mainly responsible for tracking font resources that are available to the system and making those resources available to FontConsumers. FontServer is instantiated in an implementation-specific manner, so consult the implementation documentation for details.


FontConsumer is responsible for providing FontUse instances as requested, tracking the fonts used by a document, and tracking the glyph subset used by a document. FontConsumer is instantiated in an implementation-specific manner, so consult the implementation documentation for details. Care should be taken to instantiate exactly one FontConsumer per document that is processed. Otherwise the list of fonts and font subset information will be corrupt.


FontUse is a specific Font, as used by a specific FontConsumer, with a specific encoding, from a specific registration. It is important to keep FontUse instances distinct by encoding so that the client application can handle any multiple encodings during rendering. It is important to keep FontUse instances distinct by registration, because certain methods are relative to that registration. For example, the method "nextBolderWeight()" might return a different value for the same font if it were registered as part of two different font families. FontUse provides the document-specific, encoding-specific, and registration-specific glyph metrics, encoding, and embedding information. FontUse instances are obtained from the FontConsumer "selectFont" methods.


Font provides general information about a font's metrics. Font instances are obtained from the FontUse.getFont() method.

Sample Code

Consult your implementation documentation for instructions about instantiating FontServer and FontConsumer.

Font Selection
import org.axsl.font.FontUtility;


FontConsumer consumer = getFontConsumer();
int fontSelectionStrategy = FontUtility.foFontSelectionStrategy(
        "character-by-character", true);
String[] fontFamily = FontUtility.foFontFamily(
        "Helvetica, sans-serif");
int fontStyle = FontUtility.foFontStyle("italic", true);
int fontWeight = FontUtility.foFontWeight("bold", true);
int fontVariant = FontUtility.foFontVariant("small-caps", true);
int fontStretch = FontUtility.foFontVariant("condensed", true);
// We don't care about font size for scalable fonts
int fontSize = 0;
// This will make sure an "S" can be encoded by the returned font
int aChar = "SomeString".charAt(0);
this.resolvedFont = consumer.selectFontXSL(
Use a Font instance

The javadocs are probably sufficient to comprehend the various methods in FontUse and Font. If additional code samples are needed, please make a request on the mailing list for assistance.

Notes on font-selection-strategy

It is believed that current aXSL methods are sufficient to allow an application to implement font-selection-strategy="character-by-character".

Regarding font-selection-strategy="auto", aXSL provides support only in the sense that the implementation knows that the client application has requested it. Providing support beyond this appears to be beyond the scope of aXSL's mission. The standard appears to provide the "auto" option for those implementations with a specific strategy in mind. It is believed that implementations are able to add support for other strategies within the current aXSL framework. These strategies would of course be implementation-dependent.

Notes on simulated small-caps

Simulated small-caps must be handled outside of the font system. Flagging a font-description in the font-configuration file with a simulated-font-stretch value merely does the following 1) allows that font to be selected with either normal or small-caps variant, and 2) tells the font system what percentage the user wishes to use for small-caps, if small-caps is selected. So, for font-variant="small-caps", if a true small-caps variant for the font is found, it will be selected. If not, but a simulated small-caps font is available, it will be selected. In the first case, the font system sees two different fonts with two different sets of metrics. In the second case, it sees only one font. The client application must handle the switching back and forth from one point size to another to get the correct metrics information from this one font.

Font Configuration

Many applications need a way for users to communicate information about available fonts to them. aXSL has developed a font-configuration DTD that can optionally be used for this purpose. It is quite possible to use the axslFont interfaces and use some other scheme for obtaining information about available fonts. See Font Configuration for user documentation about this DTD.

Character Set

Because aXSL interfaces use 32-bit int representations for characters, the entire 21-bit extended Unicode character set is supported. Here are some useful links regarding this issue:

Known Implementations

The known implementations of axslFont are:

Reference Applications

Reference applications contain working code that uses axslFont: