From 117ed0060d5ba6327cc993c9dcdd40de4b6c24a2 Mon Sep 17 00:00:00 2001 From: Kiss Lorand <50251547+kisslorand@users.noreply.github.com> Date: Tue, 11 Aug 2026 22:25:09 +0300 Subject: [PATCH] Fix Celsius symbol rendering in Preview (#15202) --- deps_src/imgui/imgui_draw.cpp | 1 + src/slic3r/GUI/ImGuiWrapper.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/deps_src/imgui/imgui_draw.cpp b/deps_src/imgui/imgui_draw.cpp index 913a551fa0..d88bc79904 100644 --- a/deps_src/imgui/imgui_draw.cpp +++ b/deps_src/imgui/imgui_draw.cpp @@ -2856,6 +2856,7 @@ const ImWchar* ImFontAtlas::GetGlyphRangesDefault() { 0x0020, 0x00FF, // Basic Latin + Latin Supplement 0x2000, 0x206F, // General Punctuation + 0x2103, 0x2103, // ℃ Celsius symbol 0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana 0x31F0, 0x31FF, // Katakana Phonetic Extensions 0xFF00, 0xFFEF, // Half-width characters diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp index 8974a169d1..d46e8ed31b 100644 --- a/src/slic3r/GUI/ImGuiWrapper.cpp +++ b/src/slic3r/GUI/ImGuiWrapper.cpp @@ -2809,12 +2809,26 @@ void ImGuiWrapper::init_font(bool compress) } } + if (m_glyph_ranges == ImGui::GetIO().Fonts->GetGlyphRangesThai()) { + ImFontConfig fallback_cfg = cfg; + fallback_cfg.MergeMode = true; + static constexpr ImWchar celsius_range[] = { 0x2103, 0x2103, 0 }; + io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/HarmonyOS_Sans_SC_Regular.ttf").c_str(), m_font_size, &fallback_cfg, celsius_range); + } + bold_font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/" + font_name_bold).c_str(), m_font_size, &cfg, ranges.Data); if (bold_font == nullptr) { bold_font = io.Fonts->AddFontDefault(); if (bold_font == nullptr) { throw Slic3r::RuntimeError("ImGui: Could not load deafult font"); } } + if (m_glyph_ranges == ImGui::GetIO().Fonts->GetGlyphRangesThai()) { + ImFontConfig fallback_cfg = cfg; + fallback_cfg.MergeMode = true; + static constexpr ImWchar celsius_range[] = { 0x2103, 0x2103, 0 }; + io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/HarmonyOS_Sans_SC_Bold.ttf").c_str(), m_font_size, &fallback_cfg, celsius_range); + } + if (m_glyph_ranges == ImGui::GetIO().Fonts->GetGlyphRangesThai()) { default_font->Scale *= 1.25f; bold_font->Scale *= 1.25f;