Track span rtl status in layout glyph

This commit is contained in:
Jeremy Soller 2022-10-24 17:13:32 -06:00
parent 7363c923e5
commit d6d896688f
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE
2 changed files with 4 additions and 2 deletions

View file

@ -7,6 +7,7 @@ pub struct FontLayoutGlyph<'a> {
pub end: usize, pub end: usize,
pub x: f32, pub x: f32,
pub w: f32, pub w: f32,
pub rtl: bool,
pub font: &'a Font<'a>, pub font: &'a Font<'a>,
pub inner: (CacheKey, i32, i32), pub inner: (CacheKey, i32, i32),
} }

View file

@ -14,7 +14,7 @@ pub struct FontShapeGlyph<'a> {
} }
impl<'a> FontShapeGlyph<'a> { impl<'a> FontShapeGlyph<'a> {
fn layout(&self, font_size: i32, x: f32, y: f32) -> FontLayoutGlyph<'a> { fn layout(&self, font_size: i32, x: f32, y: f32, rtl: bool) -> FontLayoutGlyph<'a> {
let x_offset = font_size as f32 * self.x_offset; let x_offset = font_size as f32 * self.x_offset;
let y_offset = font_size as f32 * self.y_offset; let y_offset = font_size as f32 * self.y_offset;
let x_advance = font_size as f32 * self.x_advance; let x_advance = font_size as f32 * self.x_advance;
@ -25,6 +25,7 @@ impl<'a> FontShapeGlyph<'a> {
end: self.end, end: self.end,
x: x, x: x,
w: x_advance, w: x_advance,
rtl,
font: self.font, font: self.font,
inner, inner,
} }
@ -183,7 +184,7 @@ impl<'a> FontShapeLine<'a> {
x -= x_advance x -= x_advance
} }
glyphs.push(glyph.layout(font_size, x, y)); glyphs.push(glyph.layout(font_size, x, y, span.rtl));
push_line = true; push_line = true;
if !self.rtl { if !self.rtl {