Add line width field to LayoutLine

This commit is contained in:
Héctor Ramón Jiménez 2022-12-15 04:59:31 +01:00 committed by Jeremy Soller
parent 652543f9aa
commit 67950724c3
3 changed files with 9 additions and 0 deletions

View file

@ -55,6 +55,8 @@ pub struct LayoutRun<'a> {
pub glyphs: &'a [LayoutGlyph], pub glyphs: &'a [LayoutGlyph],
/// Y offset of line /// Y offset of line
pub line_y: i32, pub line_y: i32,
/// width of line
pub line_w: f32,
} }
/// An iterator of visible text lines, see [`LayoutRun`] /// An iterator of visible text lines, see [`LayoutRun`]
@ -105,6 +107,7 @@ impl<'a, 'b> Iterator for LayoutRunIter<'a, 'b> {
rtl: shape.rtl, rtl: shape.rtl,
glyphs: &layout_line.glyphs, glyphs: &layout_line.glyphs,
line_y: self.line_y, line_y: self.line_y,
line_w: layout_line.w,
}); });
} }
self.line_i += 1; self.line_i += 1;

View file

@ -32,6 +32,8 @@ pub struct LayoutGlyph {
/// A line of laid out glyphs /// A line of laid out glyphs
pub struct LayoutLine { pub struct LayoutLine {
/// Width of the line
pub w: f32,
/// Glyphs in line /// Glyphs in line
pub glyphs: Vec<LayoutGlyph>, pub glyphs: Vec<LayoutGlyph>,
} }

View file

@ -594,6 +594,7 @@ impl ShapeLine {
mem::swap(&mut glyphs, &mut glyphs_swap); mem::swap(&mut glyphs, &mut glyphs_swap);
layout_lines.push( layout_lines.push(
LayoutLine { LayoutLine {
w: x,
glyphs: glyphs_swap, glyphs: glyphs_swap,
}, },
); );
@ -623,6 +624,7 @@ impl ShapeLine {
mem::swap(&mut glyphs, &mut glyphs_swap); mem::swap(&mut glyphs, &mut glyphs_swap);
layout_lines.push( layout_lines.push(
LayoutLine { LayoutLine {
w: x,
glyphs: glyphs_swap, glyphs: glyphs_swap,
}, },
); );
@ -650,6 +652,7 @@ impl ShapeLine {
mem::swap(&mut glyphs, &mut glyphs_swap); mem::swap(&mut glyphs, &mut glyphs_swap);
layout_lines.push( layout_lines.push(
LayoutLine { LayoutLine {
w: x,
glyphs: glyphs_swap, glyphs: glyphs_swap,
}, },
); );
@ -663,6 +666,7 @@ impl ShapeLine {
if push_line { if push_line {
layout_lines.push( layout_lines.push(
LayoutLine { LayoutLine {
w: x,
glyphs, glyphs,
}, },
); );