egroupware/phpgwapi/inc/fpdf/doc/setfont.htm
2004-06-04 06:17:23 +00:00

104 lines
3.2 KiB
HTML
Executable File

<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-&gt;SetFont('Times');<BR>
//Arial bold 14<BR>
$pdf-&gt;SetFont('Arial','B',14);<BR>
//Removes bold<BR>
$pdf-&gt;SetFont('');<BR>
//Times bold, italic and underlined 14<BR>
$pdf-&gt;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>