Table of Contents
Before reading this chapter please make sure that your installation supports TTF fonts if you intend to use them (See Necessary system requirements for the library). The rest of this chapter assumes that a working installation with TTF fonts is available when needed.
It is highly recommended to create a setup where TTF fonts work since the visual quality is significantly better than for the built-in bitmap fonts. In addition the bitmap fonts are restricted to only display plain 7-bit ASCII characters which means that no accented characters can be displayed, for example the Scandinavian characters "åäö".
All files in the library are encoded in utf-8.
The library supports two fundamental types of fonts.
There are three built in bitmap fonts. They are available as font
FF_FONT2. The advantage with bitmap fonts is that they
are always available in all installations of GD. However, bitmap fonts
only supports 7-bit ASCII so if you need to display any character from
the extended character set it is not possible to use bitmap fonts. The
available sizes of the bitmap fonts are also limited, the three
available size corresponds to the three families where
FF_FONT0 is the smallest and
largest available bitmap font.
Bitmap fonts also has a more "rugged" look since they do not use anti-aliasing.
Example: The following script lines shows a typical use of bit map font specified for the title of a graph
1 2 3 4 5 6
$graph = new Graph(....); // Adjust the title to use the largest built-in bitmap font in bold face $graph->title->SetFont(FF_FONT2,FS_BOLD);
The remainder of this chapter will describe this in more details.
TTF Fonts (True Type Fonts)
True Type Fonts (TTF) give a much better visual quality of the text. They are available in all sizes and there are many more font family to choose from. All font family specification apart from the three bitmap fonts are TTF fonts. In order to use these fonts the installation must be configured in the right way which is described in Necessary system requirements for the library. It is necessary to use TTF fonts in order to display extended character sets (outside the traditional 7-bit ASCII). TTF fonts must also be used when inserting unicode entities as described in Inserting Unicode entities
In order to be able to use TTF fonts it is necessary to check if the installations supports this. See Necessary system requirements for the library
Example: The following script lines shows a typical use of the Arial TTF fonts for the title of a graph
1 2 3 4 5 6
$graph = new Graph(....); // Adjust the title to use 14pt Arial bold face $graph->title->SetFont(FF_ARIAL,FS_BOLD,14);