BufferLine: use layout_in_buffer to implement layout
This commit is contained in:
parent
80d120dfa5
commit
816ea4fae7
1 changed files with 9 additions and 10 deletions
|
|
@ -172,7 +172,7 @@ impl BufferLine {
|
||||||
self.shape_in_buffer(&mut ShapeBuffer::default(), font_system)
|
self.shape_in_buffer(&mut ShapeBuffer::default(), font_system)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shape a line using a pre-existing shape buffer.
|
/// Shape a line using a pre-existing shape buffer, will cache results
|
||||||
pub fn shape_in_buffer(
|
pub fn shape_in_buffer(
|
||||||
&mut self,
|
&mut self,
|
||||||
scratch: &mut ShapeBuffer,
|
scratch: &mut ShapeBuffer,
|
||||||
|
|
@ -204,17 +204,16 @@ impl BufferLine {
|
||||||
width: f32,
|
width: f32,
|
||||||
wrap: Wrap,
|
wrap: Wrap,
|
||||||
) -> &[LayoutLine] {
|
) -> &[LayoutLine] {
|
||||||
if self.layout_opt.is_none() {
|
self.layout_in_buffer(
|
||||||
self.wrap = wrap;
|
&mut ShapeBuffer::default(),
|
||||||
let align = self.align;
|
font_system,
|
||||||
let shape = self.shape(font_system);
|
font_size,
|
||||||
let layout = shape.layout(font_size, width, wrap, align);
|
width,
|
||||||
self.layout_opt = Some(layout);
|
wrap,
|
||||||
}
|
)
|
||||||
self.layout_opt.as_ref().expect("layout not found")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Layout a line using a pre-existing shape buffer.
|
/// Layout a line using a pre-existing shape buffer, will cache results
|
||||||
pub fn layout_in_buffer(
|
pub fn layout_in_buffer(
|
||||||
&mut self,
|
&mut self,
|
||||||
scratch: &mut ShapeBuffer,
|
scratch: &mut ShapeBuffer,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue