Specific fonts in TCPDF pdf

Karol85 picture Karol85 · Jan 14, 2012 · Viewed 29.6k times · Source

Can somebody tell me what i am doing wrong? I need Arial font in my pdf generated by TCPDF. First I've tried to use that : 1) I got Arial from windows fonts caltalog and put it in TCPDF directory. 2) Next I wrote in script :

$fontname = $pdf->addTTFfont('../lib/tcpdf/arial.ttf', '', '', 32);

After that in tcpdf/fonts appears 3 files (arial.ctg.z , arial.php and arial.z). I thought that everything was ok but if in TCPDF i use this font by:

$pdf->SetFont('arial', '', 16);

Font in document is indeed arial but without polish specific sings (ąęłżńź)

I've tried also prepare font by yourself : I downloaded ttf2afm and makefontuni.php script then in command line I wrote this:

ttf2ufm -a arial.ttf
php -q makefontuni.php arial.ttf arial.ufm

that command gave me also 3 files (arial.ctg.z , arial.php and arial.z) but final situation is the same like before.

I've admit that all data writing to pdf is in UTF-8 and TCPDF construct is like this :

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'utf-8', false);

I don't know what am i doing wrong. :(

Answer

Yannis picture Yannis · Oct 17, 2012

If you want to use a custom font use this tool

https://www.xml-convert.com/en/convert-tff-font-to-afm-pfa-fpdf-tcpdf

when you get the generated files just move them to the /fonts directory and with the same name they have, set the font-name attribute.