50% OFF!!!

Sunday, December 12, 2021

using FontAwesome in PHP FPDF

Hi All,

I found it impossible to use FontAwesome 4.7.0 Free version, inside FPDF PHP engine.

When trying to upload the FontAwesome.4.7.full.otf into FPDF's Font File Generation, I'm getting an error:

Error: OpenType fonts based on PostScript outlines are not supported


So my solution, 

to re-build the FontAwesome font 4.7 free version (under same license!),

with mapping of regular characters to icons HEX CODES: 0x21 to 0xFF. 

So for example, 

character code 0x21 is now mapped to * (FontAwesome's asterisk)


And then, just use it inside PHP FPDF as follows:

// Import and prepare font for usage by engine:

$pdf->AddFont('FontAwesome47-P1','','FontAwesome47-P1.php');

...

// print FontAwesome's asterisk

$pdf->SetFont('FontAwesome47-P1' '', 14);

$pdf->Text($x, $y, chr(0x21));


Note:

Remember to upload the files FontAwesome47-P1.php + FontAwesome47-P1.z,
that generated on FPDF's Font File Generation to the FPDF's font folder.

Characters code MAP of new fonts exists as preview when opening the google-drive links below.


View MAP + DOWNLOAD: FontAwesome47-P1.otf (google drive)

View MAP + DOWNLOADFontAwesome47-P2.otf (google drive)

View MAP + DOWNLOADFontAwesome47-P3.otf (google drive)

View MAP + DOWNLOADFontAwesome47-P4.otf (google drive)


PHP+Z Files ready-to-use for PHP FPDF (with ISO-8859-1 encoding):

FontAwesome47-P1-4 (php+z files) DOWNLOAD (google drive)



Best regards!

Please write comments...


1 comment:

  1. This is really a live saver - thanks!
    But how do I use the Latin-1 Supplement in P1?
    If I use chr(0x31) I get the check sign (0031 in basic Latin), but using chr(0xB7) I do not get the shopping wagon (00B7 in supplement)

    ReplyDelete