setfont.htm
3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<TITLE>SetFont</TITLE>
<LINK TYPE="text/css" REL="stylesheet" HREF="../fpdf.css">
</HEAD>
<BODY>
<H2>SetFont</H2>
<TT>SetFont(<B>string</B> family [, <B>string</B> style [, <B>float</B> size]])</TT>
<H4 CLASS='st'>Version</H4>
1.0
<H4 CLASS='st'>Description</H4>
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.
<BR>
The font can be either a standard one or a font added via the AddFont() method. Standard fonts
use Windows encoding cp1252 (Western Europe).
<BR>
The method can be called before the first page is created and the font is retained from page
to page.
<BR>
If you just wish to change the current font size, it is simpler to call SetFontSize().
<BR>
<BR>
<B>Note: </B>for the standard fonts, the font metric files must be accessible. There are three
possibilities for this:
<BR>
<BR>
<UL>
<LI>They are in the current directory (the one where the running script lies)
<BR>
<LI>They are in one of the directories defined by the <TT>include_path</TT> parameter
<BR>
<LI>They are in the directory defined by the <TT>FPDF_FONTPATH</TT> constant
</UL>
Example for the last case (note the trailing slash):
<BR>
<BR>
<TABLE WIDTH="100%" BGCOLOR="#E0E0E0"><TR><TD>
<TT>
define('FPDF_FONTPATH','/home/www/font/');<BR>
require('fpdf.php');
</TT>
</TD></TR></TABLE><BR>
If the file corresponding to the requested font is not found, the error "Could not include
font metric file" is generated.
<H4 CLASS='st'>Parameters</H4>
<TT><U>family</U></TT>
<BLOCKQUOTE>
Family font. It can be either a name defined by AddFont() or one of the standard families (case
insensitive):
<UL>
<LI><TT>Courier</TT> (fixed-width)
<LI><TT>Helvetica<TT> or </TT>Arial</TT> (synonymous; sans serif)
<LI><TT>Times</TT> (serif)
<LI><TT>Symbol</TT> (symbolic)
<LI><TT>ZapfDingbats</TT> (symbolic)
</UL>
It is also possible to pass an empty string. In that case, the current family is retained.
</BLOCKQUOTE>
<TT><U>style</U></TT>
<BLOCKQUOTE>
Font style. Possible values are (case insensitive):
<UL>
<LI>empty string: regular
<LI><TT>B</TT>: bold
<LI><TT>I</TT>: italic
<LI><TT>U</TT>: underline
</UL>
or any combination. The default value is regular.
Bold and italic styles do not apply to <TT>Symbol</TT> and <TT>ZapfDingbats</TT>.
</BLOCKQUOTE>
<TT><U>size</U></TT>
<BLOCKQUOTE>
Font size in points.
<BR>
The default value is the current size. If no size has been specified since the beginning of
the document, the value taken is 12.
</BLOCKQUOTE>
<H4 CLASS='st'>Example</H4>
<TABLE WIDTH="100%" BGCOLOR="#E0E0E0"><TR><TD>
<TT>
//Times regular 12<BR>
$pdf->SetFont('Times');<BR>
//Arial bold 14<BR>
$pdf->SetFont('Arial','B',14);<BR>
//Removes bold<BR>
$pdf->SetFont('');<BR>
//Times bold, italic and underlined 14<BR>
$pdf->SetFont('Times','BIU');
</TT>
</TD></TR></TABLE><BR>
<H4 CLASS='st'>See also</H4>
<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>.
<H6></H6>
<HR>
<DIV ALIGN="CENTER"><A HREF="index.htm">Index</A></DIV>
</BODY>
</HTML>