File tree 2 files changed +11
-15
lines changed
2 files changed +11
-15
lines changed Original file line number Diff line number Diff line change @@ -15,15 +15,7 @@ pub(crate) fn align<B: Brush>(
15
15
) {
16
16
// Whether the text base direction is right-to-left.
17
17
let is_rtl = layout. base_level & 1 == 1 ;
18
- let alignment_width = alignment_width. unwrap_or_else ( || {
19
- let max_line_length = layout
20
- . lines
21
- . iter ( )
22
- . map ( |line| line. metrics . advance )
23
- . max_by ( f32:: total_cmp)
24
- . unwrap_or ( 0.0 ) ;
25
- max_line_length. min ( max_line_length)
26
- } ) ;
18
+ let alignment_width = alignment_width. unwrap_or_else ( || layout. full_width ) ;
27
19
28
20
// Apply alignment to line items
29
21
for line in & mut layout. lines {
Original file line number Diff line number Diff line change @@ -156,12 +156,16 @@ impl<B: Brush> Layout<B> {
156
156
. break_remaining ( max_advance. unwrap_or ( f32:: MAX ) ) ;
157
157
}
158
158
159
- // Apply to alignment to layout relative to the specified container width. If container_width is not
160
- // specified then the max line length is used.
161
- //
162
- // If `align_when_overflowing` is set to `true` then `Center` and `End` alignment will apply even if
163
- // the line contents are wider than the `container_width`. If it is set to `false` then all overflowing
164
- // lines will be `Start` aligned.
159
+ /// Apply alignment to the layout relative to the specified container width or full layout
160
+ /// width.
161
+ ///
162
+ /// You must perform line breaking prior to aligning, through [`Layout::break_lines`] or
163
+ /// [`Layout::break_all_lines`]. If `container_width` is not specified, the layout's
164
+ /// [`Layout::full_width`] is used.
165
+ ///
166
+ /// If `align_when_overflowing` is set to `true`, alignment will apply even if the line
167
+ /// contents are wider than the alignment width. If it is set to `false`, all overflowing lines
168
+ /// will be [`Alignment::Start`] aligned.
165
169
pub fn align (
166
170
& mut self ,
167
171
container_width : Option < f32 > ,
You can’t perform that action at this time.
0 commit comments