Skip to content

[RTL] Fix RichTextLabel vertical alignment calculation regression - #122401

Open
AgZ47 wants to merge 2 commits into
godotengine:masterfrom
AgZ47:vertical-alignment-fix
Open

[RTL] Fix RichTextLabel vertical alignment calculation regression#122401
AgZ47 wants to merge 2 commits into
godotengine:masterfrom
AgZ47:vertical-alignment-fix

Conversation

@AgZ47

@AgZ47 AgZ47 commented Aug 14, 2026

Copy link
Copy Markdown

What problem(s) does this PR solve?

Additional information

Commit facdd8e added a zero-width space (U+200B) to lines in RichTextLabel::_shape_line() to ensure uniform line height with fallback fonts. However, appending U+200B causes TextServer to append an extra glyph run that inflates text_buf->get_size().y by 3px for standard fonts. This inflated total height causes VERTICAL_ALIGNMENT_BOTTOM to be offset by 3px and VERTICAL_ALIGNMENT_CENTER to be offset by ~1.5px.

I have used AI to help me as a first time contributor, helped me with some of the git commands and in finding the right file locations.

@AgZ47
AgZ47 requested a review from a team as a code owner August 14, 2026 07:30

@bruvzg bruvzg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will reintroduce a bunch of other issues this code fixed.

@AgZ47

AgZ47 commented Aug 14, 2026

Copy link
Copy Markdown
Author

Would restricting the 0x200B insertion to only when the line has no text glyphs be the right direction to preserve the fallback font fix without inflating populated lines?

@AgZ47

AgZ47 commented Aug 14, 2026

Copy link
Copy Markdown
Author

I've updated the PR to guard the 0x200B insertion with txt.is_empty():

  • Empty / baseline lines: Still receive 0x200B so fallback fonts and blank lines retain their full baseline height (verified with multi-line spacing preserving the expected 22px gap).
  • Populated text lines: Skip 0x200B so text_buf metrics are not artificially inflated, restoring pixel-perfect 0px alignment for both Center and Bottom vertical alignments.

@AThousandShips AThousandShips added bug needs work needs testing regression topic:gui cherrypick:4.7 Considered for cherry-picking into a future 4.7.x release labels Aug 14, 2026
@AThousandShips AThousandShips added this to the 4.8 milestone Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug cherrypick:4.7 Considered for cherry-picking into a future 4.7.x release needs testing needs work regression topic:gui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants