0

I tried to generate pdf files with libharu. There are many different languages input in my case, so I chose the encoder(UTF-8). The following architecture is about my code:

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

    const char * font_name = HPDF_LoadTTFontFromFile(pdf, "ArialUnicodeMS.ttf", HPDF_TRUE);
    HPDF_Font font = HPDF_GetFont(pdf, font_name, "UTF-8");
    HPDF_Page_SetFontAndSize(page, font, 12);

    HPDF_Page_BeginText(page);
    HPDF_Page_MoveTextPos(page, 60 + i * 100, height - 75);
    HPDF_Page_ShowText(page, font_name[i]);
    HPDF_Page_EndText(page);

Here are my testing input: "тест", "テスト", "Ölçek", "ทดสอบ", "테스트", "測試", "测试". The library worked, but not in every fonts. I know I shoud use the font support UTF-8, so I have tried ArialUnicodeMS, DroidSans, DroidSansFallback, DroidSansFallbackFull. Only ArialUnicodeMS can output all inputs. I use FontForge to check the difference between these fonts, but DroidSans also povides characters I want. Please tell me the reason about this situation, thanks a lot.

0 Answers0