1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
---|
2 | <html>
|
---|
3 | <head>
|
---|
4 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
5 | <title>SetFont</title>
|
---|
6 | <link type="text/css" rel="stylesheet" href="../fpdf.css">
|
---|
7 | </head>
|
---|
8 | <body>
|
---|
9 | <h1>SetFont</h1>
|
---|
10 | <code>SetFont(<b>string</b> family [, <b>string</b> style [, <b>float</b> size]])</code>
|
---|
11 | <h2>Description</h2>
|
---|
12 | Sets the font used to print character strings. It is mandatory to call this method
|
---|
13 | at least once before printing text or the resulting document would not be valid.
|
---|
14 | <br>
|
---|
15 | The font can be either a standard one or a font added via the AddFont() method. Standard fonts
|
---|
16 | use Windows encoding cp1252 (Western Europe).
|
---|
17 | <br>
|
---|
18 | The method can be called before the first page is created and the font is retained from page
|
---|
19 | to page.
|
---|
20 | <br>
|
---|
21 | If you just wish to change the current font size, it is simpler to call SetFontSize().
|
---|
22 | <br>
|
---|
23 | <br>
|
---|
24 | <strong>Note:</strong> the font metric files must be accessible. They are searched successively in:
|
---|
25 | <ul>
|
---|
26 | <li>The directory defined by the <code>FPDF_FONTPATH</code> constant (if this constant is defined)</li>
|
---|
27 | <li>The <code>font</code> directory located in the directory containing <code>fpdf.php</code> (if it exists)</li>
|
---|
28 | <li>The directories accessible through <code>include()</code></li>
|
---|
29 | </ul>
|
---|
30 | Example defining <code>FPDF_FONTPATH</code> (note the mandatory trailing slash):
|
---|
31 | <div class="doc-source">
|
---|
32 | <pre><code>define('FPDF_FONTPATH','/home/www/font/');
|
---|
33 | require('fpdf.php');</code></pre>
|
---|
34 | </div>
|
---|
35 | If the file corresponding to the requested font is not found, the error "Could not include
|
---|
36 | font metric file" is issued.
|
---|
37 | <h2>Parameters</h2>
|
---|
38 | <dl class="param">
|
---|
39 | <dt><code>family</code></dt>
|
---|
40 | <dd>
|
---|
41 | Family font. It can be either a name defined by AddFont() or one of the standard families (case
|
---|
42 | insensitive):
|
---|
43 | <ul>
|
---|
44 | <li><code>Courier</code> (fixed-width)</li>
|
---|
45 | <li><code>Helvetica</code> or <code>Arial</code> (synonymous; sans serif)</li>
|
---|
46 | <li><code>Times</code> (serif)</li>
|
---|
47 | <li><code>Symbol</code> (symbolic)</li>
|
---|
48 | <li><code>ZapfDingbats</code> (symbolic)</li>
|
---|
49 | </ul>
|
---|
50 | It is also possible to pass an empty string. In that case, the current family is retained.
|
---|
51 | </dd>
|
---|
52 | <dt><code>style</code></dt>
|
---|
53 | <dd>
|
---|
54 | Font style. Possible values are (case insensitive):
|
---|
55 | <ul>
|
---|
56 | <li>empty string: regular</li>
|
---|
57 | <li><code>B</code>: bold</li>
|
---|
58 | <li><code>I</code>: italic</li>
|
---|
59 | <li><code>U</code>: underline</li>
|
---|
60 | </ul>
|
---|
61 | or any combination. The default value is regular.
|
---|
62 | Bold and italic styles do not apply to <code>Symbol</code> and <code>ZapfDingbats</code>.
|
---|
63 | </dd>
|
---|
64 | <dt><code>size</code></dt>
|
---|
65 | <dd>
|
---|
66 | Font size in points.
|
---|
67 | <br>
|
---|
68 | The default value is the current size. If no size has been specified since the beginning of
|
---|
69 | the document, the value taken is 12.
|
---|
70 | </dd>
|
---|
71 | </dl>
|
---|
72 | <h2>Example</h2>
|
---|
73 | <div class="doc-source">
|
---|
74 | <pre><code>//Times regular 12
|
---|
75 | $pdf->SetFont('Times');
|
---|
76 | //Arial bold 14
|
---|
77 | $pdf->SetFont('Arial','B',14);
|
---|
78 | //Removes bold
|
---|
79 | $pdf->SetFont('');
|
---|
80 | //Times bold, italic and underlined 14
|
---|
81 | $pdf->SetFont('Times','BIU');</code></pre>
|
---|
82 | </div>
|
---|
83 | <h2>See also</h2>
|
---|
84 | <a href="addfont.htm">AddFont()</a>,
|
---|
85 | <a href="setfontsize.htm">SetFontSize()</a>,
|
---|
86 | <a href="cell.htm">Cell()</a>,
|
---|
87 | <a href="multicell.htm">MultiCell()</a>,
|
---|
88 | <a href="write.htm">Write()</a>.
|
---|
89 | <hr style="margin-top:1.5em">
|
---|
90 | <div style="text-align:center"><a href="index.htm">Index</a></div>
|
---|
91 | </body>
|
---|
92 | </html>
|
---|