libredwg icon indicating copy to clipboard operation
libredwg copied to clipboard

font_file is null When the TEXT font name is not plain ASCII

Open shanzhugit opened this issue 4 years ago • 1 comments
trafficstars

Hi~ For Text entity, if the font name is Arial or others that is plain ASCII, we can get the correct font_file. But when Text entity use Chinese font with Chinese font name like “黑体” or "宋体"( btw, their .ttf file names are plain English), it returns null font _file. See the example file attached.

          Dwg_Entity_TEXT *text;
          text = dwg.object[i].tio.entity->tio.TEXT;
          Dwg_Object_STYLE *style = text->style->obj->tio.object->tio.STYLE;
          char *stylename;
          stylename = bit_convert_TU((BITCODE_TU)style->font_file);

Could you help check if the issue can be solved? Thank you~~ Text.zip

shanzhugit avatar Feb 05 '21 17:02 shanzhugit

In the case of the 3rd style, with name "FS" and the EED

EED[0] code: 0 [RC], wstring: len=6 [RS] "SimHei" [TU]
EED[1] code: 71 [RC], long: 34353 [RL]

the length of the font_file fields is 0. So it looks like you want to copy the EED code 0 name over to font_file? This is problematic.

I'd rather add a helper function to get the font_file property either from the font_file field, or the EED, which also adds much more TTF flags. "SimHei" would be the family/typeface I guess, pitch, charset, and italic and bold flags are in the ttf_flag (code 71) 34353, i.e. 0x8631. I do that already for DXF output.

rurban avatar Feb 23 '21 07:02 rurban