-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gpui: Add text alignment #24090
gpui: Add text alignment #24090
Conversation
Thank you! |
This is cause by |
let mut glyph_origin = point( | ||
aligned_origin_x( | ||
origin, | ||
align_width.unwrap_or(layout.width), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here layout.width
is the actually text width, not the line width.
So if the text is "hello", the layout.width
be the width of the "hello".
window: &mut Window, | ||
cx: &mut App, | ||
) -> Result<()> { | ||
paint_line( | ||
origin, | ||
&self.layout.unwrapped_layout, | ||
line_height, | ||
align, | ||
self.layout.wrap_width, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whitespace_normal
can works, because of the wrap_width
have value.
This is by TextLayout to measured known_dimensions:
zed/crates/gpui/src/elements/text.rs
Line 287 in 1301c41
let wrap_width = if text_style.white_space == WhiteSpace::Normal { |
But if nowrap
mode, the wrap_width
is none.
Adds a text property for controlling left, center, or right text alignment.
#8792 should stay open since this doesn't add support for
justify
(which would require a much bigger change since this can just alter the origin of each line, but justify requires changing spacing, whereas justify requires changes to each platform's shaping code).Release Notes: