diff --git a/piker/ui/_style.py b/piker/ui/_style.py index 196d6fd8..21fb3e74 100644 --- a/piker/ui/_style.py +++ b/piker/ui/_style.py @@ -182,7 +182,7 @@ class DpiAwareFont: # always going to hit that error in range mapping from inches: # float to px size: int. self._font_inches = inches - font_size = math.floor(inches * dpi) + font_size = math.floor(inches * pdpi) log.debug( f"screen:{screen.name()}\n" diff --git a/tests/test_dpi_font.py b/tests/test_dpi_font.py new file mode 100644 index 00000000..04decfcf --- /dev/null +++ b/tests/test_dpi_font.py @@ -0,0 +1,18 @@ +from PyQt6 import QtGui +from piker.ui._style import DpiAwareFont + +class MockScreen: + def physicalDotsPerInch(self): + return 169 # example HiDPI + def logicalDotsPerInch(self): + return 96 + def name(self): + return "MockScreen" + +# create font instance +font = DpiAwareFont() + +# pass the mock screen to configure_to_dpi +font.configure_to_dpi(screen=MockScreen()) + +print("Computed pixel size:", font.px_size)