diff options
Diffstat (limited to 'library/src/math/fragment.rs')
| -rw-r--r-- | library/src/math/fragment.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/library/src/math/fragment.rs b/library/src/math/fragment.rs index a7ca8db3..fe9642a2 100644 --- a/library/src/math/fragment.rs +++ b/library/src/math/fragment.rs @@ -152,13 +152,19 @@ impl GlyphFragment { x_max: 0, y_max: 0, }); + + let mut width = advance.scaled(ctx); + if !is_extended_shape(ctx, id) { + width += italics; + } + Self { id, c, lang: ctx.styles().get(TextNode::LANG), fill: ctx.styles().get(TextNode::FILL), font_size: ctx.size, - width: advance.scaled(ctx), + width, ascent: bbox.y_max.scaled(ctx), descent: -bbox.y_min.scaled(ctx), italics_correction: italics, @@ -249,6 +255,15 @@ fn italics_correction(ctx: &MathContext, id: GlyphId) -> Option<Abs> { Some(ctx.table.glyph_info?.italic_corrections?.get(id)?.scaled(ctx)) } +/// Look up the italics correction for a glyph. +fn is_extended_shape(ctx: &MathContext, id: GlyphId) -> bool { + ctx.table + .glyph_info + .and_then(|info| info.extended_shapes) + .and_then(|info| info.get(id)) + .is_some() +} + /// Look up a kerning value at a specific corner and height. /// /// This can be integrated once we've found a font that actually provides this |
