SetFont

SetFont(string family [, string style [, double size]])

Description

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 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().

Note: for the method to work, the font metric files must be accessible. There are three possibilities for this:

Example for the last case (note the trailing slash):

define('FPDF_FONTPATH','/home/www/font/');
require('fpdf.php');

If the file corresponding to the requested font is not found, the error "Could not include font metric file" is generated.

Parameters

family
Family font. Possible values are (case insensitive): It is also possible to pass an empty string. In that case, the current family is retained.
style
Font style. Possible values are (case insensitive): The default value is normal. Style does not apply to Symbol and ZapfDingbats.
size
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.

Example

//Times normal 12
$pdf->SetFont('Times');
//Arial bold 14
$pdf->SetFont('Arial','B',14);
//Removes bold
$pdf->SetFont('');
//Times normal 14
$pdf->SetFont('Times');

See also

SetFontSize(), Cell(), MultiCell().

Index