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


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


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.



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'. (The 'generic' font is currently used for pie chart percentage labels and error message images.)


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.2, “TrueType Font Selection” for more information. An empty string or NULL can be specified to use the default TrueType font.


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


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.


See SetFont for more information about fonts. See SetLineSpacing for more information about line spacing.

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.


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.2, “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.