From 67721a5832f32134a4f63bb84d771b4bb218d649 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 23 Jul 2021 12:19:07 -0400 Subject: [PATCH] Add dpi font scale getter --- piker/ui/_style.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/piker/ui/_style.py b/piker/ui/_style.py index 90f8a898..2b73b0df 100644 --- a/piker/ui/_style.py +++ b/piker/ui/_style.py @@ -56,7 +56,6 @@ class DpiAwareFont: self._qfont = QtGui.QFont(name) self._font_size: str = font_size self._qfm = QtGui.QFontMetrics(self._qfont) - self._physical_dpi = None self._font_inches: float = None self._screen = None @@ -82,6 +81,10 @@ class DpiAwareFont: def font(self): return self._qfont + def scale(self) -> float: + screen = self.screen + return screen.logicalDotsPerInch() / screen.physicalDotsPerInch() + @property def px_size(self) -> int: return self._qfont.pixelSize() @@ -114,7 +117,7 @@ class DpiAwareFont: # dpi is likely somewhat scaled down so use slightly larger font size if scale > 1 and self._font_size: # TODO: this denominator should probably be determined from - # relative aspect rations or something? + # relative aspect ratios or something? inches = inches * (1 / scale) * (1 + 6/16) dpi = mx_dpi