Skip to content

Use QTextLayout for WrappedText.heightForWidth so wrapped text never clips during paint - #80

Merged
trissim merged 1 commit into
mainfrom
fix/wrapped-text-qtextlayout-height
Nov 27, 2026
Merged

trissim merged 1 commit into
mainfrom
fix/wrapped-text-qtextlayout-height

Conversation

@trissim

@trissim trissim commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

WrappedText.text_rect measured wrapped height with QFontMetrics.boundingRect while FittedText.paintEvent drew with QTextLayout. At narrow widths with punctuation-heavy text (e.g. QtGoalBar at 207px with installed glyph fonts), boundingRect returned 136px (8 lines) while QTextLayout wrapped to 153px (9 lines), clipping the first and last lines by 8.5px each under AlignVCenter (IDEN-5: two engines for one height).

Hoisted FittedText._layout_text(text, width) so both _prepare_text_layouts and WrappedText.text_rect share one QTextLayout authority. Verified with pytest tests/test_fitted_text.py (3 passed in 0.05s, including new no-clipping regression test).

@trissim
trissim merged commit 10f4cf6 into main Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant