fix DpiAwareFont default size calculation #48
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -77,6 +77,9 @@ dependencies = [
|
|||
"trio-typing>=0.10.0",
|
||||
"numba>=0.61.0",
|
||||
"pyvnc",
|
||||
"pyqt6>=6.8.0",
|
||||
|
goodboy
commented
Review
@momo let’s not add these deps to the core set and instead add them to the i also wonder if we might want to even consider making a new I think for now tossing it into Maybe do a quick check for that in their docs too? @momo let's not add these deps to the core set and instead add them to the `dev` set since we only need them for running this new test suite 🙏
i also wonder if we might want to even consider making a new `testing = []` dependency group eventually?
I think for now tossing it into `dev` is sufficient. Also not sure if `uv` has a way for deps-groups to depend on others?
Maybe do a quick check for that in their docs too?
goodboy
commented
Review
looks like nope says gemini Xp
> Also not sure if uv has a way for deps-groups to depend on others?
looks like nope says gemini Xp
> uv does not currently support nesting dependency groups directly within the pyproject.toml file in a way that one group explicitly "includes" another in the same manner as, for example, extras can be defined to include other extras.
However, you can achieve a similar effect by managing your uv commands to include multiple groups when performing operations like sync or pip install.
|
||||
"pyqtgraph>=0.12.3",
|
||||
"qdarkstyle>=3.2.3",
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
goodboy
commented
Review
woo nice! this is a good start but we should wrap this in a https://docs.pytest.org/en/stable/getting-started.html#create-your-first-test woo nice!
this is a good start but we should wrap this in a `pytest` test-fn (function) so that it will report like the rest of the test suites ;)
https://docs.pytest.org/en/stable/getting-started.html#create-your-first-test
|
||||
6
uv.lock
|
|
@ -811,7 +811,10 @@ dependencies = [
|
|||
{ name = "polars-fuzzy-match" },
|
||||
{ name = "pyarrow" },
|
||||
{ name = "pygments" },
|
||||
{ name = "pyqt6" },
|
||||
{ name = "pyqtgraph" },
|
||||
{ name = "pyvnc" },
|
||||
{ name = "qdarkstyle" },
|
||||
{ name = "rapidfuzz" },
|
||||
{ name = "rich" },
|
||||
{ name = "tomli" },
|
||||
|
|
@ -866,9 +869,12 @@ requires-dist = [
|
|||
{ name = "polars-fuzzy-match", specifier = ">=0.1.5" },
|
||||
{ name = "pyarrow", specifier = ">=18.0.0" },
|
||||
{ name = "pygments", specifier = ">=2.16.1,<3.0.0" },
|
||||
{ name = "pyqt6", specifier = ">=6.8.0" },
|
||||
{ name = "pyqt6", marker = "extra == 'uis'", specifier = ">=6.7.0,<7.0.0" },
|
||||
{ name = "pyqtgraph", git = "https://github.com/pikers/pyqtgraph.git" },
|
||||
{ name = "pyqtgraph", marker = "extra == 'uis'", git = "https://github.com/pikers/pyqtgraph.git" },
|
||||
{ name = "pyvnc", git = "https://github.com/regulad/pyvnc.git" },
|
||||
{ name = "qdarkstyle", specifier = ">=3.2.3" },
|
||||
{ name = "qdarkstyle", marker = "extra == 'uis'", specifier = ">=3.0.2,<4.0.0" },
|
||||
{ name = "rapidfuzz", specifier = ">=3.5.2,<4.0.0" },
|
||||
{ name = "rapidfuzz", marker = "extra == 'uis'", specifier = ">=3.2.0,<4.0.0" },
|
||||
|
|
|
|||
Yeah, it’s funny that this worked for you since the non-physical DPI is supposed to be the one that “you perceive on screen given DE scaling compensation” ..
so it does indeed look like we might always want/need to do from-scratch analysis of every display’s reported DPI and totally ignore OS-dependent metrix/reports including those with supposed auto-scaling.