Merge pull request #3271 from lllucius/master

Fix garbled text when display scalling > 300%
This commit is contained in:
LiZ-Li-BBL 2024-01-08 12:13:33 +08:00 committed by GitHub
commit 4d15a586b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -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.5f * 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

View File

@ -2120,6 +2120,15 @@ void ImGuiWrapper::init_font(bool compress)
if (bold_font == nullptr) { throw Slic3r::RuntimeError("ImGui: Could not load deafult font"); }
}
#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;
config.MergeMode = true;