Combine both simple and word wrapping into one layout function

This commit is contained in:
Jeremy Soller 2022-10-26 20:10:38 -06:00
parent 5d1aa8b814
commit 87c12b11ae
2 changed files with 36 additions and 86 deletions

View file

@ -212,21 +212,15 @@ impl<'a> TextBufferLine<'a> {
pub fn layout(&mut self, font_system: &'a FontSystem<'a>, font_size: i32, width: i32) -> &[LayoutLine] {
if self.layout_opt.is_none() {
let mut layout = Vec::new();
if self.wrap_simple {
self.shape(font_system).layout_simple(
font_size,
width,
&mut layout,
0,
);
} else {
self.shape(font_system).layout(
font_size,
width,
&mut layout,
0,
);
}
let wrap_simple = self.wrap_simple;
let shape = self.shape(font_system);
shape.layout(
font_size,
width,
&mut layout,
0,
wrap_simple
);
self.layout_opt = Some(layout);
}
self.layout_opt.as_ref().unwrap()