From ff1fb07b2d2241ed760e27ef9eb9f62deea6ce32 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 18 Feb 2015 14:04:02 -0800 Subject: [PATCH] Add high-dpi support to scaleWidgetFontSizes --- interface/src/UIUtil.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/interface/src/UIUtil.cpp b/interface/src/UIUtil.cpp index 5d01ddaa3d..27f40539a4 100644 --- a/interface/src/UIUtil.cpp +++ b/interface/src/UIUtil.cpp @@ -51,7 +51,14 @@ void UIUtil::scaleWidgetFontSizes(QWidget* widget) { const float NATIVE_DPI = 96.0f; #endif - float fontScale = (BASE_DPI / NATIVE_DPI) * (glCanvas->logicalDpiX() / NATIVE_DPI); + // Scale fonts based on the native dpi. On Windows, where the native DPI is 96, + // the scale will be: 72.0 / 96.0 = 0.75 + float fontScale = (BASE_DPI / NATIVE_DPI); + + // Scale the font further by the system's DPI settings. If using a 2x high-dpi screen + // on Windows, for example, the font will be further scaled by: 192.0 / 96.0 = 2.0 + // This would give a final scale of: 0.75 * 2.0 = 1.5 + fontScale *= (glCanvas->logicalDpiX() / NATIVE_DPI); internalScaleWidgetFontSizes(widget, fontScale); }