libharu ios 显示中文

汉字编码采用GBK形式(GBK-EUC-H)

 

所以要输出的汉子应该也采用gbk形式

[@"汉语" cStringUsingEncoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000)]

 

 

HPDF_Page_BeginText(page1);
HPDF_UseCNSFonts(pdf);
HPDF_UseCNSEncodings(pdf);
const char *fontname = HPDF_LoadTTFontFromFile(pdf,"/Library/Fonts/Arial Unicode.ttf",HPDF_TRUE);
    HPDF_Font fontJp = HPDF_GetFont (pdf, fontname, "GBK-EUC-H");
    HPDF_Page_SetFontAndSize(page1, fontJp, 16.0);
    HPDF_Page_TextOut(page1, 50.00, 460.00, [@"汉语" cStringUsingEncoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000)]);
    HPDF_Page_EndText(page1);

你可能感兴趣的:(ios)