gpui: Add text alignment (#24090)

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:

- N/A
This commit is contained in:
someone13574
2025-02-02 09:15:12 -08:00
committed by GitHub
parent 4a65315f3b
commit aa42e206b3
5 changed files with 112 additions and 6 deletions
+3 -1
View File
@@ -390,8 +390,10 @@ impl TextLayout {
let line_height = element_state.line_height;
let mut line_origin = bounds.origin;
let text_style = window.text_style();
for line in &element_state.lines {
line.paint(line_origin, line_height, window, cx).log_err();
line.paint(line_origin, line_height, text_style.text_align, window, cx)
.log_err();
line_origin.y += line.size(line_height).height;
}
}