Fries of Doom
Fries of Doom

Reputation: 179

Does anyone know why HarfBuzz with FreeType Is just rendering "??? ???? ????"

I've compiled this HarfBuzz example, and the renderings that I'm getting are just "???? ???? ?????".

The example I'm compiling is this https://github.com/tangrams/harfbuzz-example

The output should look something like what is presented on the example's github page, but I'm just getting "???? ??? ????" for all the different texts.

This is the output from the program, so it seems to be loading the fonts that came with the example correctly, although these names seem fairly generic:

> 0: DejaVu Serif Book unic plat=0 id=3
> 1: DejaVu Serif Book unic plat=0 id=4
> 2: DejaVu Serif Book armn plat=1 id=0
> 3: DejaVu Serif Book unic plat=3 id=1
> 4: DejaVu Serif Book unic plat=3 id=10
> 0: Source Sans Pro Regular unic plat=0 id=3
> 1: Source Sans Pro Regular armn plat=1 id=0
> 2: Source Sans Pro Regular unic plat=3 id=1
> 3: Source Sans Pro Regular ADOB plat=7 id=0
> 0: AR PL New Sung Regular unic plat=0 id=3
> 1: AR PL New Sung Regular armn plat=1 id=0
> 2: AR PL New Sung Regular unic plat=3 id=1
> ex 0 string min_x=3 max_x=420 min_y=-1 max_y=36 bbox 417x37 boffs 36,3
> ex 0 origin 20,50 bbox l=23 r=440 t=14 b=51
> ex 1 string min_x=1 max_x=356 min_y=0 max_y=34 bbox 355x34 boffs 34,1
> ex 1 origin 425,125 bbox l=426 r=781 t=91 b=125
> ex 2 string min_x=-10 max_x=12 min_y=-250 max_y=-4 bbox 22x246 boffs -10,-4
> ex 2 origin 389,200 bbox l=379 r=401 t=204 b=450

And these are the strings it's trying to render:

const char *texts[NUM_EXAMPLES] = {
  "Ленивый рыжий кот",
  "كسول الزنجبيل القط",
  "懶惰的姜貓",
}; 

If I change the strings to English characters, they render alright, which makes me think the fonts dont contain the correct languages, but as far as I can tell, it is loading the fonts that came with the example, and I did try changing the Arabic font to one that I was told definitely contains Arabic fonts.

/* Load our fonts */
FT_Face ft_face[NUM_EXAMPLES];
assert(!FT_New_Face(ft_library, "fonts/DejaVuSerif.ttf", 0, &ft_face[ENGLISH]));
assert(!FT_Set_Char_Size(ft_face[ENGLISH], 0, ptSize, device_hdpi, device_vdpi));
ftfdump(ft_face[ENGLISH]); // wonderful world of encodings ...
force_ucs2_charmap(ft_face[ENGLISH]); // which we ignore.

assert(!FT_New_Face(ft_library, "fonts/SourceSansPro-Regular.otf", 0, &ft_face[ARABIC]));
assert(!FT_Set_Char_Size(ft_face[ARABIC], 0, ptSize, device_hdpi, device_vdpi));
ftfdump(ft_face[ARABIC]);
force_ucs2_charmap(ft_face[ARABIC]);

assert(!FT_New_Face(ft_library, "fonts/fireflysung-1.3.0/fireflysung.ttf", 0, &ft_face[CHINESE]));
assert(!FT_Set_Char_Size(ft_face[CHINESE], 0, ptSize, device_hdpi, device_vdpi));
ftfdump(ft_face[CHINESE]);
force_ucs2_charmap(ft_face[CHINESE]);

I'm compiling with C++17. I have already read this in case anyone mentions it: https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/

Does anyone know why I'm just getting question marks? Is there a compiler setting I need to enable UTF-8? Is it possible the compiler is stripping out the UTF-8 strings?

Thanks!

Upvotes: 0

Views: 1113

Answers (1)

Fries of Doom
Fries of Doom

Reputation: 179

Yes, there is a compiler option, /utf-8 (MSVC)

Upvotes: 0

Related Questions