I'm using the FPDF library for PHP to generate reports, but now I need to use another font (Verdana) that isn't in the core fonts. I added the line:
$pdf->AddFont('Verdana','','verdana.php');
I copied the files verdana.php and verdana.z to the fonts directory. Every things works fine, if I use the next instructions:
$pdf->SetFont('Verdana','',6);
But if I try to use the next instruction (to use the bold font):
$pdf->SetFont('Verdana','B',6);
I get the error:
FPDF error: Undefined font: verdana B
I tried adding another font for the Verdana Bold:
$pdf->AddFont('Verdana-Bold','B','verdanab.php');
Of course, I put the files verdanab.php and verdanab.z in the fonts directory. But I get the same error. What I'm missing or how to use both Verdana fonts (normal and bold)?
Thanks in advance.
php'); $pdf = new FPDF(); $pdf->AddFont('CevicheOne','','CevicheOne-Regular. php'); $pdf->AddPage(); $pdf->SetFont('CevicheOne','',35); $pdf->Write(10,'Enjoy new fonts with FPDF!'
To do this, add the key "Fonts provided by application" to Info. plist (the raw key name is UIAppFonts ). Xcode creates an array value for the key; add the name of the font file as an item of the array. Be sure to include the file extension as part of the name.
Adding Custom Fonts to the projectDrag and Drop your font files in the new folder and choose the checkboxes for Copy items if needed and Add to targets. Then press Finish. Press the arrow next to Fonts provided by application and add the font file names.
Standart Font Families:
Courier (fixed-width)
Helvetica or Arial (synonymous; sans serif)
Times (serif)
Symbol (symbolic)
ZapfDingbats (symbolic)
Here you can create your own .php file for Fpdf:
http://www.fpdf.org/makefont/
Use this syntax:
$pdf->AddFont('Verdana','','verdanab.php');
instead of using:
$pdf->AddFont('Verdana','B','verdanab.php');
make sure you have added the font directory at the top of the script before require('fpdf.php');
define('FPDF_FONTPATH','./font/');
if you have already done that, then just remove 'B' from the setFont() method. Its a quick fix and not a good practice.
$pdf->SetFont('Verdana','',6);
For more help you can go through this Adding new fonts and encoding support
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With