From 2b6800b026d9f36f9ad6434aabc3962ce0236db4 Mon Sep 17 00:00:00 2001 From: Leland Lucius Date: Fri, 5 Jan 2024 22:36:18 -0600 Subject: [PATCH] Only use modified scaling on Windows And only if the system's scaling factor is greater than 300%. --- src/slic3r/GUI/GLCanvas3D.cpp | 12 +++++++++++- src/slic3r/GUI/ImGuiWrapper.cpp | 11 +++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 81f6acc22..313c87afb 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -6428,7 +6428,17 @@ void GLCanvas3D::_resize(unsigned int w, unsigned int h) m_last_w = w; m_last_h = h; - const float font_size = 1.0f * wxGetApp().em_unit(); + float font_size = wxGetApp().em_unit(); + +#ifdef _WIN32 + // On Windows, if manually scaled here, rendering issues can occur when the system's Display + // scaling is greater than 300% as the font's size gets to be to large. So, use imgui font + // scaling instead (see: ImGuiWrapper::init_font() and issue #3401) + font_size *= (font_size > 30.0f) ? 1.0f : 1.5f; +#else + font_size *= 1.5f; +#endif + #if ENABLE_RETINA_GL imgui->set_scaling(font_size, 1.0f, m_retina_helper->get_scale_factor()); #else diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp index 416d3365e..aafc93f1b 100644 --- a/src/slic3r/GUI/ImGuiWrapper.cpp +++ b/src/slic3r/GUI/ImGuiWrapper.cpp @@ -2110,7 +2110,6 @@ void ImGuiWrapper::init_font(bool compress) throw Slic3r::RuntimeError("ImGui: Could not load deafult font"); } } - default_font->Scale = 1.5f; if (m_is_korean) bold_font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/" + "NotoSansKR-Bold.ttf").c_str(), m_font_size, &cfg, ranges.Data); @@ -2120,7 +2119,15 @@ void ImGuiWrapper::init_font(bool compress) bold_font = io.Fonts->AddFontDefault(); if (bold_font == nullptr) { throw Slic3r::RuntimeError("ImGui: Could not load deafult font"); } } - bold_font->Scale = 1.5f; + +#ifdef _WIN32 + // Render the text a bit larger (see GLCanvas3D::_resize() and issue #3401), but only if the scale factor + // for the Display is greater than 300%. + if (wxGetApp().em_unit() > 30) { + default_font->Scale = 1.5f; + bold_font->Scale = 1.5f; + } +#endif #ifdef __APPLE__ ImFontConfig config;