From 04d39179931a6b17385f7f4c8123b119529cae5c Mon Sep 17 00:00:00 2001 From: "liz.li" Date: Fri, 2 Sep 2022 15:02:54 +0800 Subject: [PATCH] FIX: imgui font texture failed Change-Id: I5ba0ad1c568024ab15e3c1559015e192709376a2 --- src/slic3r/GUI/ImGuiWrapper.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp index b78cacde0..7c497219e 100644 --- a/src/slic3r/GUI/ImGuiWrapper.cpp +++ b/src/slic3r/GUI/ImGuiWrapper.cpp @@ -1705,10 +1705,12 @@ void ImGuiWrapper::init_font(bool compress) #endif builder.BuildRanges(&ranges); // Build the final result (ordered ranges with all the unique characters submitted) + io.Fonts->Flags |= ImFontAtlasFlags_NoPowerOfTwoHeight; + ImFontConfig cfg = ImFontConfig(); + cfg.OversampleH = cfg.OversampleV = 1; //FIXME replace with io.Fonts->AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, m_font_size, nullptr, ranges.Data); //https://github.com/ocornut/imgui/issues/220 - ImFont* font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/" + "HarmonyOS_Sans_SC_Regular.ttf").c_str(), m_font_size, nullptr, ranges.Data); - + ImFont* font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/" + "HarmonyOS_Sans_SC_Regular.ttf").c_str(), m_font_size, &cfg, io.Fonts->GetGlyphRangesChineseSimplifiedCommon()); if (font == nullptr) { font = io.Fonts->AddFontDefault(); if (font == nullptr) { @@ -1716,10 +1718,7 @@ void ImGuiWrapper::init_font(bool compress) } } - ImFontConfig cfg = ImFontConfig(); - cfg.OversampleH = 1; - bold_font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/" + "HarmonyOS_Sans_SC_Bold.ttf").c_str(), m_font_size, &cfg); - + bold_font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/" + "HarmonyOS_Sans_SC_Bold.ttf").c_str(), m_font_size, &cfg, io.Fonts->GetGlyphRangesChineseSimplifiedCommon()); if (bold_font == nullptr) { bold_font = io.Fonts->AddFontDefault(); if (bold_font == nullptr) { throw Slic3r::RuntimeError("ImGui: Could not load deafult font"); }