Add dpi font scale getter

ordermodepps_backup
Tyler Goodlet 2021-07-23 12:19:07 -04:00
parent 9887b14518
commit 67721a5832
1 changed files with 5 additions and 2 deletions

View File

@ -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