Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpretation of spaceAfterScript for mmultiscripts's prescripts #217

Open
fred-wang opened this issue Jan 26, 2024 · 12 comments
Open

Interpretation of spaceAfterScript for mmultiscripts's prescripts #217

fred-wang opened this issue Jan 26, 2024 · 12 comments

Comments

@fred-wang
Copy link
Contributor

I stumbled on some interop issue while exporting tests from Gecko.

From https://learn.microsoft.com/en-us/typography/opentype/spec/math:

spaceAfterScript Extra white space to be added after each subscript and superscript. Suggested: 0.5 pt for a 12 pt font. (Note that, in some math layout implementations, a constant value, such as 0.5 pt, may be used for all text sizes. Some implementations may use a constant ratio of text size, such as 1/24 of em.)

MathML Core and Chromium places the space before each prescript at https://w3c.github.io/mathml-core/#base-with-prescripts-and-postscripts:

For each subscript/superscript pair of mmultiscripts prescripts:
Increment inline-offset by SpaceAfterScript.
...

But Firefox seems to do it the other way around, i.e. place the space after each prescript.

So the former option makes the rendering more symmetric with respect to the base, but the latter makes it more consistent with the parameter name.

Since we have space between scripts anyway, the significant difference is that the former adds a space between the leftmost scripts (assuming LTR) and the content before ; and the latter adds a space between the base and its closest prescripts.

@fred-wang
Copy link
Contributor Author

Tentative test: unfortunately, scripts-spaceafterscript3000.woff cannot be access due to CORS policy. It seems chromium badly computes the inline size of mmultitscripts BTW.

<!DOCTYPE html>
<style>
  math {
    font: 50px spaceafterscript3000;
  }
  mspace {
      background: black
  }
  mmultiscripts {
      background: gray;
  }
  @font-face {
    font-family: spaceafterscript3000;
    src: url("http://wpt.live/fonts/math/scripts-spaceafterscript3000.woff");
  }
</style>
<math>
  <mmultiscripts>
    <mspace width="1em" height="1em" depth="1em"/>
    <mspace width="1em" height="1em" depth="1em"/>
    <mspace width="2em" height="1em" depth="1em"/>
    <mspace width="3em" height="1em" depth="1em"/>
    <mspace width="4em" height="1em" depth="1em"/>
    <mprescripts/>
    <mspace width="1em" height="1em" depth="1em"/>
    <mspace width="2em" height="1em" depth="1em"/>
    <mspace width="3em" height="1em" depth="1em"/>
    <mspace width="4em" height="1em" depth="1em"/>
  </mmultiscripts>
</math>

@NSoiffer
Copy link
Contributor

I would tend to lean towards symmetry. Do you have any idea what TeX does for the equivalent {}_{sub}_{sup}{base}_{sub}_{sup}?

I'm not completely sure that is right comparison though. The mhchem package for ${}^{238}\text{U}$ does a lot of tweaking for spacing, so maybe that is a better indicator of what is right. It's a mess though:

<math>
        <mrow>
          <msubsup>
            <mrow>
              <mrow>
                <mpadded width='0'>
                  <mphantom>
                    <mi>A</mi>
                  </mphantom>
                </mpadded>
              </mrow>
            </mrow>
            <mrow>
              <mrow>
                <mpadded height='0' depth='0'>
                  <mphantom></mphantom>
                </mpadded>
              </mrow>
            </mrow>
            <mrow>
              <mrow>
                <mpadded height='0' depth='0'>
                  <mphantom>
                    <mn>238</mn>
                  </mphantom>
                </mpadded>
              </mrow>
            </mrow>
          </msubsup>
          <mspace width='-0.083em' linebreak='nobreak'></mspace>
          <msubsup>
            <mrow>
              <mrow>
                <mpadded width='0'>
                  <mphantom>
                    <mi>A</mi>
                  </mphantom>
                </mpadded>
              </mrow>
            </mrow>
            <mrow>
              <mrow>
                <mpadded width='0'>
                  <mphantom>
                    <mn>2</mn>
                  </mphantom>
                </mpadded>
              </mrow>
              <mrow>
                <mpadded width='0' lspace='-1width'>
                  <mrow>
                    <mpadded height='0'></mpadded>
                  </mrow>
                </mpadded>
              </mrow>
            </mrow>
            <mrow>
              <mrow>
                <mpadded height='0'>
                  <mrow>
                    <mpadded width='0'>
                      <mphantom>
                        <mn>2</mn>
                      </mphantom>
                    </mpadded>
                  </mrow>
                </mpadded>
              </mrow>
              <mrow>
                <mpadded width='0' lspace='-1width'>
                  <mn>238</mn>
                </mpadded>
              </mrow>
            </mrow>
          </msubsup>
          <mrow>
            <mi mathvariant='normal'>U</mi>
          </mrow>
        </mrow>
      </math>

@dginev
Copy link

dginev commented Jan 29, 2024

So the former option makes the rendering more symmetric with respect to the base, but the latter makes it more consistent with the parameter name.

I guess one can view the symmetric approach to have a reading of "After" that means "AwayFromBase", or "Outer". "After" is a bit of an unfortunate preposition, since it depends on an implied traversal order...

moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this issue Feb 1, 2024
- dir-3.html/dir-5.html: These are approximative verifications of overall
  RTL directionality using "covering rectangles". Export them with a
  a specific font in order to make them a bit more robust.
  For dir-5.html we use scripts-spaceafterscript3000.woff and adjust the
  rects accordingly but the test might change later depending on the
  outcome of w3c/mathml-core#217.

- dir-4-ref.html: Removed (the test was removed in bug 1783995).

Differential Revision: https://phabricator.services.mozilla.com/D199702

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1876684
gecko-commit: eb00222e557742d5a6c66534f38345ddf71deaa5
gecko-reviewers: emilio
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Feb 2, 2024
- dir-3.html/dir-5.html: These are approximative verifications of overall
  RTL directionality using "covering rectangles". Export them with a
  a specific font in order to make them a bit more robust.
  For dir-5.html we use scripts-spaceafterscript3000.woff and adjust the
  rects accordingly but the test might change later depending on the
  outcome of w3c/mathml-core#217.

- dir-4-ref.html: Removed (the test was removed in bug 1783995).

Differential Revision: https://phabricator.services.mozilla.com/D199702
moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this issue Feb 2, 2024
- dir-3.html/dir-5.html: These are approximative verifications of overall
  RTL directionality using "covering rectangles". Export them with a
  a specific font in order to make them a bit more robust.
  For dir-5.html we use scripts-spaceafterscript3000.woff and adjust the
  rects accordingly but the test might change later depending on the
  outcome of w3c/mathml-core#217.

- dir-4-ref.html: Removed (the test was removed in bug 1783995).

Differential Revision: https://phabricator.services.mozilla.com/D199702

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1876684
gecko-commit: eb00222e557742d5a6c66534f38345ddf71deaa5
gecko-reviewers: emilio
@fred-wang
Copy link
Contributor Author

I stumbled on some interop issue while exporting tests from Gecko.

For the record this is the == reftest (note: this is using RTL mmultiscript):
http://wpt.live/mathml/presentation-markup/direction/direction-overall-003.html
http://wpt.live/mathml/presentation-markup/direction/direction-overall-003-ref.html

The results are not available yet, but they should appear at:
https://wpt.fyi/results/mathml/presentation-markup/direction/direction-overall-003.html?label=experimental&label=master&aligned

ErichDonGubler pushed a commit to erichdongubler-mozilla/firefox that referenced this issue Feb 2, 2024
- dir-3.html/dir-5.html: These are approximative verifications of overall
  RTL directionality using "covering rectangles". Export them with a
  a specific font in order to make them a bit more robust.
  For dir-5.html we use scripts-spaceafterscript3000.woff and adjust the
  rects accordingly but the test might change later depending on the
  outcome of w3c/mathml-core#217.

- dir-4-ref.html: Removed (the test was removed in bug 1783995).

Differential Revision: https://phabricator.services.mozilla.com/D199702
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Feb 8, 2024
- dir-3.html/dir-5.html: These are approximative verifications of overall
  RTL directionality using "covering rectangles". Export them with a
  a specific font in order to make them a bit more robust.
  For dir-5.html we use scripts-spaceafterscript3000.woff and adjust the
  rects accordingly but the test might change later depending on the
  outcome of w3c/mathml-core#217.

- dir-4-ref.html: Removed (the test was removed in bug 1783995).

Differential Revision: https://phabricator.services.mozilla.com/D199702

UltraBlame original commit: eb00222e557742d5a6c66534f38345ddf71deaa5
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Feb 8, 2024
- dir-3.html/dir-5.html: These are approximative verifications of overall
  RTL directionality using "covering rectangles". Export them with a
  a specific font in order to make them a bit more robust.
  For dir-5.html we use scripts-spaceafterscript3000.woff and adjust the
  rects accordingly but the test might change later depending on the
  outcome of w3c/mathml-core#217.

- dir-4-ref.html: Removed (the test was removed in bug 1783995).

Differential Revision: https://phabricator.services.mozilla.com/D199702

UltraBlame original commit: eb00222e557742d5a6c66534f38345ddf71deaa5
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Feb 8, 2024
- dir-3.html/dir-5.html: These are approximative verifications of overall
  RTL directionality using "covering rectangles". Export them with a
  a specific font in order to make them a bit more robust.
  For dir-5.html we use scripts-spaceafterscript3000.woff and adjust the
  rects accordingly but the test might change later depending on the
  outcome of w3c/mathml-core#217.

- dir-4-ref.html: Removed (the test was removed in bug 1783995).

Differential Revision: https://phabricator.services.mozilla.com/D199702

UltraBlame original commit: eb00222e557742d5a6c66534f38345ddf71deaa5
mbrodesser-Igalia pushed a commit to mbrodesser-Igalia/wpt that referenced this issue Feb 19, 2024
- dir-3.html/dir-5.html: These are approximative verifications of overall
  RTL directionality using "covering rectangles". Export them with a
  a specific font in order to make them a bit more robust.
  For dir-5.html we use scripts-spaceafterscript3000.woff and adjust the
  rects accordingly but the test might change later depending on the
  outcome of w3c/mathml-core#217.

- dir-4-ref.html: Removed (the test was removed in bug 1783995).

Differential Revision: https://phabricator.services.mozilla.com/D199702

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1876684
gecko-commit: eb00222e557742d5a6c66534f38345ddf71deaa5
gecko-reviewers: emilio
@khaledhosny
Copy link

khaledhosny commented Feb 22, 2024

I tested with MS Word, and spaceAfterScript is added before prescripts (the test font uses a large value to make it obvious):
image

@khaledhosny
Copy link

I submitted MicrosoftDocs/typography-issues#1135 for clarifying this in OpenType spec.

@fred-wang
Copy link
Contributor Author

I tested with MS Word, and spaceAfterScript is added before prescripts (the test font uses a large value to make it obvious):

Thanks Khaled, so this would consistent with MathML Core / Chromium. What is your test? It seems there is only one prescript and presubscript, right? Because I only see one gap.

@khaledhosny
Copy link

It seems there is only one prescript and presubscript, right?

Yes. Perhaps this screenshot makes it more obvious:

image

@fred-wang
Copy link
Contributor Author

OK, I was asking because MathML supports multiple sub/sup pairs of prescripts, so we have a more generic use of spaceAfterScript: https://w3c.github.io/mathml-core/#figure-box-mmultiscripts

@khaledhosny
Copy link

I don’t think Microsoft Word support multiple pairs on either side.

marcoscaceres pushed a commit to web-platform-tests/wpt that referenced this issue Feb 23, 2024
- dir-3.html/dir-5.html: These are approximative verifications of overall
  RTL directionality using "covering rectangles". Export them with a
  a specific font in order to make them a bit more robust.
  For dir-5.html we use scripts-spaceafterscript3000.woff and adjust the
  rects accordingly but the test might change later depending on the
  outcome of w3c/mathml-core#217.

- dir-4-ref.html: Removed (the test was removed in bug 1783995).

Differential Revision: https://phabricator.services.mozilla.com/D199702

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1876684
gecko-commit: eb00222e557742d5a6c66534f38345ddf71deaa5
gecko-reviewers: emilio
@fred-wang
Copy link
Contributor Author

@khaledhosny So IIUC the conclusion is that the space should be added before pre-scripts (and after post-scripts) so the "symmetric" approach by Chromium, not the "always-after-scripts" approach by Firefox.

@khaledhosny
Copy link

Yes. The spec text was also updated to make this more explicit:

Extra white space to be added after each subscript and superscript that occurs after a baseline element, and before each subscript and superscript that occurs before a baseline element.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants