fix DpiAwareFont default size calculation #48

Open
momo wants to merge 1 commits from dpi-font-auto-calc into how_to_show_ur_pp
Collaborator
  • Previously, configure_to_dpi() used logical DPI or _font_sizes presets, which produced fonts (~8px) on high-DPI displays.
  • Changed font size calculation to use physicalDotsPerInch() of the screen: font_size = round(inches * pdpi)
  • Ensures consistent, readable default font size based on actual screen DPI
- Previously, configure_to_dpi() used logical DPI or _font_sizes presets, which produced fonts (~8px) on high-DPI displays. - Changed font size calculation to use physicalDotsPerInch() of the screen: font_size = round(inches * pdpi) - Ensures consistent, readable default font size based on actual screen DPI
momo added 1 commit 2025-12-03 21:56:57 +00:00
momo requested review from goodboy 2025-12-03 21:57:08 +00:00
goodboy reviewed 2025-12-03 22:10:29 +00:00
@ -77,6 +77,9 @@ dependencies = [
"trio-typing>=0.10.0",
"numba>=0.61.0",
"pyvnc",
"pyqt6>=6.8.0",

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

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

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.

> 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.
goodboy reviewed 2025-12-03 22:14:29 +00:00
@ -0,0 +15,4 @@
# pass the mock screen to configure_to_dpi
font.configure_to_dpi(screen=MockScreen())
print("Computed pixel size:", font.px_size)

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

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
goodboy reviewed 2025-12-03 22:19:22 +00:00
@ -183,3 +183,3 @@
# float to px size: int.
self._font_inches = inches
font_size = math.floor(inches * dpi)
font_size = math.floor(inches * pdpi)

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.

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.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
You can also view command line instructions.

Step 1:

From your project repository, check out a new branch and test the changes.
git checkout -b dpi-font-auto-calc how_to_show_ur_pp
git pull origin dpi-font-auto-calc

Step 2:

Merge the changes and update on Gitea.
git checkout how_to_show_ur_pp
git merge --no-ff dpi-font-auto-calc
git push origin how_to_show_ur_pp
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: pikers/piker#48
There is no content yet.