Chinese cannot be displayed
jhr990206 opened this issue · comments
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"你好".
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!
Was it due to the Chinese title of the font file?
That's right, that's the reason.