Fonts in XFree86 : New font backends
Previous: Internationalisation of scalable font backends.
Next: Fonts in XFree86

4. New font backends

4.1. New TrueType backends

This version of XFree86 comes with two TrueType backends, known as `freetype' (formerly `xfsft') and `X-TrueType' (`X-TT' for short). Those two backends are incompatible, in that only one can be used at any one time. Users are invited to chose whichever backend they find more useful and stick to it.

The `freetype' backend resides in the module `freetype'. Before using it, please check that the `Module' section of your `XF86Config' file contains a line that reads

Load "freetype"

The `X-TrueType' backend resides in module `xtt'. In order to use it, replace the line in your `XF86Config' file that loads the `freetype' module with a line reading

Load "xtt"

Both TrueType backends delay glyph rasterisation to the time at which a glyph is first used. For this reason, they only provide an approximate value for the `average width' font property. Users are warned not to rely on the average width of a font having an accurate value.

Both backends also support an optimisation for character-cell fonts (fonts with all glyph metrics equal, or terminal fonts). A font with an XLFD specifying a character-cell spacing `c', as in

-misc-mincho-medium-r-normal--0-0-0-0-c-0-jisx0208.1990-0
will not rasterise glyphs at metrics computation time, but instead trust the font really to be a character-cell font. Users are encouraged to make use of this optimisation when useful, but be warned that not all monospaced fonts are character-cell fonts.

4.1.1. The `freetype' TrueType backend

The `freetype' backend (formerly `xfsft') is a backend based on the FreeType library (see www.freetype.org) with support for the `fontenc' style of internationalisation (see The fontenc layer). This backend supports TrueType Font files (*.ttf) and TrueType Collections (*.ttc).

In order to access the faces in a TrueType Collection file, the face number must be specified in the fonts.dir file before the filename within colons. For example,

:2:mincho.ttc -misc-mincho-medium-r-normal--0-0-0-0-c-0-jisx0208.1990-0
refers to face 2 in the `mincho.ttc' TrueType Collection file.

4.1.2. The `X-TrueType' TrueType backend

The `X-TrueType' backend is another backend based on the FreeType library. X-TrueType doesn't use the `fontenc' layer for managing font encodings, but instead uses its own database of encodings. However, X-TrueType includes a large number of encodings, and any encoding you need is likely to be present in X-TrueType.

X-TrueType extends the `fonts.dir' syntax with a number of options, known as `TTCap'. A `TTCap' entry follows the general syntax

:option=value:
and should be specified before the filename.

The most useful TTCap option is used to specify the face number to use with TTCs; it carries the name `fn'. This means that face 2 of font file `mincho.ttc' is specified using:

:fn=2:mincho.ttc -misc-mincho-medium-r-normal--0-0-0-0-c-0-jisx0208.1990-0
More information on the TTCap syntax, and on X-TrueType in general, may be found on
http://hawk.ise.chuo-u.ac.jp/student/person/tshiozak/x-tt/index-eng.html

4.2. Support for CID-keyed fonts

The CID-keyed font format was designed by Adobe Systems for fonts with large character sets. It is described in the Adobe Technical Notes nr. 5092, "Overview of the CID-Keyed Font Technology," nr. 5014, "CMap and CIDFont File Format Specification," and others, available from

http://partners.adobe.com/supportservice/devrelations/typeforum/cidfonts.html

Sample CID-keyed fonts can be found at:

ftp://ftp.oreilly.com/pub/examples/nutshell/cjkv/adobe/
Support for CID-keyed fonts in XFree86 is controlled by the two switches `BuildCID' and BuildCIDFonts. Make sure that those switches are turned on (in the directory xc/config/cf) when XFree86 is built. By default, they should be set to YES, unless you are building XFree86 for a small memory footprint, in which case they should be set to NO.

The CID-keyed font backend does not use the `fontenc' layer, but instead uses the standard `CMap' method of recoding CID-keyed fonts.

4.2.1. Using CID-keyed fonts

As shown in the sample install file /usr/X11R6/lib/X11/XF86Config.eg, the font directory CID should be specified as part of the XFree86 font path:

FontPath "/usr/X11R6/lib/X11/fonts/CID/"
in the `XF86Config' file. When the CID font directory is on the font path it must contain at least the empty files fonts.dir and fonts.scale. Sample `fonts.dir' and `fonts.scale' files, with 0 entries, are installed by default.

A sample CID-keyed font is provided in the file:

test/xsuite/xtest/CID
The test directory was given the same name as the CID font directory, because it shows how a CID-keyed font should be installed. It contains a number of subdirectories, and any CID font directory should have the same directory structure.

When installing CID-keyed fonts, the empty fonts.scale and fonts.dir files in the directory:

xc/fonts/scaled/CID
should be replaced by fonts.scale and fonts.dir files with a number of entries of the form:
1

Adobe-Korea1/Munhwa-Regular--Adobe-Korea1-0.cid \

-adobe-munhwa-medium-r-normal--0-0-0-0-p-0-adobe.korea1-0

(the font file name and the XLFD name should be on the same line). Note that the first column does not specify an actual filename; instead, it specifies the PostScript name of the CID-keyed font, followed by the extension `.cid'. The actual names of the files used will be derived from this PostScript name.

CID-keyed fonts are divided in groups by character collection. For example, the Korean font:

Munhwa-Regular--Adobe-Korea1-0
is in a subdirectory `Adobe-Korea1'.

The PostScript name of a CID-keyed font consists of two parts, the CIDFontName and the CMapName, separated by two dashes. For instance, in the case of the font name

Munhwa-Regular--Adobe-Korea1-0
the CIDFontName is `Munhwa-Regular' while the CMapName is `Adobe-Korea1'.

Each CID-keyed font consist of a CIDFont file and one or more CMap files. The CIDFont file contains the description of each character in a font. It is stored in the subdirectory CIDFont of the Adobe-Korea1 directory. The directory structure looks as following:

CID/Adobe-Korea1/CIDFont/Munhwa-Regular

CID/Adobe-Korea1/CMap/Adobe-Korea1-0

CID/Adobe-Korea1/AFM/Munhwa-Regular.afm

CID/Adobe-Korea1/CFM

CID/fonts.dir

CID/fonts.scale

The file `Munhwa-Regular.afm' is an Adobe Font Metric File (AFM). The directory `CFM' will be used for summaries of that font metric file, which will be computed later.

When the CID-keyed files are installed you can run the utility

/usr/X11R6/bin/mkcfm
to create the summaries of font metric file (*.cfm), and to put them in appropriate subdirectories. By default, the program works on the directory:
/usr/X11R6/lib/X11/fonts/CID
A different directory can be specified on the command line of `mkcfm.'

`mkcfm' should be run as root, as it needs to write its output to a system directory. If the program determines that it cannot write in the designated `CFM' subdirectories, it will display a message, and switch to current directory.

Unless `mkcfm' is run, opening large CID-keyed fonts will take a significant amount of time. `mkcfm' should be run again whenever a change is made to any of the CID-keyed fonts, or when the CID-keyed fonts are copied to a machine with a different architecture.

4.2.2. Limitations

The current version of the CID-keyed fonts backend only supports the CMaps used for horizontal text (e.g. the CMap `KSC-EUC-H' will be used, but not `KSC-EUC-V'). This limitation is due to the fact that the core X11 protocol only provides support for horizontal writing.


Fonts in XFree86 : New font backends
Previous: Internationalisation of scalable font backends.
Next: Fonts in XFree86