Version/Branch of Dear ImGui:
v1.63
Back-end file/Renderer/OS:
glfw + opengl2 + imgui
My Issue/Question:
why the text show like the attachment?
when I use this code,it’s show text like cube:
ImGui::GetIO().Fonts->AddFontFromFileTTF(“msyh.ttc”, 60.0f, NULL, ImGui::GetIO().Fonts->GetGlyphRangesChineseFull());
but I use this code,it’s show text like normal:
ImGui::GetIO().Fonts->AddFontFromFileTTF(“msyh.ttc”, 60.0f, NULL, ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon());
Hello,
This happen if you failed to upload the texture to the GPU, which generally happen if the texture is too small.
GetGlyphRangesChineseFull() at size 60 with Oversampling bigger than 1 is going to create way too large textures.
Please read misc/fonts/README (https://github.com/ocornut/imgui/tree/master/misc/fonts)
In particular I have just updated this section:
If you have very large number of glyphs or multiple fonts, the texture may become too big for your graphics API.
The typical result of failing to upload a texture is if every glyphs appears as white rectangles.
In particular, using a large range such as GetGlyphRangesChineseSimplifiedCommon() is not recommended unless you
set OversampleH/OversampleV to 1 and use a small font size.
Mind the fact that some graphics drivers have texture size limitation.
If you are building a PC application, mind the fact that your users may use hardware with lower limitations than yours.
Some solutions:
- 1) Reduce glyphs ranges by calculating them from source localization data. You can use ImFont::GlyphRangesBuilder for this purpose,
this will be the biggest win.
- 2) You may reduce oversampling, e.g. config.OversampleH = config.OversampleV = 1, this will largely reduce your texture size.
- 3) Set io.Fonts.TexDesiredWidth to specify a texture width to minimize texture height (see comment in ImFontAtlas::Build function).
- 4) Set io.Fonts.Flags |= ImFontAtlasFlags_NoPowerOfTwoHeight; to disable rounding the texture height to the next power of two.