Reputation: 191
I want to use multiple fonts in tcpdf.. ex: Hello world I want Hello in frutiger light font and world in frutiger Bold
$fruit=$pdf->AddFont('fruit');
$pdf->SetFont($fruit['family']);
Everthing appears in frutiger light font.I dont know how to use multiple fonts .It would be great if someone answers.i have include this frutiger light and frutiger bold in my font library.Thanks in Advance
Upvotes: 1
Views: 6959
Reputation: 11
\TCPDF_FONTS::addTTFfont(realpath(_SITE_PATH_.'.../ARIALNB.TTF'), 'TrueTypeUnicode', '', 32); // bold $fontname = \TCPDF_FONTS::addTTFfont(realpath(_SITE_PATH_.'.../ARIALN.TTF'), 'TrueTypeUnicode', '', 32); // normal $pdf->SetFont($fontname, '', 10, '', false); // set normal // else $pdf->SetFont('ARIALN', '', 10, '', false); // set normal $html='[ b ]Развъдна организация/[/b]/[br/] // format bold [span style="line-height: 11px;"]TEXT[/span]'; $pdf->writeHTMLCell(61, 25, 138, 7, $html, 0, 0, 0, true, 'L', true); // print
Upvotes: 1
Reputation: 820
To create a new font, you need to do that :
$pdf->addTTFfont('fontName', '', 'fontName.php');
$pdf->addTTFfont('fontNameBold', '', 'fontNameBold.php');
And to use both, you have to do like that :
$pdf->SetFont('fontName', '', 10);
//Write something here with the font "fontName"
$pdf->SetFont('fontNameBold', '', 10);
//Write something here in bold with the font "fontNameBold"
$pdf->SetFont('fontName', '', 15);
//Write something here with the font "fontName"
And if you don't have your answer now, you can check this one : http://www.tcpdf.org/fonts.php
Or this one : http://www.tcpdf.org/examples.php
Upvotes: 3