Fixed text scale on retina displays.

This commit is contained in:
Leonardo Zide
2026-02-14 16:51:49 -08:00
parent 1e40f166ac
commit 069ed47ee9
7 changed files with 24 additions and 16 deletions
+2 -2
View File
@@ -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<int>(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
+6 -1
View File
@@ -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<int>(OverrideTool)];
}
float lcView::GetUIScale() const
{
return mWidget ? mWidget->GetDeviceScale() : 1.0f;
}
float lcView::GetOverlayScale() const
{
lcVector3 OverlayCenter;
+1
View File
@@ -264,6 +264,7 @@ public:
bool CloseFindReplaceDialog();
void ShowFindReplaceWidget(bool Replace);
float GetUIScale() const;
float GetOverlayScale() const;
lcVector3 GetMoveDirection(const lcVector3& Direction) const;
void UpdatePiecePreview();
+1 -1
View File
@@ -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);
}
+1 -1
View File
@@ -15,7 +15,6 @@ public:
QSize sizeHint() const override;
protected:
float GetDeviceScale() const
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
@@ -25,6 +24,7 @@ protected:
#endif
}
protected:
void initializeGL() override;
void resizeGL(int Width, int Height) override;
void paintGL() override;
+10 -8
View File
@@ -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++;
}
+1 -1
View File
@@ -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;