Skip to content

fix(qt): handle pixel-sized fonts when scaling widgets#7465

Draft
thepastaclaw wants to merge 2 commits into
dashpay:developfrom
thepastaclaw:tracker-1251
Draft

fix(qt): handle pixel-sized fonts when scaling widgets#7465
thepastaclaw wants to merge 2 commits into
dashpay:developfrom
thepastaclaw:tracker-1251

Conversation

@thepastaclaw

Copy link
Copy Markdown

Pixel-sized font scaling fix

Issue being fixed or feature implemented

GUIUtil::updateFonts() assumed every widget font had a positive point size. The recovery-phrase dialog stylesheet uses pixel-sized fonts, for which Qt reports an invalid point size, so an asynchronous global font refresh could abort while the dialog was open. This caused the original macOS report in #7281 and the cross-platform recurrence in #7464.

Fixes #7281.
Fixes #7464.

Supersedes the earlier closed draft #7315, which GitHub would not reopen after the branch was rebased onto current develop.

What was done?

  • Convert valid pixel-sized widget fonts to point sizes using the widget's logical DPI before applying the existing scaling path.
  • Skip widgets when Qt provides neither a valid point size nor a safely convertible pixel size.
  • Preserve fractional point sizes in the per-widget cache.
  • Add a focused Qt regression test covering a pixel-sized font passed through GUIUtil::updateFonts().

How Has This Been Tested?

  • Built qt/libbitcoinqt.a and test_dash_qt against current develop.
  • ./src/qt/test/test_dash-qt passes with the default minimal platform. On macOS, the focused font-test body is skipped under minimal, matching the existing AppTests platform limitation.
  • QT_QPA_PLATFORM=cocoa ./src/qt/test/test_dash-qt exercises and passes FontTests; the later full AppTests suite cannot run to completion in this headless macOS environment because Cocoa pasteboard initialization aborts.
  • git diff --check upstream/develop...HEAD passes.
  • Independent pre-PR code-review gate passes after target-branch integration validation.

Breaking Changes

None.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation, where applicable
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@thepastaclaw

Copy link
Copy Markdown
Author

The linux64_ubsan-test / Test source failure is unrelated to this PR, so the branch is proper as-is and has been left untouched.

The failing test is feature_llmq_connections.py, which timed out waiting for DKG phase 2 / receivedContributions on all three in-job attempts. This PR changes only Qt font-scaling and Qt unit-test files; it does not change the functional test, its framework, or LLMQ code. The exact develop base passed the same UBSan test in 82 seconds, and this PR's normal linux64-test job passed as well.

Filed #7466 with the failure logs and reproduction evidence. No commit, push, rebase, or CI retrigger is appropriate for this PR.

@thepastaclaw

thepastaclaw commented Jul 21, 2026

Copy link
Copy Markdown
Author

✅ Final review complete — no blockers (commit aa68ce3)

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Codex + Sonnet

The pixel-sized font fix correctly converts pixels to points using the widget's logical DPI, handles invalid sizes safely, and has focused Qt regression coverage. The new Dash-specific test files are not yet registered for Dash cppcheck analysis, and the conversion branch contains one harmless redundant assignment.

Review provenance

  • Codex reviewers: gpt-5.6-sol — general (completed), gpt-5.6-sol — dash-core-commit-history (completed)
  • Verifier: gpt-5.6-sol — final-verifier (fallback)
  • Sonnet reviewers: claude-sonnet-5 — general (failed), claude-sonnet-5 — dash-core-commit-history (failed), claude-sonnet-5 — general (completed), claude-sonnet-5 — dash-core-commit-history (completed)

🟡 1 suggestion(s) | 💬 1 nitpick(s)

1 additional finding(s) omitted (not in diff).

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `test/util/data/non-backported.txt`:
- [SUGGESTION] test/util/data/non-backported.txt:38: Register the new font tests for Dash-specific cppcheck
  The newly added `src/qt/test/fonttests.cpp` and `src/qt/test/fonttests.h` files have no upstream Bitcoin Core counterpart, but no pattern in this registry matches them. `test/lint/lint-cppcheck-dash.py` constructs its complete input set from these patterns, so both files are currently omitted from Dash-specific static analysis. Add the test files alongside the existing `guiutil_font.*` entry.

Comment thread src/qt/guiutil_font.cpp Outdated
Stylesheets may set font-size in px, making pointSizeF() report -1 and
tripping assert(font.pointSize() > 0) in updateFonts(). Convert pixel
sizes to points when DPI is valid, otherwise skip the widget so invalid
DPI cannot divide by zero.

Fixes recovery-dialog / pixel-font crashes tracked in dashpay#7281/dashpay#7464.
Add FontTests that applies a pixel-sized font (recovery-dialog failure
mode) and asserts GUIUtil::updateFonts() no longer aborts and yields a
positive point size. Include the public API via guiutil.h after the
guiutil_font.h inline. Run FontTests before AppTests so cocoa can
exercise the regression path without full GUI startup.
@thepastaclaw

Copy link
Copy Markdown
Author

Addressed the current review findings in the existing clean two-commit stack:

  • 0c9e3717545 removes the redundant intermediate setPointSizeF() assignment from the pixel-size conversion path.
  • aa68ce33d12 registers src/qt/test/fonttests.* in test/util/data/non-backported.txt so Dash cppcheck covers the new tests.

Validation: python3 test/lint/lint-cppcheck-dash.py, git diff --check upstream/develop...HEAD, clean worktree, and both rewritten commits' GPG signatures verified.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Codex + Sonnet

Both carried-forward findings are resolved at the exact current head: the Dash-specific font tests are registered for cppcheck, and the redundant point-size assignment has been removed. Independent review of the rewritten PR stack and the incremental delta found no new in-scope issues; the pixel-to-point conversion handles invalid sizes safely and has focused Qt regression coverage.

GitHub does not allow PastaClaw to approve their own PR, so the canonical APPROVE verdict is transported as a COMMENT review.

Review provenance

  • Codex reviewers: gpt-5.6-sol — general (completed), gpt-5.6-sol — dash-core-commit-history (completed)
  • Verifier: gpt-5.6-sol — final-verifier (fallback)
  • Sonnet reviewers: claude-sonnet-5 — general (failed), claude-sonnet-5 — dash-core-commit-history (failed), claude-sonnet-5 — general (completed), claude-sonnet-5 — dash-core-commit-history (failed), claude-sonnet-5 — dash-core-commit-history (completed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant