From 3b14fd22448e80eaee8cce6774b3fdf2cd684130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Tue, 13 Mar 2018 10:58:33 +0100 Subject: [PATCH 1/4] MathML: Test italic correction of sub and super scripts attached to a large operator --- ...nheight2000-2AFF-italiccorrection3000.woff | Bin 0 -> 1372 bytes .../scripts/subsup-parameters-2.html | 123 ++++++++++++++++++ mathml/tools/largeop.py | 18 +++ 3 files changed, 141 insertions(+) create mode 100644 fonts/math/largeop-displayoperatorminheight2000-2AFF-italiccorrection3000.woff create mode 100644 mathml/presentation-markup/scripts/subsup-parameters-2.html diff --git a/fonts/math/largeop-displayoperatorminheight2000-2AFF-italiccorrection3000.woff b/fonts/math/largeop-displayoperatorminheight2000-2AFF-italiccorrection3000.woff new file mode 100644 index 0000000000000000000000000000000000000000..0b4f8bf46a76ab5cc70c2a12cb7db0d49570bd7c GIT binary patch literal 1372 zcmZXUe>9X?7{~8B#!HzDCEgJkKib4--WhCa+qJ04$n4ZHHhYfhee+@xlcG)Os4=Z+ zC8?FPIj5;rNh7tXY+F0yM={JG#VRGSdk`^&RtICR+W+>R^Evl@zUTWs_nv#7=k65? z1Y(Iq41jqwumW&c5dfK;|35+m0yY3<2LM2pLe%xE5+Vcwi3k9CF?6#aPKu|$)rx{7 zp-|Jp_$c(r7FIh(iX*su_)S3VYY4FbTh$wrL?*+0o}V-%EYjHVK^jX^&}RuXF648k zsOJhP6rmOXV`qrRf^p_WX;Nw$+;cdLZDwJ?zmmu_m=B49G5Qhu1|TDoVxgvjWI?}o z!#t&Z^3If0xULj>7C_iDS%9Bb6hlx10eZI2ln>|j-TBa<3j^dJh6}tQn)=KYvD*R-0F&0ik>#6rd6<4G0ow_h3>0HozkQAAMv-Re)T6N-jU6 ze5#PkN%O;TyNT;@erBx$9uMRnAvbWqDTxT3U z{Z?o{4dymD250Q-3f$Ma0yG)vOy$UY_qxRcHM^`fbtz(8?v$n1CFM*ls&g)yY|a(q z3CFR4TjK4TJ2^Fr-&dwQ4<6VY@cwPj{Z+Doy`;uJA|?Gu z?Md_79yc{N(^pO}V@5`=82dIq@8EhKO`liHn{O@L+FMLHeJ1vG@0A5z4SxBzDtz2) z)2(Rx&b#4zOPlsQ^Sr;TbdSuhj>H<$iadUmmaJ^dZ{OE$SNi&~LbGr(;>3?Wk2}VV zmqnel0y}KCDc-_*uG_QLrt-eSYa&G#I-G4S&STjx_hg%2_+x1O=v3~M&PQEY=Ix#M zsQ&v=W8jVY@q$Ngj9;|T)0HEWbKV)}mw&oPf`~gruuuVNlZ?E>st(wr^VkNon8hl@ z>?%w%Gt9pf12fEWen^`c;=af%Q(-5dOXakP(c{sm+sylwdwQ(XOcR;y%lsTthSjIA$^M@RwVzIJ`SPY|6n6r5- z=0RbXEqT{7QCqNgp{LkZ*f1y60NmxToh}QnT zuQHrj=IP zXo;Hr%4wR}vTk~QyGQUFKNNi!;P!+S^dxgTwn)dY+vPq~xG`V;Y9x}~nI%^Qp`kl? zMjV$jy1Nh$Or9t}<5W)W9TEX9LAEVMUC}w{$|9Mf#ExtsapbHkkd)CJ;z2f#r=f^A cjirO4;{lyC1BszF0RS0;uS)+Xm?{AN1xXnmvH$=8 literal 0 HcmV?d00001 diff --git a/mathml/presentation-markup/scripts/subsup-parameters-2.html b/mathml/presentation-markup/scripts/subsup-parameters-2.html new file mode 100644 index 00000000000000..09e21964f97da9 --- /dev/null +++ b/mathml/presentation-markup/scripts/subsup-parameters-2.html @@ -0,0 +1,123 @@ + + + + +Subscripts and Superscripts parameters + + + + + + + + +

+ + + ⫿ + + + + + + + ⫿ + + + + + + ⫿ + + + + + + + ⫿ + + + + + + + +

+
+

+ + + ⫿ + + + + + + + ⫿ + + + + + + ⫿ + + + + + + + ⫿ + + + + + + + +

+ + diff --git a/mathml/tools/largeop.py b/mathml/tools/largeop.py index 3c9c6c4c949692..73d967689bb7dc 100644 --- a/mathml/tools/largeop.py +++ b/mathml/tools/largeop.py @@ -12,3 +12,21 @@ mathfont.drawRectangleGlyph(g, mathfont.em, v1, 0) f[nAryWhiteVerticalBarCodePoint].verticalVariants = "uni2AFF uni2AFF.display" mathfont.save(f) + +v1 = 2 * mathfont.em +v2 = 3 * mathfont.em +f = mathfont.create("largeop-displayoperatorminheight%d-2AFF-italiccorrection%d" % (v1, v2)) +f.copyright = "Copyright (c) 2018 Igalia S.L." +f.math.DisplayOperatorMinHeight = v1 +mathfont.createSquareGlyph(f, nAryWhiteVerticalBarCodePoint) +g = f.createChar(-1, "uni2AFF.display") +p = g.glyphPen() +p.moveTo(0, 0) +p.lineTo(v2, v1) +p.lineTo(v2 + mathfont.em, v1) +p.lineTo(mathfont.em, 0) +p.closePath(); +g.width = mathfont.em + v2 +g.italicCorrection = v2 +f[nAryWhiteVerticalBarCodePoint].verticalVariants = "uni2AFF uni2AFF.display" +mathfont.save(f) From 7583caab9d5b2f6bf1bba3a2303d8d62b476e0c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Wed, 14 Mar 2018 17:33:15 +0100 Subject: [PATCH 2/4] Add workaround from PR #10025 --- mathml/presentation-markup/scripts/subsup-parameters-2.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mathml/presentation-markup/scripts/subsup-parameters-2.html b/mathml/presentation-markup/scripts/subsup-parameters-2.html index 09e21964f97da9..52cac3e697fc3a 100644 --- a/mathml/presentation-markup/scripts/subsup-parameters-2.html +++ b/mathml/presentation-markup/scripts/subsup-parameters-2.html @@ -30,7 +30,8 @@ setup({ explicit_done: true }); window.addEventListener("load", function() { - document.fonts.ready.then(runTests); + // Delay the check to workaround WebKit's bug https://webkit.org/b/174030. + requestAnimationFrame(() => { document.fonts.ready.then(runTests); }); }); function runTests() { From 16747b3c17567b6fdcb1f5480d2e687963a468f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Fri, 16 Mar 2018 11:39:29 +0100 Subject: [PATCH 3/4] Adjust a bit the tests to make it clearer and add comments. --- .../scripts/subsup-parameters-2.html | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/mathml/presentation-markup/scripts/subsup-parameters-2.html b/mathml/presentation-markup/scripts/subsup-parameters-2.html index 52cac3e697fc3a..bdbf1e8bf9fbd1 100644 --- a/mathml/presentation-markup/scripts/subsup-parameters-2.html +++ b/mathml/presentation-markup/scripts/subsup-parameters-2.html @@ -34,17 +34,26 @@ 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() { - assert_approx_equals(getBox("ref001").left - getBox("sub001").right, 0, epsilon, "msub"); + 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, 0, epsilon, "msubsup"); - assert_approx_equals(getBox("sup004").left - getBox("sub004").left, 0, epsilon, "mmultiscripts postscripts"); + assert_approx_equals(getBox("sup003").left - getBox("sub003").left, v, epsilon, "msubsup"); + 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("ref011").left - getBox("sub011").left, v, epsilon, "msub"); + 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"); @@ -58,10 +67,9 @@

- ⫿ + ⫿ - @@ -91,10 +99,9 @@

- ⫿ + ⫿ - From dfdc9b2f0fdea51b2987ab34c04a99b0a655f7c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Thu, 22 Mar 2018 06:56:29 +0100 Subject: [PATCH 4/4] Addresses rego's feedback --- .../presentation-markup/scripts/subsup-parameters-2.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mathml/presentation-markup/scripts/subsup-parameters-2.html b/mathml/presentation-markup/scripts/subsup-parameters-2.html index bdbf1e8bf9fbd1..eaa4f0ffab154a 100644 --- a/mathml/presentation-markup/scripts/subsup-parameters-2.html +++ b/mathml/presentation-markup/scripts/subsup-parameters-2.html @@ -21,9 +21,6 @@ } +

+

Null Italic Correction

@@ -95,7 +96,7 @@

-
+

NonNull Italic Correction