1

I have following code that perfectly works on Linux:

auto pdf_doc = HPDF_New(nullptr, nullptr);
if (!pdf_doc) { /* error handling */ }

HPDF_SetCompressionMode(pdf_doc, HPDF_COMP_ALL);

HPDF_UseUTFEncodings(pdf_doc);
HPDF_SetCurrentEncoder(pdf_doc, "UTF-8");

const char* font_bold_name = HPDF_LoadTTFontFromFile(pdf_doc, "HelveticaBd.ttf", HPDF_TRUE);
auto font_bold = HPDF_GetFont(pdf_doc, font_bold_name, "UTF-8");

const char* font_regular_name = HPDF_LoadTTFontFromFile(pdf_doc, "Helvetica.ttf", HPDF_TRUE);
auto font_regular = HPDF_GetFont(pdf_doc, font_regular_name, "UTF-8");

But on Windows, call to HPDF_LoadTTFontFromFile() returns "" and error 105D is set in pdf_doc. This error according to the documentation, means "Font cannot be embedded. (license restriction)".

But the same TTF font files are working on Linux. I also tried the font provided in demo but in that case it sets error 0x1017 in pdf_doc which means "Cannot open a file. (Detailed code is set.)"

Also the call succeeds when I pass HPDF_FALSE(meaning "do not embed the font") and it works. But I need to embed the font :(

Has anybody faced similar issue?
Am I missing something?
Why would license be an issue on Windows when Linux allows it?
Is it related to any font related settings/config on Windows?

Edit:
Error is occurring for Helvetica-bold font. The regular version of Helvetica doesn't cause any error but it is not getting embedded.
Does it have to do anything with the Base-14 fonts?

Sam
  • 1,842
  • 3
  • 19
  • 33
  • Do those font files "HelveticaBd.ttf" and "Helvetica.ttf" actually exist on your Windows system? I am able to use HPDF_LoadTTFontFromFile() with embedding if I point to a specific .ttf file that exists. – M Katz Jun 03 '19 at 07:33
  • Of course. As I mentioned, the call even succeeds without embedding the font. – Sam Jun 04 '19 at 05:54
  • The call succeeding does not necessarily mean the font is there. In any case, here is an issue with some code that works for me for embedding fonts, if it helps: https://stackoverflow.com/questions/56423869/utf8-in-libharu-is-embedding-fonts-really-necessary You could try embedding verdana like I'm doing just to separate out whether the problem is the particular font. – M Katz Jun 04 '19 at 06:03

0 Answers0