tudelft3d / AdTree

Accurate, detailed, and automatic modelling of laser-scanned trees

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chinese cannot be displayed

jhr990206 opened this issue · comments

Hello!

The code in the picture comes from the file "viewer_imgui.cpp". I tried to modify the content in Text to Chinese, but what was displayed “?”, Chinese cannot be displayed. Can you provide me with a solution? Thank you!
picture

In line 97 of "viewer_imgui.cpp", you see

io.Fonts->AddFontFromMemoryCompressedTTF(droid_sans_compressed_data, droid_sans_compressed_size, static_cast<float>(font_size * dpi_scaling()));

Here the font "droid_sans_compressed_data" doesn't support Chinese.

You will first need to add a font that supports Chinese, e.g.,

io.Fonts->AddFontFromFileTTF("/Users/lnan/Documents/Projects/Easy3D/resources/fonts/cn_Mao.ttf", static_cast<float>(font_size * dpi_scaling()), nullptr, io.Fonts->GetGlyphRangesChineseSimplifiedCommon());

Then input your Chinese characters like:

(const char*)u8"你好".

Below is what I just got:
Screen Shot 2023-12-28 at 23 08 17

Please format your code (I couldn't read it), and the image is also not attached.

See the following comment in 'viewer_imgui.cpp':

// If you want to show other languages, e.g., Chinese, you first need to use a TTF font file that supports Chinese. You can replace the above line by:
 io.Fonts->AddFontFromFileTTF("/Users/lnan/Documents/Projects/Easy3D/resources/fonts/cn_Mao.ttf", static_cast<float>(font_size * dpi_scaling()), nullptr, io.Fonts->GetGlyphRangesChineseSimplifiedCommon());
// Then input the Chinese characters like: 
(const char*)u8"你好". 

I will reply here (Please don't create another issue).
As I have shown you before, the code can already visualize Chinese characters.
Please do:
-) show your code of "AddFontFromFileTTF(...)";
-) make sure your font file supports Chinese. You can send me your file so I can check.
-) make sure your font file has been successfully loaded.

This file has been mod
code.txt
ified based on your code. I hope you can help me check for any issues. Thank you very much!

Can you try to change (in both the folder where you store the ttf file and your code) your font file from cn_***.ttf to cn_Mao.ttf? Below is what I get:
image

I suspect either your IDE, or the code, or your OS doesn't support Chinese characters in the path string.
Let me know if this solves the problem.

Was it due to the Chinese title of the font file?

That's right, that's the reason.