Location: PHPKode > projects > PHP OpenTailorShop > phpopentailorshop/fpdf/doc/setfont.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link type="text/css" rel="stylesheet" href="../fpdf.css">
<code>SetFont(<b>string</b> family [, <b>string</b> style [, <b>float</b> size]])</code>
Sets the font used to print character strings. It is mandatory to call this method
at least once before printing text or the resulting document would not be valid.
The font can be either a standard one or a font added via the AddFont() method. Standard fonts
use Windows encoding cp1252 (Western Europe).
The method can be called before the first page is created and the font is retained from page
to page.
If you just wish to change the current font size, it is simpler to call SetFontSize().
<strong>Note:</strong> the font metric files must be accessible. They are searched successively in:
<li>The directory defined by the <code>FPDF_FONTPATH</code> constant (if this constant is defined)</li>
<li>The <code>font</code> directory located in the directory containing <code>fpdf.php</code> (if it exists)</li>
<li>The directories accessible through <code>include()</code></li>
Example defining <code>FPDF_FONTPATH</code> (note the mandatory trailing slash):
<div class="doc-source">
If the file corresponding to the requested font is not found, the error "Could not include
font metric file" is issued.
<dl class="param">
Family font. It can be either a name defined by AddFont() or one of the standard families (case
<li><code>Courier</code> (fixed-width)</li>
<li><code>Helvetica</code> or <code>Arial</code> (synonymous; sans serif)</li>
<li><code>Times</code> (serif)</li>
<li><code>Symbol</code> (symbolic)</li>
<li><code>ZapfDingbats</code> (symbolic)</li>
It is also possible to pass an empty string. In that case, the current family is retained.
Font style. Possible values are (case insensitive):
<li>empty string: regular</li>
<li><code>B</code>: bold</li>
<li><code>I</code>: italic</li>
<li><code>U</code>: underline</li>
or any combination. The default value is regular.
Bold and italic styles do not apply to <code>Symbol</code> and <code>ZapfDingbats</code>.
Font size in points.
The default value is the current size. If no size has been specified since the beginning of
the document, the value taken is 12.
<div class="doc-source">
<pre><code>//Times regular 12
//Arial bold 14
//Removes bold
//Times bold, italic and underlined 14
<h2>See also</h2>
<a href="addfont.htm">AddFont()</a>,
<a href="setfontsize.htm">SetFontSize()</a>,
<a href="cell.htm">Cell()</a>,
<a href="multicell.htm">MultiCell()</a>,
<a href="write.htm">Write()</a>.
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
Return current item: PHP OpenTailorShop