From 069ed47ee9b151d5e2c6620ad77f5a92811ee0e2 Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Sat, 14 Feb 2026 16:51:49 -0800 Subject: [PATCH] Fixed text scale on retina displays. --- common/lc_profile.cpp | 4 ++-- common/lc_view.cpp | 7 ++++++- common/lc_view.h | 3 ++- common/lc_viewmanipulator.cpp | 2 +- common/lc_viewwidget.h | 4 ++-- common/texfont.cpp | 18 ++++++++++-------- common/texfont.h | 2 +- 7 files changed, 24 insertions(+), 16 deletions(-) diff --git a/common/lc_profile.cpp b/common/lc_profile.cpp index 53770c94..af149607 100644 --- a/common/lc_profile.cpp +++ b/common/lc_profile.cpp @@ -72,8 +72,8 @@ static lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] = lcProfileEntry("Settings", "GradientColorBottom", LC_RGB(49, 52, 55)), // LC_PROFILE_GRADIENT_COLOR_BOTTOM lcProfileEntry("Settings", "DrawAxes", 0), // LC_PROFILE_DRAW_AXES lcProfileEntry("Settings", "DrawAxesLocation", static_cast(lcAxisIconLocation::BottomLeft)), // LC_PROFILE_DRAW_AXES_LOCATION - lcProfileEntry("Settings", "AxesColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_AXES_COLOR - lcProfileEntry("Settings", "TextColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_TEXT_COLOR + lcProfileEntry("Settings", "AxesColor", LC_RGBA(160, 160, 160, 255)), // LC_PROFILE_AXES_COLOR + lcProfileEntry("Settings", "TextColor", LC_RGBA(160, 160, 160, 255)), // LC_PROFILE_TEXT_COLOR lcProfileEntry("Settings", "MarqueeBorderColor", LC_RGBA(64, 64, 255, 255)), // LC_PROFILE_MARQUEE_BORDER_COLOR lcProfileEntry("Settings", "MarqueeFillColor", LC_RGBA(64, 64, 255, 64)), // LC_PROFILE_MARQUEE_FILL_COLOR lcProfileEntry("Settings", "OverlayColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_OVERLAY_COLOR diff --git a/common/lc_view.cpp b/common/lc_view.cpp index 59e27954..aa8ef01a 100644 --- a/common/lc_view.cpp +++ b/common/lc_view.cpp @@ -1181,7 +1181,7 @@ void lcView::DrawViewport() const mContext->EnableColorBlend(true); - gTexFont.PrintText(mContext, 3.0f, (float)mHeight - 1.0f - 6.0f, 0.0f, CameraName.toLatin1().constData()); + gTexFont.PrintText(mContext, 3.0f, (float)mHeight - 1.0f - 6.0f, 0.0f, GetUIScale(), CameraName.toLatin1().constData()); mContext->EnableColorBlend(false); } @@ -1698,6 +1698,11 @@ lcTrackTool lcView::GetOverrideTrackTool(Qt::MouseButton Button) const return TrackToolFromTool[static_cast(OverrideTool)]; } +float lcView::GetUIScale() const +{ + return mWidget ? mWidget->GetDeviceScale() : 1.0f; +} + float lcView::GetOverlayScale() const { lcVector3 OverlayCenter; diff --git a/common/lc_view.h b/common/lc_view.h index 700a5ebf..4f087bc6 100644 --- a/common/lc_view.h +++ b/common/lc_view.h @@ -263,7 +263,8 @@ public: void ShowContextMenu() const; bool CloseFindReplaceDialog(); void ShowFindReplaceWidget(bool Replace); - + + float GetUIScale() const; float GetOverlayScale() const; lcVector3 GetMoveDirection(const lcVector3& Direction) const; void UpdatePiecePreview(); diff --git a/common/lc_viewmanipulator.cpp b/common/lc_viewmanipulator.cpp index 2a154162..6b5f83f3 100644 --- a/common/lc_viewmanipulator.cpp +++ b/common/lc_viewmanipulator.cpp @@ -896,7 +896,7 @@ void lcViewManipulator::DrawRotate(lcTrackButton TrackButton, lcTrackTool TrackT gTexFont.GetStringDimensions(&cx, &cy, buf); Context->SetColor(0.8f, 0.8f, 0.0f, 1.0f); - gTexFont.PrintText(Context, ScreenPos[0] - (cx / 2), ScreenPos[1] + (cy / 2), 0.0f, buf); + gTexFont.PrintText(Context, ScreenPos[0] - (cx / 2), ScreenPos[1] + (cy / 2), 0.0f, mView->GetUIScale(), buf); Context->EnableColorBlend(false); } diff --git a/common/lc_viewwidget.h b/common/lc_viewwidget.h index d5473189..ab905b5d 100644 --- a/common/lc_viewwidget.h +++ b/common/lc_viewwidget.h @@ -15,7 +15,6 @@ public: QSize sizeHint() const override; -protected: float GetDeviceScale() const { #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) @@ -24,7 +23,8 @@ protected: return devicePixelRatio(); #endif } - + +protected: void initializeGL() override; void resizeGL(int Width, int Height) override; void paintGL() override; diff --git a/common/texfont.cpp b/common/texfont.cpp index a05a9183..97d740fd 100644 --- a/common/texfont.cpp +++ b/common/texfont.cpp @@ -162,7 +162,7 @@ void TexFont::GetStringDimensions(int* cx, int* cy, const char* Text) const } } -void TexFont::PrintText(lcContext* Context, float Left, float Top, float Z, const char* Text) const +void TexFont::PrintText(lcContext* Context, float Left, float Top, float Z, float Scale, const char* Text) const { const size_t Length = strlen(Text); @@ -175,6 +175,8 @@ void TexFont::PrintText(lcContext* Context, float Left, float Top, float Z, cons while (*Text) { int ch = *Text; + float Right = Left + mGlyphs[ch].width * Scale; + float Bottom = Top - mFontHeight * Scale; *CurVert++ = Left; *CurVert++ = Top; @@ -183,24 +185,24 @@ void TexFont::PrintText(lcContext* Context, float Left, float Top, float Z, cons *CurVert++ = mGlyphs[ch].top; *CurVert++ = Left; - *CurVert++ = Top - mFontHeight; + *CurVert++ = Bottom; *CurVert++ = Z; *CurVert++ = mGlyphs[ch].left; *CurVert++ = mGlyphs[ch].bottom; - *CurVert++ = Left + mGlyphs[ch].width; - *CurVert++ = Top - mFontHeight; + *CurVert++ = Right; + *CurVert++ = Bottom; *CurVert++ = Z; *CurVert++ = mGlyphs[ch].right; *CurVert++ = mGlyphs[ch].bottom; - *CurVert++ = Left + mGlyphs[ch].width; - *CurVert++ = Top - mFontHeight; + *CurVert++ = Right; + *CurVert++ = Bottom; *CurVert++ = Z; *CurVert++ = mGlyphs[ch].right; *CurVert++ = mGlyphs[ch].bottom; - *CurVert++ = Left + mGlyphs[ch].width; + *CurVert++ = Right; *CurVert++ = Top; *CurVert++ = Z; *CurVert++ = mGlyphs[ch].right; @@ -212,7 +214,7 @@ void TexFont::PrintText(lcContext* Context, float Left, float Top, float Z, cons *CurVert++ = mGlyphs[ch].left; *CurVert++ = mGlyphs[ch].top; - Left += mGlyphs[ch].width; + Left = Right; Text++; } diff --git a/common/texfont.h b/common/texfont.h index 9dddf466..297d034f 100644 --- a/common/texfont.h +++ b/common/texfont.h @@ -18,7 +18,7 @@ public: bool Initialize(lcContext* Context); void Reset(); - void PrintText(lcContext* Context, float Left, float Top, float Z, const char* Text) const; + void PrintText(lcContext* Context, float Left, float Top, float Z, float Scale, const char* Text) const; void GetTriangles(const lcMatrix44& Transform, const char* Text, float* Buffer) const; void GetGlyphTriangles(float Left, float Top, float Z, int Glyph, float* Buffer) const; void GetStringDimensions(int* cx, int* cy, const char* Text) const;