Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 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=UTF-8">
|
| 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 at least once before printing text.
|
| 13 | <br>
|
| 14 | <br>
|
| 15 | The font can be either a standard one or a font added by the AddFont() method. Standard fonts
|
| 16 | use the Windows encoding cp1252 (Western Europe).
|
| 17 | <br>
|
| 18 | <br>
|
| 19 | The method can be called before the first page is created and the font is kept from page to page.
|
| 20 | <br>
|
| 21 | <br>
|
| 22 | If you just wish to change the current font size, it is simpler to call SetFontSize().
|
| 23 | <h2>Parameters</h2>
|
| 24 | <dl class="param">
|
| 25 | <dt><code>family</code></dt>
|
| 26 | <dd>
|
| 27 | Family font. It can be either a name defined by AddFont() or one of the standard families (case
|
| 28 | insensitive):
|
| 29 | <ul>
|
| 30 | <li><code>Courier</code> (fixed-width)</li>
|
| 31 | <li><code>Helvetica</code> or <code>Arial</code> (synonymous; sans serif)</li>
|
| 32 | <li><code>Times</code> (serif)</li>
|
| 33 | <li><code>Symbol</code> (symbolic)</li>
|
| 34 | <li><code>ZapfDingbats</code> (symbolic)</li>
|
| 35 | </ul>
|
| 36 | It is also possible to pass an empty string. In that case, the current family is kept.
|
| 37 | </dd>
|
| 38 | <dt><code>style</code></dt>
|
| 39 | <dd>
|
| 40 | Font style. Possible values are (case insensitive):
|
| 41 | <ul>
|
| 42 | <li>empty string: regular</li>
|
| 43 | <li><code>B</code>: bold</li>
|
| 44 | <li><code>I</code>: italic</li>
|
| 45 | <li><code>U</code>: underline</li>
|
| 46 | </ul>
|
| 47 | or any combination. The default value is regular.
|
| 48 | Bold and italic styles do not apply to <code>Symbol</code> and <code>ZapfDingbats</code>.
|
| 49 | </dd>
|
| 50 | <dt><code>size</code></dt>
|
| 51 | <dd>
|
| 52 | Font size in points.
|
| 53 | <br>
|
| 54 | The default value is the current size. If no size has been specified since the beginning of
|
| 55 | the document, the value is 12.
|
| 56 | </dd>
|
| 57 | </dl>
|
| 58 | <h2>Example</h2>
|
| 59 | <div class="doc-source">
|
| 60 | <pre><code>// Times regular 12
|
| 61 | $pdf->SetFont('Times');
|
| 62 | // Arial bold 14
|
| 63 | $pdf->SetFont('Arial', 'B', 14);
|
| 64 | // Removes bold
|
| 65 | $pdf->SetFont('');
|
| 66 | // Times bold, italic and underlined 14
|
| 67 | $pdf->SetFont('Times', 'BIU');</code></pre>
|
| 68 | </div>
|
| 69 | <h2>See also</h2>
|
| 70 | <a href="addfont.htm">AddFont</a>,
|
| 71 | <a href="setfontsize.htm">SetFontSize</a>,
|
| 72 | <a href="cell.htm">Cell</a>,
|
| 73 | <a href="multicell.htm">MultiCell</a>,
|
| 74 | <a href="write.htm">Write</a>
|
| 75 | <hr style="margin-top:1.5em">
|
| 76 | <div style="text-align:center"><a href="index.htm">Index</a></div>
|
| 77 | </body>
|
| 78 | </html>
|