I would expect the following snippet to return a height corresponding to a single line of text:
let text = " !";
let mut layout_ctx: LayoutContext<Option<Brush<Color>>> = LayoutContext::new();
let mut font_ctx = FontContext::new();
let mut builder = layout_ctx.ranged_builder(&mut font_ctx, text, 1.0, true);
builder.push_default(StyleProperty::FontSize(12f32));
builder.push_default(StyleProperty::TextWrapMode(TextWrapMode::NoWrap));
let mut layout = builder.build(text);
layout.break_all_lines(Some(0f32));
println!("{:?}", layout.height());
for (idx, line) in layout.lines().enumerate() {
println!("line {idx}: {:?}", &text[line.text_range()]);
}
However, for me it returns a height of about 32 and two lines (" " and "!"). In contrast, if text is "!!", it works as I would expect it to. This only happens if the first character is a space (' '), not a tab character or similar. I don't know if this is intended behaviour, if so, is there a way to ensure a line starting with a space character is not wrapped?
I would expect the following snippet to return a
heightcorresponding to a single line of text:However, for me it returns a height of about
32and two lines (" "and"!"). In contrast, iftextis"!!", it works as I would expect it to. This only happens if the first character is a space (' '), not a tab character or similar. I don't know if this is intended behaviour, if so, is there a way to ensure a line starting with a space character is not wrapped?