(Versi Bahasa Indonesia: https://medium.com/@ekastrya/cara-menambah-font-untuk-tcpdf-17af6808b76)
Earlier today, I was assigned a simple task to add two custom fonts for a client's project. It took me 15 minutes on Stack Overflow to find a fast way to do this. Found it and here are the steps:
- Install / download / require the tcpdf library into your project.
- Open the library folder (for example mine was: ./vendor/tecnickcom/tcpdf).
- Notice and enter to the tools folder.
- Copy the TTF file(s) into this tools folder.
- Run this command from the terminal (still from the tools folder):
$ php tcpdf_addfont -i BOOKOS.TTF
(Replace BOOKOS.TTF with your own fonts) - Repeat step (5) for each fonts desired.
Coding time..
To change between fonts from your php code, use the following scripts.
$pdf->SetFont($font_family = ‘bookos’, $variant = ‘’, $fontsize = 11);
(Versi Bahasa Indonesia: https://medium.com/@ekastrya/cara-menambah-font-untuk-tcpdf-17af6808b76)
Top comments (3)
I'm getting some gibberish characters, please help
Works perfectly! Thanks
Somehow I had to add '.php' to 'tcpdf_addfont' to make it work.
Should we delete the fonts from the 'tools' folder after we execute the command?