source: trunk/client/inc/hpdf/_fpdf/doc/setfont.htm@ 2

Last change on this file since 2 was 2, checked in by root, 15 years ago

importo il progetto

File size: 3.2 KB
Line 
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>
12Sets the font used to print character strings. It is mandatory to call this method
13at least once before printing text or the resulting document would not be valid.
14<br>
15The font can be either a standard one or a font added via the AddFont() method. Standard fonts
16use Windows encoding cp1252 (Western Europe).
17<br>
18The method can be called before the first page is created and the font is retained from page
19to page.
20<br>
21If 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>
30Example defining <code>FPDF_FONTPATH</code> (note the mandatory trailing slash):
31<div class="doc-source">
32<pre><code>define('FPDF_FONTPATH','/home/www/font/');
33require('fpdf.php');</code></pre>
34</div>
35If the file corresponding to the requested font is not found, the error "Could not include
36font metric file" is issued.
37<h2>Parameters</h2>
38<dl class="param">
39<dt><code>family</code></dt>
40<dd>
41Family font. It can be either a name defined by AddFont() or one of the standard families (case
42insensitive):
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>
50It 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>
54Font 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>
61or any combination. The default value is regular.
62Bold and italic styles do not apply to <code>Symbol</code> and <code>ZapfDingbats</code>.
63</dd>
64<dt><code>size</code></dt>
65<dd>
66Font size in points.
67<br>
68The default value is the current size. If no size has been specified since the beginning of
69the 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-&gt;SetFont('Times');
76//Arial bold 14
77$pdf-&gt;SetFont('Arial','B',14);
78//Removes bold
79$pdf-&gt;SetFont('');
80//Times bold, italic and underlined 14
81$pdf-&gt;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>
Note: See TracBrowser for help on using the repository browser.