diff options
author | Adam Treat <adam.treat@qt.io> | 2018-02-08 23:14:08 -0500 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@qt.io> | 2018-02-09 11:17:04 +0000 |
commit | 6bf411a7f89751142a762b39408c79c436906c75 (patch) | |
tree | 58dd013b57af7283f3c3d78adceffdde6bafadfb | |
parent | 36af0b46e3ff8886c1c9be6f5e656a5dd61dda1e (diff) |
Fix scaling of fonts so that it is portable across screens
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ä <antti.maatta@qt.io>
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Pasi Keränen <pasi.keranen@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r-- | src/Runtime/Source/Qt3DSRuntimeRender/Source/Qt3DSQtTextRenderer.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
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)); } |