From 6bf411a7f89751142a762b39408c79c436906c75 Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Thu, 8 Feb 2018 23:14:08 -0500 Subject: Fix scaling of fonts so that it is portable across screens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rendering fonts on screens with different logical dpi was resulting in inconsistent sizes of fonts in studio projects. This fixes an issue I was seeing where my Linux host was displaying fonts at seemingly normal size, but my QNX target with a different logical dpi had abnormally large fonts. With this change, the rendering of the fonts looks identical. Change-Id: Ide4f0b507e5839808b5ea185fe346613a54264a2 Reviewed-by: Antti Määttä Reviewed-by: Janne Koskinen Reviewed-by: Miikka Heikkinen Reviewed-by: Pasi Keränen Reviewed-by: Tomi Korpipää --- src/Runtime/Source/Qt3DSRuntimeRender/Source/Qt3DSQtTextRenderer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Runtime/Source/Qt3DSRuntimeRender/Source/Qt3DSQtTextRenderer.cpp b/src/Runtime/Source/Qt3DSRuntimeRender/Source/Qt3DSQtTextRenderer.cpp index 5e5157aa..aad51286 100644 --- a/src/Runtime/Source/Qt3DSRuntimeRender/Source/Qt3DSQtTextRenderer.cpp +++ b/src/Runtime/Source/Qt3DSRuntimeRender/Source/Qt3DSQtTextRenderer.cpp @@ -397,7 +397,10 @@ struct Qt3DSQtTextRenderer : public ITextRenderer void updateFontInfo(FontInfo &fi, const STextRenderInfo &inText, QT3DSF32 inTextScaleFactor = 1.0f) { - fi.font.setPointSizeF(inText.m_FontSize * inTextScaleFactor); + static qreal dpi = + QGuiApplication::primaryScreen()->logicalDotsPerInch(); + qreal point = inText.m_FontSize * 72 / dpi; + fi.font.setPointSizeF(point * inTextScaleFactor); fi.font.setLetterSpacing(QFont::AbsoluteSpacing, qreal(inText.m_Tracking)); } -- cgit v1.2.3