Subversion Repositories cheapmusic

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
98 - 1
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><title>SetFont</title><link rel="stylesheet" type="text/css" href="phplotdoc.css" /><meta name="generator" content="DocBook XSL Stylesheets V1.78.1" /><link rel="home" href="index.html" title="PHPlot Reference Manual" /><link rel="up" href="reference.html" title="PHPlot Function Reference" /><link rel="prev" href="SetFileFormat.html" title="SetFileFormat" /><link rel="next" href="SetFontGD.html" title="SetFontGD" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">SetFont</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="SetFileFormat.html">Prev</a> </td><th width="60%" align="center">PHPlot Function Reference</th><td width="20%" align="right"> <a accesskey="n" href="SetFontGD.html">Next</a></td></tr></table><hr /></div><div class="refentry"><a id="SetFont"></a><div class="titlepage"></div><div class="refnamediv"><h2><span class="refentrytitle">SetFont</span></h2><p>SetFont &#8212; Select which font to use for a plot element</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">$plot-&gt;SetFont(<em class="parameter"><code>$elem</code></em>, <em class="parameter"><code>$font</code></em>, [<span class="optional"><em class="parameter"><code>$size</code></em></span>], [<span class="optional"><em class="parameter"><code>$line_spacing</code></em></span>])</pre></div><div class="refsect1"><a id="idp1378100292"></a><h2>Description</h2><p>
3
<code class="function">SetFont</code> selects the font and size to use for one plot
4
element (for example, the title). This functions works differently depending
5
on whether or not you are using TrueType fonts. If using TrueType fonts,
6
call either <a class="xref" href="SetDefaultTTFont.html" title="SetDefaultTTFont"><span class="refentrytitle">SetDefaultTTFont</span></a> or <a class="xref" href="SetUseTTF.html" title="SetUseTTF"><span class="refentrytitle">SetUseTTF</span></a>
7
before calling SetFont.
8
    </p></div><div class="refsect1"><a id="idp1378102172"></a><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>$elem</code></em></span></dt><dd><p>
9
The name of the element to change the font for. Use one of the following
10
strings: 'title', 'legend', 'generic', 'x_label', 'y_label', 'x_title',
11
or 'y_title'.
12
          </p></dd><dt><span class="term"><em class="replaceable"><code>$font</code></em></span></dt><dd><p>
13
Selects the font to use.  For TrueType fonts,
14
this is either the full pathname of a TrueType font filename,
15
or the filename (without path) if the font file is either located in the
16
default TrueType font directory set with <a class="xref" href="SetTTFPath.html" title="SetTTFPath"><span class="refentrytitle">SetTTFPath</span></a>
17
or can be found by GD using its default search rules.
18
An empty string or NULL can be specified to use the default TrueType font.
19
          </p><p>
20
For built-in GD fonts, this is a number between 1 and 5 which selects one
21
of the built-in GD fonts.  Font 1 is the smallest, and font 5 is the
22
largest.
23
          </p></dd><dt><span class="term"><em class="replaceable"><code>$size</code></em></span></dt><dd><p>
24
The font size in points for TrueType fonts. Ignored for built-in GD fonts.
25
If not specified, a default value of 12 is used.
26
See note below.
27
          </p></dd><dt><span class="term"><em class="replaceable"><code>$line_spacing</code></em></span></dt><dd><p>
28
Optional line spacing adjustment for this text element.
29
This is interpreted differently for GD and TrueType text.
30
See <a class="xref" href="SetLineSpacing.html" title="SetLineSpacing"><span class="refentrytitle">SetLineSpacing</span></a> for details.
31
If not specified, the value set by <a class="xref" href="SetLineSpacing.html" title="SetLineSpacing"><span class="refentrytitle">SetLineSpacing</span></a> is used.
32
          </p></dd></dl></div></div><div class="refsect1"><a id="idp1378108460"></a><h2>Notes</h2><p>
33
See also <a class="xref" href="conc-text.html" title="3.8. Text Fonts">Section 3.8, &#8220;Text Fonts&#8221;</a>.
34
    </p><p>
35
The <code class="literal">generic</code> font is used for pie chart segment labels,
36
message image text (see <a class="xref" href="DrawMessage.html" title="DrawMessage"><span class="refentrytitle">DrawMessage</span></a>), error image text,
37
and can be used from callbacks (see <a class="xref" href="callbacks.html#callbacks-drawing" title="4.4.5. Using Callbacks to Annotate Plots">Section 4.4.5, &#8220;Using Callbacks to Annotate Plots&#8221;</a>).
38
However, changing this font has no effect on error image text, because the
39
PHPlot error handler resets the font to the default before displaying the error.
40
    </p><p>
41
When using built-in GD fonts, the default fonts are shown in the following
42
table, where font 1 is the smallest font and font 5 is the biggest font.
43
      </p><div class="informaltable"><table summary="Default built-in fonts" border="1"><colgroup><col class="c1" /><col class="c2" /></colgroup><thead><tr><th>Element</th><th>Default Built-in Font</th></tr></thead><tbody><tr><td>generic</td><td>2</td></tr><tr><td>legend</td><td>2</td></tr><tr><td>title</td><td>5</td></tr><tr><td>x_label</td><td>1</td></tr><tr><td>y_label</td><td>1</td></tr><tr><td>x_title</td><td>3</td></tr><tr><td>y_title</td><td>3</td></tr></tbody></table></div><p>
44
    </p><p>
45
When using TrueType fonts, the default font sizes are shown in the following
46
table. Use <a class="xref" href="SetDefaultTTFont.html" title="SetDefaultTTFont"><span class="refentrytitle">SetDefaultTTFont</span></a> to set the default TrueType font.
47
      </p><div class="informaltable"><table summary="Default TrueType font sizes" border="1"><colgroup><col class="c1" /><col class="c2" /></colgroup><thead><tr><th>Element</th><th>Default TrueType Font Size (points)</th></tr></thead><tbody><tr><td>generic</td><td>8</td></tr><tr><td>legend</td><td>8</td></tr><tr><td>title</td><td>14</td></tr><tr><td>x_label</td><td>6</td></tr><tr><td>y_label</td><td>6</td></tr><tr><td>x_title</td><td>10</td></tr><tr><td>y_title</td><td>10</td></tr></tbody></table></div><p>
48
    </p><p>
49
Simultaneous use of GD and TrueType font text is allowed in the same plot.
50
To mix font types, use
51
<a class="xref" href="SetFontGD.html" title="SetFontGD"><span class="refentrytitle">SetFontGD</span></a> and <a class="xref" href="SetFontTTF.html" title="SetFontTTF"><span class="refentrytitle">SetFontTTF</span></a> to
52
specify the font and font type of an element, instead of using SetFont.
53
    </p><p>
54
SetFont implicitly uses the default font type.
55
When a PHPlot object instance is created, the default font type is GD.
56
Using <a class="xref" href="SetUseTTF.html" title="SetUseTTF"><span class="refentrytitle">SetUseTTF</span></a>(True), or selecting a default font with
57
<a class="xref" href="SetDefaultTTFont.html" title="SetDefaultTTFont"><span class="refentrytitle">SetDefaultTTFont</span></a>, sets the default font type to TrueType.
58
Using <a class="xref" href="SetUseTTF.html" title="SetUseTTF"><span class="refentrytitle">SetUseTTF</span></a>(False) sets the default font type back
59
to GD. Either of these three operations will also reset all current text
60
elements to the defaults indicated above, negating any prior SetFont,
61
SetFontGD, or SetFontTTF calls. Note that <a class="xref" href="SetTTFPath.html" title="SetTTFPath"><span class="refentrytitle">SetTTFPath</span></a>,
62
which selects the directory where TrueType fonts can be found, does not
63
affect the default font type nor does it change any existing font
64
selections.
65
    </p><p>
66
Although PHP documents the TrueType font sizes as being given in points
67
(where there are about 72 points per inch), it doesn't know the output
68
device resolution, so it just assumes a fixed resolution of 72 pixels per
69
inch.  As a result, the TrueType font size argument actually measures the
70
approximate font height in pixels. For example, if you use $size=18,
71
the text will be about 18 pixels high in the user's browser. The actual
72
size seen by the user will depend on the resolution of the user's display.
73
On a 72 pixels per inch display, the text size will be 18 points, but at
74
96 pixels per inch it would only be 13.5 points.
75
    </p></div><div class="refsect1"><a id="idp1378129836"></a><h2>History</h2><p>
76
Starting with PHPlot-5.1.3, TrueType fonts are validated by trying to
77
use the font with a non-drawing operation, rather than by seeing if the
78
font file exists.
79
See <a class="xref" href="conc-text.html#conc-text-fonts" title="3.8.3. TrueType Font Selection">Section 3.8.3, &#8220;TrueType Font Selection&#8221;</a> for more information.
80
    </p><p>
81
Simultaneous use of GD and TrueType font text was added at PHPlot-5.0.6.
82
Through PHPlot-5.0.5, all text in a plot used GD fonts, or all text used
83
TrueType fonts.
84
    </p><p>
85
The line_spacing parameter was added at PHPlot-5.0.6 to allow finer
86
control over the line spacing for different elements. Through PHPlot-5.0.5,
87
the same line spacing was used for all text elements.
88
    </p><p>
89
The described behavior for finding TrueType font files (first using the
90
name as given, then looking in the SetTTFPath font directory) was
91
implemented in PHPlot-5.0rc3.
92
    </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="SetFileFormat.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="SetFontGD.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">SetFileFormat </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> SetFontGD</td></tr></table></div></body></html>