From d603ee689f0e3fdcfa3230b3d75cdce6c5af05c1 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 4 Apr 2019 13:53:19 +0200 Subject: Widget style: Use per-screen DPI in QStyleHelper::dpiScaled() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pass the style option to dpiScaled() in order to get the correct screen DPI. The style option contains the font, which again contains the current DPI value. Add QFontMetrics::fontDpi() accessors to get the DPI from the QFont. This DPI will/should be updated on screen change. Replace hardcoded Q_OS_MAC DPI with hardcoded base DPI. This makes per-screen DPI testable on macOS, too. Task-number: QTBUG-45055 Change-Id: I75f8b37d45eb50c3334b46b8469a546d29712f1b Reviewed-by: Morten Johan Sørvig --- src/gui/text/qfontmetrics.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/gui/text/qfontmetrics.cpp') diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index c8dc8d676e..c85dd4e1e3 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -1036,8 +1036,15 @@ int QFontMetrics::lineWidth() const return qRound(engine->lineThickness()); } +/*! + \since 5.14 - + Returns the font DPI. +*/ +qreal QFontMetrics::fontDpi() const +{ + return d->dpi; +} /***************************************************************************** QFontMetricsF member functions @@ -1913,4 +1920,14 @@ qreal QFontMetricsF::lineWidth() const return engine->lineThickness().toReal(); } +/*! + \since 5.14 + + Returns the font DPI. +*/ +qreal QFontMetricsF::fontDpi() const +{ + return d->dpi; +} + QT_END_NAMESPACE -- cgit v1.2.3