Default Font Constructors in FPDF Tamil


SetFont

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 the Windows encoding cp1252 (Western Europe).The method can be called before the first page is created and the font is kept from page to page.

Syntax


SetFont(string family , string style , float size)

Parameters

  • family
  • style
  • size

family

Font writing style.It is also possible to pass an empty string. In that case, the current family is kept. It can be either a name defined by AddFont() or one of the standard families are

  • Courier (fixed-width)
  • Helvetica or Arial (synonymous; sans serif)
  • Times (serif)
  • Symbol (symbolic)
  • ZapfDingbats (symbolic)
$pdf -> SetFont('Times');

style

Font display style.It is also possible to pass an empty string. In that case, the current family is kept. using default values or any combination.

  • empty string: regular
  • B: bold
  • I: italic
  • U: underline
$pdf -> SetFont('B');

The default value is regular. Bold and italic styles do not apply to Symbol and ZapfDingbats.

size

Font display size in points.The default value is the current size. If no size has been specified since the beginning of the document, the value is 12.

$pdf -> SetFont(14);
Example
$pdf -> SetFont('Times','B',14);

AddFont

Imports a TrueType, OpenType or Type1 font and makes it available. It is necessary to generate a font definition file first with the MakeFont utility. if you want to view the steps of adding fonts Click Here

Syntax


AddFont(string family , string style , string file)

Parameters

  • family
  • style
  • file

family

Font writing style.The name can be chosen arbitrarily. If it is a standard family name, it will override the corresponding font.

style

Font display style.values are

  • empty string: regular
  • B: bold
  • I: italic
  • BI or IB: bold italic

file

The font definition file. By default, the name is built from the family and style, in lower case with no space.

Source Code

<?php
	require_once "fpdf/fpdf.php"; //fpdf supporting file
 
//Page Creation (Default value is P;Default value is mm;default page size: A4)
#   $pdf = new FPDF(); 
//or
    $pdf = new FPDF('P','mm','A4');
    $pdf -> AddPage();
 
    // SetFont(family,style,size)
    $pdf -> SetFont('Arial','',14);
 
    //Using bold,italic,underline the text
    $pdf -> SetFont('Arial','BIU',14); //B-bold; I-italic; U-underline
 
    //addFont(family,style,file)
    $pdf ->addFont('Roboto','','Roboto.php'); //Adding Custom Font
    $pdf -> SetFont('Roboto','',10);
 
 
    $pdf -> Output(); // Display output
?>
View Demo