You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let max_advance = if text_context.wrap{
width_constraint
}else{Some(f32::MAX)};
layout.break_all_lines(max_advance);
layout.align(
width_constraint,match text_context.horizontal_alignment{HorizontalAlignment::Center => Alignment::Middle,HorizontalAlignment::Right => Alignment::End,HorizontalAlignment::Left => Alignment::Start,},);
When word wrap is off I've found I still need to call break_all_lines and I still need to supply a max_advance, so I set it to f32::MAX. This is fine.
This code is all working well, except for the cases where word wrap is off, the text is longer than the width constraint, and the text alignment is Middle or End.
The result is as follows:
There are 9 tests here. First three left aligned, then right aligned, then centered. Within each set of three tests the middle test case is the problematic one - you can see in all three cases it gets left-aligned.
The expected behaviour was that the left side of the right-aligned text would be cropped, and both sides of the centered text would be cropped. Although with further thought I can see that chopping off the start of the text may not always be desirable.
After the discussion on Zulip it was decided I should create a GitHub issue.
The text was updated successfully, but these errors were encountered:
As per the Zulip discussion here.
My code currently looks like this:
When word wrap is off I've found I still need to call
break_all_lines
and I still need to supply amax_advance
, so I set it tof32::MAX
. This is fine.This code is all working well, except for the cases where word wrap is off, the text is longer than the width constraint, and the text alignment is Middle or End.
The result is as follows:
There are 9 tests here. First three left aligned, then right aligned, then centered. Within each set of three tests the middle test case is the problematic one - you can see in all three cases it gets left-aligned.
The expected behaviour was that the left side of the right-aligned text would be cropped, and both sides of the centered text would be cropped. Although with further thought I can see that chopping off the start of the text may not always be desirable.
After the discussion on Zulip it was decided I should create a GitHub issue.
The text was updated successfully, but these errors were encountered: