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