fix DpiAwareFont default size calculation

dpi-font-auto-calc
di1ara 2025-12-03 16:50:10 -05:00
parent 9e82a46c0b
commit 4b6bd55df4
2 changed files with 19 additions and 1 deletions

View File

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

View File

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