[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.9.17 Using a Custom Font

This section describes how to use a custom font within Crystal Space.

Crystal Space has a plugin that specifies the font server to use. The font server that almost all applications use is the default font server (crystalspace.font.server.default).

The other 2 servers are the freetype2 server and the font multiplexor. The font multiplexor just allows multiple font servers to be searched for the specified font. The freetype2 font server allows fonts to be created on the fly from fonts (like TrueType fonts) located on the user's machine.

This HOWTO document does not address using the freetype2 server with the assumption that most programs will not want to depend on the font existing on all the potential targeted platforms.

Standard Fonts

Every font server is expected to return a font given the following strings:

The default font server has these 4 fonts built in. They are as follows:

To use these fonts simply use the LoadFont method and pass the font desired.

 
Font = G2D->GetFontServer()->LoadFont(CSFONT_LARGE);

Loadable Fonts

The default font server will also look for a file in the virtual file system with the name specified. The file must be in the "csf" font format. This format is pretty simple binary format that supports individual characters with different widths and optionally an alpha component to provide anti-aliasing.

To specify an alternate font simply use the LoadFont method with the file name such as:

 
Font = G2D->GetFontServer()->LoadFont("/lib/fontshow/lucida36.csf");

Creating New Loadable Fonts

The easiest way to create a loadable font is to use the csfontutil which runs on Windows platforms and converts a true type font to the CSF format.

This program can be downloaded at:

http://ohrthguy.freeshell.org/tools/csfontutil.htm

Once the CSF file is created it can be included in the application no matter what platforms are targeted. The base font does not have to be on that system.

Using Anti-Aliased Fonts

When a font is created using the csfontutil program it creates it with anti-aliasing information. This information is currently only used by the OpenGL renderer. The software and other renderers do not check for the "alpha map" associated with the font and so do not blend the edges of the fonts with the background.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated using texi2html