Add dpi font scale getter
parent
4ce6edae70
commit
4d5afc2e25
|
@ -56,7 +56,6 @@ class DpiAwareFont:
|
||||||
self._qfont = QtGui.QFont(name)
|
self._qfont = QtGui.QFont(name)
|
||||||
self._font_size: str = font_size
|
self._font_size: str = font_size
|
||||||
self._qfm = QtGui.QFontMetrics(self._qfont)
|
self._qfm = QtGui.QFontMetrics(self._qfont)
|
||||||
self._physical_dpi = None
|
|
||||||
self._font_inches: float = None
|
self._font_inches: float = None
|
||||||
self._screen = None
|
self._screen = None
|
||||||
|
|
||||||
|
@ -82,6 +81,10 @@ class DpiAwareFont:
|
||||||
def font(self):
|
def font(self):
|
||||||
return self._qfont
|
return self._qfont
|
||||||
|
|
||||||
|
def scale(self) -> float:
|
||||||
|
screen = self.screen
|
||||||
|
return screen.logicalDotsPerInch() / screen.physicalDotsPerInch()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def px_size(self) -> int:
|
def px_size(self) -> int:
|
||||||
return self._qfont.pixelSize()
|
return self._qfont.pixelSize()
|
||||||
|
@ -114,7 +117,7 @@ class DpiAwareFont:
|
||||||
# dpi is likely somewhat scaled down so use slightly larger font size
|
# dpi is likely somewhat scaled down so use slightly larger font size
|
||||||
if scale > 1 and self._font_size:
|
if scale > 1 and self._font_size:
|
||||||
# TODO: this denominator should probably be determined from
|
# 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)
|
inches = inches * (1 / scale) * (1 + 6/16)
|
||||||
dpi = mx_dpi
|
dpi = mx_dpi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue