Fail to load large font
Opened this issue · 0 comments
trlsmax commented
I try to load large font to display chinese char, but most of time it fail and display random wrong char.
here is how I load font:
auto& io = ImGui::GetIO();
ImFontConfig fontcfg;
fontcfg.OversampleH = 4;
fontcfg.OversampleV = 4;
fontcfg.SizePixels = std::round(16 * screen_scalex);
#ifdef _WIN32
if (std::filesystem::is_regular_file("C:\\Windows\\Fonts\\simsun.ttc")) {
ImFontGlyphRangesBuilder builder;
ImVector<ImWchar> ranges;
builder.AddText(u8"阈矢轴滞浏廓拷°²³√");
builder.AddRanges(io.Fonts->GetGlyphRangesChineseSimplifiedCommon());
builder.BuildRanges(&ranges);
io.Fonts->AddFontFromFileTTF("C:\\Windows\\Fonts\\simsun.ttc", 20, &fontcfg, ranges.Data);
} else {
io.Fonts->AddFontDefault(&fontcfg);
}
#else
io.Fonts->AddFontDefault(&fontcfg);
#endif
io.Fonts->Build();