welcome to the fourth (fifth ^_^) chapter of PHP FPDF tutorial series. in this short chapter, i’m about to demonstrate how to add custom font in our PDF document. and we will also learn how to deal with font variants. as an examples, we will use three different font families. Jokerman, Freescript, and Alien League second edition. Alien League, however, will have two variants which is regular version, and italic version. so here we have 2 font files for Alien League, one is regular the other is italic. in FPDF, we cannot use the font’s TTF file directly to add a new font. so in FPDF directory, there is a script called makefont.php. we use makefont to convert ttf file into .z file and .php file which stores characters definition, so let’s do this. to make things easier, first, copy the directory path of your makefont.php file. then you need to put your fonts file in a directory. in my example, customfont directory. open command prompt, use cd command to move into your fonts directory. then execute makefont.php with the font file name as parameter. a .php and .z file with the same name will be generated. These are the files you need. do it again for each fonts. close your command prompt, copy those files into “font” directory inside “fpdf17” directory. then let’s make the PDF generator. to define a new font, we need to use AddFont() method with three parameters. first parameter is family name. the name can be chosen arbitrarily. just to make it straight, i’ll simply use the font names. second is style or variant. the default value is regular. third is the php file of the respective fonts we’ve just made. let’s add each font. because Alien League will have two variants, we need to define it twice. both should have the same family name, but different variant and php file. then finally use SetFont() method to use the fonts. i’ve made a mistake here by using wrong php file name in font definition. let’s fix it. this concludes this chapter of tutorial. thank you for watching. see you next time.