SetFontTTF
Prev | PHPlot Function Reference | Next

## SetFontTTF

SetFontTTF — Select a TrueType font to use for a plot element

## Synopsis

    $plot->SetFontTTF($elem, $font, [$size], [$line_spacing])

## Description

`SetFontTTF` selects a TrueType font and size to use for one plot element (for example, the title). This function supplements SetFont, which selects a GD or TTF font depending on the currently selected font type. SetFontTTF always selects a TrueType font, even if TrueType fonts are not the default font type.

## Parameters

`$elem`

  The name of the element to change the font for. Use one of the following strings: 'title', 'legend', 'generic', 'x_label', 'y_label', 'x_title', or 'y_title'.

`$font`

  Selects the TrueType font to use. This is either the full pathname of a TrueType font filename, or the filename (without path) if the font file is either located in the default TrueType font directory set with SetTTFPath or can be found by GD using its default search rules. See Section 3.8.3, “TrueType Font Selection” for more information. An empty string or NULL can be specified to use the default TrueType font.

`$size`

  The TrueType font size in points. If not specified, a default value of 12 is used.

`$line_spacing`

  Optional line spacing adjustment for this text element. For TrueType text, this is an adjustment factor for the built-in font spacing. See SetLineSpacing for details.

## Notes

See Section 3.8, “Text Fonts”, SetFont for more information about fonts, and SetLineSpacing for more information about line spacing.

The `generic` font is used for pie chart segment labels, message image text (see DrawMessage), error image text, and can be used from callbacks (see Section 4.4.5, “Using Callbacks to Annotate Plots”). However, changing this font has no effect on error image text, because the PHPlot error handler resets the font to the default before displaying the error.

Use SetUseTTF (or SetDefaultTTFont, which calls it) to set the default font type. Use SetFont to specify the font to use for an element using the default font type. Use SetFontGD and SetFontTTF to specify the font of an element using the specific type of font.

## History

Starting with PHPlot-5.1.3, TrueType fonts are validated by trying to use the font with a non-drawing operation, rather than by seeing if the font file exists. See Section 3.8.3, “TrueType Font Selection” for more information.

This function was added at PHPlot-5.0.6, along with SetFontGD, to allow mixing GD and TrueType fonts in the same graph.

Prev | Up | Next
SetFontGD | Home | SetGridColor