diff --git a/library/src/math/attach.rs b/library/src/math/attach.rs index cc523e0e6..110ea4b79 100644 --- a/library/src/math/attach.rs +++ b/library/src/math/attach.rs @@ -192,11 +192,8 @@ fn scripts( } let italics = base.italics_correction(); + let sup_delta = Abs::zero(); let sub_delta = -italics; - let sup_delta = match base.class() { - Some(MathClass::Large) => Abs::zero(), - _ => italics, - }; let mut width = Abs::zero(); let mut ascent = base.ascent(); diff --git a/library/src/math/fragment.rs b/library/src/math/fragment.rs index a7ca8db3e..fe9642a20 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 { 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 diff --git a/library/src/math/row.rs b/library/src/math/row.rs index 5862bfc60..d971ce221 100644 --- a/library/src/math/row.rs +++ b/library/src/math/row.rs @@ -59,10 +59,6 @@ impl MathRow { } let mut amount = Abs::zero(); - if let MathFragment::Glyph(glyph) = *prev { - amount += glyph.italics_correction; - } - amount += spacing(prev, &fragment, style, space, space_width).at(font_size); if !amount.is_zero() {