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
MathML: Test italic correction of sub and super scripts attached to a large operator #9993
Changes from 3 commits
3b14fd2
7583caa
16747b3
dfdc9b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Subscripts and Superscripts parameters</title> | ||
<link rel="help" href="http://www.mathml-association.org/MathMLinHTML5/S3.html#SS4"> | ||
<meta name="assert" content="Elements msub, msup, subsup and msubsup correctly use the italic correction from the MATH table."> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<style> | ||
math, mspace { | ||
font-size: 10px; | ||
} | ||
@font-face { | ||
font-family: largeop-displayoperatorminheight5000; | ||
src: url("/fonts/math/largeop-displayoperatorminheight5000.woff"); | ||
} | ||
@font-face { | ||
font-family: largeop-displayoperatorminheight2000-2AFF-italiccorrection3000; | ||
src: url("/fonts/math/largeop-displayoperatorminheight2000-2AFF-italiccorrection3000.woff"); | ||
} | ||
</style> | ||
<script> | ||
var emToPx = 10 / 1000; // font-size: 10px, font.em = 1000 | ||
var epsilon = 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
function getBox(aId) { | ||
return document.getElementById(aId).getBoundingClientRect(); | ||
} | ||
|
||
setup({ explicit_done: true }); | ||
window.addEventListener("load", function() { | ||
// Delay the check to workaround WebKit's bug https://webkit.org/b/174030. | ||
requestAnimationFrame(() => { document.fonts.ready.then(runTests); }); | ||
}); | ||
|
||
/* | ||
These two tests verify that: | ||
- In msub, the script is at the right of the base minus the italic correction. | ||
- In msup, the script is just at the right of the base. | ||
- In msubsup, the scripts are shifted by the italic correction. | ||
- In mmultiscripts, postscript pairs are shifted by the italic correction. | ||
- In mmultiscripts, prescript pairs are vertically aligned. | ||
*/ | ||
function runTests() { | ||
test(function() { | ||
var v = 0; | ||
assert_approx_equals(getBox("base001").right - getBox("sub001").left, v, epsilon, "msub"); | ||
assert_approx_equals(getBox("sup002").left, getBox("base002").right, epsilon, "msup"); | ||
assert_approx_equals(getBox("sup003").left - getBox("sub003").left, v, epsilon, "msubsup"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If both are wrongly positioned, but with the same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, however I'm not sure that's a big deal to "wrongly pass" (Chromium and Edge have many MathML tests passing on wpt.fyi ; just because they succeeded to load the test !). I think it's clearer and more natural to test the italic correction by checking the difference of position of the two scripts. I could add extra tests to check the horizontal position but that kind of tests is already (and more completely done) done by http://w3c-test.org/mathml/presentation-markup/scripts/subsup-parameters-1.html There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The goal of a test is to fail when something is not supported, so it'd be better if they fail. |
||
assert_approx_equals(getBox("sup004").left - getBox("sub004").left, v, epsilon, "mmultiscripts postscripts"); | ||
assert_approx_equals(getBox("sup005").left - getBox("sub005").left, 0, epsilon, "mmultiscripts prescripts"); | ||
}, "Null Italic Correction"); | ||
test(function() { | ||
var v = 3000 * emToPx; | ||
assert_approx_equals(getBox("base011").right - getBox("sub011").left, v, epsilon, "msub"); | ||
assert_approx_equals(getBox("sup012").left, getBox("base012").right, epsilon, "msup"); | ||
assert_approx_equals(getBox("sup013").left - getBox("sub013").left, v, epsilon, "msubsup"); | ||
assert_approx_equals(getBox("sup014").left - getBox("sub014").left, v, epsilon, "mmultiscripts postscripts"); | ||
assert_approx_equals(getBox("sup015").left - getBox("sub015").left, 0, epsilon, "mmultiscripts prescripts"); | ||
}, "NonNull Italic Correction"); | ||
done(); | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Dunno if this is common or not on MathML test suite, so feel free to ignore these suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I never liked that the test results don't show at the top. I actually think it's a good idea and should be done for MathML tests too. |
||
<p> | ||
<math displaystyle="true" style="font-family: largeop-displayoperatorminheight5000;"> | ||
<msub> | ||
<mo id="base001" lspace="0px" rspace="0px">⫿</mo> | ||
<mspace id="sub001" height="1em" width="1em" mathbackground="blue"/> | ||
</msub> | ||
</math> | ||
<math displaystyle="true" style="font-family: largeop-displayoperatorminheight5000;"> | ||
<msup> | ||
<mo id="base002" lspace="0px" rspace="0px">⫿</mo> | ||
<mspace id="sup002" height="1em" width="1em" mathbackground="blue"/> | ||
</msup> | ||
</math> | ||
<math displaystyle="true" style="font-family: largeop-displayoperatorminheight5000;"> | ||
<msubsup> | ||
<mo lspace="0px" rspace="0px">⫿</mo> | ||
<mspace id="sub003" height="1em" width="1em" mathbackground="blue"/> | ||
<mspace id="sup003" height="1em" width="1em" mathbackground="green"/> | ||
</msubsup> | ||
</math> | ||
<math displaystyle="true" style="font-family: largeop-displayoperatorminheight5000;"> | ||
<mmultiscripts> | ||
<mo lspace="0px" rspace="0px">⫿</mo> | ||
<mspace id="sub004" height="1em" width="1em" mathbackground="blue"/> | ||
<mspace id="sup004" height="1em" width="1em" mathbackground="green"/> | ||
<mprescripts/> | ||
<mspace id="sub005" height="1em" width="1em" mathbackground="magenta"/> | ||
<mspace id="sup005" height="1em" width="1em" mathbackground="cyan"/> | ||
</mmultiscripts> | ||
</math> | ||
</p> | ||
<hr/> | ||
<p> | ||
<math displaystyle="true" style="font-family: largeop-displayoperatorminheight2000-2AFF-italiccorrection3000;"> | ||
<msub> | ||
<mo id="base011" lspace="0px" rspace="0px">⫿</mo> | ||
<mspace id="sub011" height="1em" width="1em" mathbackground="blue"/> | ||
</msub> | ||
</math> | ||
<math displaystyle="true" style="font-family: largeop-displayoperatorminheight2000-2AFF-italiccorrection3000;"> | ||
<msup> | ||
<mo id="base012" lspace="0px" rspace="0px">⫿</mo> | ||
<mspace id="sup012" height="1em" width="1em" mathbackground="blue"/> | ||
</msup> | ||
</math> | ||
<math displaystyle="true" style="font-family: largeop-displayoperatorminheight2000-2AFF-italiccorrection3000;"> | ||
<msubsup> | ||
<mo lspace="0px" rspace="0px">⫿</mo> | ||
<mspace id="sub013" height="1em" width="1em" mathbackground="blue"/> | ||
<mspace id="sup013" height="1em" width="1em" mathbackground="green"/> | ||
</msubsup> | ||
</math> | ||
<math displaystyle="true" style="font-family: largeop-displayoperatorminheight2000-2AFF-italiccorrection3000;"> | ||
<mmultiscripts> | ||
<mo lspace="0px" rspace="0px">⫿</mo> | ||
<mspace id="sub014" height="1em" width="1em" mathbackground="blue"/> | ||
<mspace id="sup014" height="1em" width="1em" mathbackground="green"/> | ||
<mprescripts/> | ||
<mspace id="sub015" height="1em" width="1em" mathbackground="magenta"/> | ||
<mspace id="sup015" height="1em" width="1em" mathbackground="cyan"/> | ||
</mmultiscripts> | ||
</math> | ||
</p> | ||
</body> | ||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this closer to where it's used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.