Skip to content

Fix: TextFormat::valign not applied correctly with custom line_height#8030

Open
rustbasic wants to merge 1 commit intoemilk:mainfrom
rustbasic:patch177
Open

Fix: TextFormat::valign not applied correctly with custom line_height#8030
rustbasic wants to merge 1 commit intoemilk:mainfrom
rustbasic:patch177

Conversation

@rustbasic
Copy link
Copy Markdown
Contributor

Fix: TextFormat::valign not applied correctly with custom line_height

This PR resolves an issue where TextFormat::valign (vertical alignment) was not correctly applied when TextFormat::line_height was explicitly set, especially when it matched the max_row_height.

Problem:
The vertical positioning logic in galley_from_rows() calculated valign based on the difference (max_row_height - glyph.line_height). When glyph.line_height was explicitly set to a larger value (e.g., row_height + 6.0) and became the max_row_height for the row, this difference became zero. As a result, valign had no effect, and glyphs consistently appeared top-aligned within the allocated line space.

Solution:
The valign calculation is now updated to use glyph.font_face_height instead of glyph.line_height. This correctly applies vertical alignment to the glyph's actual visual content within the max_row_height, ensuring Align::Center and Align::Max (Bottom) settings function as intended for customized line heights.

Refactor vertical alignment calculation for glyph positioning.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 26, 2026

Preview available at https://egui-pr-preview.github.io/pr/8030-patch177
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

View snapshot changes at kitdiff

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