Closed Bug 2008690 Opened 7 months ago Closed 6 months ago

Bad clipping/width of large operators when italic correction is applied

Categories

(Core :: MathML, defect)

defect

Tracking

()

RESOLVED FIXED
149 Branch
Tracking Status
firefox149 --- fixed

People

(Reporter: fwang, Assigned: fwang)

References

(Blocks 2 open bugs)

Details

(Keywords: dev-doc-complete)

Attachments

(5 files, 1 obsolete file)

See the attached testcase, with large clockwise integrals drawn with Latin Modern Math and XITS Math.

In LTR mode, the width is too small (see the blue background).

In RTL mode this is even worse: the left part of the integrals are never shown.

Both are due to the following code that subtracts italic correct from the operator width:

https://searchfox.org/firefox-main/rev/33bba5cfe4a89dda0ee07fa9fbac578353713fd3/layout/mathml/nsMathMLChar.cpp#1021

This is legacy stuff that mimics the behavior of old fonts like STIX-Word, that provides a shorter width for slanted integrals, in order to allow proper position of subscripts.

Per MathML Core, we should actually not modified the operator width but instead take the italic correction of the base during the layout of nsMathMLmmultiscriptsFrame: https://www.w3.org/TR/mathml-core/#base-with-subscript

Note that this is a bit tricky because the base may be more complex (e.g. <mrow><mrow><mrow><mo largeop="true">∲</mo></mrow></mrow></mrow>) and we need to transmit the italic correction from the core operator to the nsMathMLmmultiscriptsFrame, which is probably why we haven't done that so far.

I see:
https://www.w3.org/TR/mathml-core/#layout-of-mtext

If the text content is made of a single glyph and this glyph has an entry in the MathItalicsCorrectionInfo table then the specified value is used as the italic correction.

https://www.w3.org/TR/mathml-core/#layout-of-mrow

The italic correction of the math content is set to the italic correction of the last in-flow child, which is the final value of previous-italic-correction.

https://www.w3.org/TR/mathml-core/#layout-of-operators
If the algorithm to shape a stretchy glyph has been used for one of the step above, then the italic correction of the math content is set to the value returned by that algorithm.

https://wpt.fyi/results/mathml/presentation-markup/scripts/subsup-parameters-2.html seems to be a basic test for italic correction, but we probably need more complex ones involving mtext (or mo behaving like mtext) or mrow constructions.

Attached image Screenshot in Firefox release 146 (obsolete) —
Attachment #9535881 - Attachment is obsolete: true

I attached one screenshot showing the bug in Firefox release 146. And another one showing the script placement issue if we disable the italic correction hack at https://searchfox.org/firefox-main/rev/33bba5cfe4a89dda0ee07fa9fbac578353713fd3/layout/mathml/nsMathMLChar.cpp#1021

Blocks: 2009367
Attachment #9535897 - Attachment description: WIP: Bug 2008690 - Make nsMathMLmmultiscriptsFrame handle italic correction of largeop base. → Bug 2008690 - Make nsMathMLmmultiscriptsFrame handle italic correction of largeop base. r=emilio,eri
Pushed by fwang@igalia.com: https://github.com/mozilla-firefox/firefox/commit/12f92743d12b https://hg.mozilla.org/integration/autoland/rev/cb43e719cd12 Make nsMathMLmmultiscriptsFrame handle italic correction of largeop base. r=emilio,layout-reviewers
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/57335 for changes under testing/web-platform/tests
Status: NEW → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 149 Branch
Upstream PR merged by moz-wptsync-bot
Keywords: dev-doc-needed

FF149 MDN work for this can be tracked in https://github.com/mdn/content/issues/43207

Fred, what were you thinking was needed for this? It sounds like a bug fix, so perhaps:

  1. A release note like this? (if not, please suggest alternative):

    Fixed a rendering bug where large operators were incorrectly clipped or had improper widths when italic correction was applied.

  2. Does this need data compatibility information to be recorded? If so, is https://developer.mozilla.org/en-US/docs/Web/MathML/Reference/Element/mo#largeop the correct operator.attribute to target?

Flags: needinfo?(fwang)

@Hamish: Largeop has been supported forever in Firefox, I think this is more a bug fix so a note like you did in (1) sounds correct.

(I don't know how important it is to be in the release notes, but I'll trust your judgement on that)

Flags: needinfo?(fwang)

Hi Fred, Thanks! I choose not to include anything for this - it doesn't change the way that developers should use the interface. I suspect most that care will aleady be tracking this issue, and the remainder hopefully upgrade to new Firefox and never notice there was ever a problem.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: