Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to load large font #93

Open
trlsmax opened this issue Nov 24, 2023 · 0 comments
Open

Fail to load large font #93

trlsmax opened this issue Nov 24, 2023 · 0 comments

Comments

@trlsmax
Copy link

trlsmax commented Nov 24, 2023

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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant