8.6. Adding custom TTF fonts
Prev | Chapter 8. Text and font handling | Next

## 8.6. Adding custom TTF fonts

In addition to the predefined fonts it is possible to easily use up to three custom fonts. This is done by first specifying the name of the font file that should be used and then specifying the font family as either `FF_USERFONT1`, `FF_USERFONT2` or `FF_USERFONT3`. A new font is installed by calling one or more of the methods

- `Graph::SetUserFont1($aNormal,$aBold,$aItalic,$aBoldIt)` (or the synonym `SetUserFont()` )

- `Graph::SetUserFont2($aNormal,$aBold,$aItalic,$aBoldIt)`

- `Graph::SetUserFont3($aNormal,$aBold,$aItalic,$aBoldIt)`

The argument to these methods should be the full font file name (including full path) for the normal, bold, italic and/or bolditalic variant of the font family. All arguments apart from "`$aNormal`" are optional.

An example on how this can be used to use a special font for the title of a graph is shown in Example 8.1

Example 8.1. Specifying and installing a user specified font

    1
    2
    3
    4
    5
    6
    7

    <?php
    // ...
    $graph->SetUserFont('/usr/share/fonts/ttf/digital.ttf');
    $graph->title->SetFont(FF_USERFONT,FS_NORMAL,12);
    $graph->title->Set('Test title '.$pi);
    // ...
    ?>

Prev | Up | Next
8.5. Formatting text paragraphs | Home | 8.7. Inserting Unicode entities