How to set different Fonts in TCPDF
php, tcpdf
Solution
You can use your custom fonts inside html like this:
$fontname=$pdf->addTTFfont('path/myfont.ttf', '', '', 32);
//echo $fontname;
$html='<span style="font-family:'.$fontname'.;font-weight:bold">my text in bold</span>: my normal text';
$pdf->writeHTMLCell($w=0,$h=0,$x=11,$y=201,$html,$border=0,$ln=0,$fill=false,$reseth=true,$align='L',$autopadding=false);
Problem
I am looking for a solution to set more than just one font for my PDF document which is created with tcpdf. I want to do something like this: ``` $pdf->SetFont('verdana_bold', 'B', 12); $pdf->SetFont('verdana', '', 12); ``` I need for my document a bold font and a regular font. The example above doesn't work. When I switch the two lines the text is all bold. When I use the example above the text is just regular. I want to set the `font-weight` with regular css stylesheets. Hope you have a solution.