blob: d7fb73c32024f4546ae28ddb669811604af4663b [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001<!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>
12Sets the font used to print character strings. It is mandatory to call this method at least once before printing text.
13<br>
14<br>
15The font can be either a standard one or a font added by the AddFont() method. Standard fonts
16use the Windows encoding cp1252 (Western Europe).
17<br>
18<br>
19The method can be called before the first page is created and the font is kept from page to page.
20<br>
21<br>
22If 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>
27Family font. It can be either a name defined by AddFont() or one of the standard families (case
28insensitive):
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>
36It 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>
40Font 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>
47or any combination. The default value is regular.
48Bold and italic styles do not apply to <code>Symbol</code> and <code>ZapfDingbats</code>.
49</dd>
50<dt><code>size</code></dt>
51<dd>
52Font size in points.
53<br>
54The default value is the current size. If no size has been specified since the beginning of
55the 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-&gt;SetFont('Times');
62// Arial bold 14
63$pdf-&gt;SetFont('Arial', 'B', 14);
64// Removes bold
65$pdf-&gt;SetFont('');
66// Times bold, italic and underlined 14
67$pdf-&gt;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>