Reputation: 19
I'm trying to load an .otf font in Php 7.4.7 like this:
$pdflib = new pdflib();
$pdflib->set_option('textformat=utf8');
$pdflib->set_option('SearchPath={{fullpath/to/my/fonts}}');
the log show up to this point no errors:
[New category:resource "SearchPath:fullpath/to/my/fonts"]
$font = $pdflib->load_font("My-Font-Regular", "unicode", "embedding");
I get this error:
[Last exception 2516 in load_font]["Font 'My-Font-Regular' with encoding 'unicode': Font file (AFM, PFM, TTF, OTF etc.) or host font not found"]
I have tried utf-8 as encoding, giving full path when adding the search path and when loading the font, single and double curly braces when setting the search path but I could make more progress.
Also tried with no success:
$pdflib->set_option("stringformat=utf8");
I couldn't find any documentation for accepted encodings and the function it's not even described in the pdflib provided docs.
Any help would be greatly appreciated.
Upvotes: 0
Views: 1794
Reputation: 2185
in general this looks fine, but there are a few potential pitfalls when using the extension based search:
My-Font-Regular
. Do your font file have this name with the extension .otf
=> My-Font-Regular.otf
fullpath/to/my/fonts
(or a sub directory) has wrong read permissions for your PHP process.Please see PDFlib 9 Tutorial, chapter 6.4.4 Searching for Fonts section Extension-based search for font files for a detailed explanation.
As you have already enabled logging, you can enable more details by adding classes {filesearch=3}. Please see PDFlib 9 API Reference, chapter 1.3 Logging for more details. This might give you more details. And I'm sure, opening a Support case at PDFlib with sharing more details might also be an option.
Upvotes: 1