OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf-8"> |
| 5 <title>Subscripts and Superscripts parameters</title> |
| 6 <link rel="help" href="http://www.mathml-association.org/MathMLinHTML5/S3.html#S
S4"> |
| 7 <meta name="assert" content="Elements msub, msup, subsup and msubsup correctly u
se the subscript and superscript parameters from the MATH table."> |
| 8 <script src="/resources/testharness.js"></script> |
| 9 <script src="/resources/testharnessreport.js"></script> |
| 10 <style> |
| 11 math, mspace { |
| 12 font-size: 10px; |
| 13 } |
| 14 @font-face { |
| 15 font-family: spaceafterscript3000; |
| 16 src: url("/fonts/math/scripts-spaceafterscript3000.woff"); |
| 17 } |
| 18 @font-face { |
| 19 font-family: superscriptshiftup7000; |
| 20 src: url("/fonts/math/scripts-superscriptshiftup7000.woff"); |
| 21 } |
| 22 @font-face { |
| 23 font-family: superscriptshiftupcramped5000; |
| 24 src: url("/fonts/math/scripts-superscriptshiftupcramped5000.woff"); |
| 25 } |
| 26 @font-face { |
| 27 font-family: subscriptshiftdown6000; |
| 28 src: url("/fonts/math/scripts-subscriptshiftdown6000.woff"); |
| 29 } |
| 30 @font-face { |
| 31 font-family: subsuperscriptgapmin11000; |
| 32 src: url("/fonts/math/scripts-subsuperscriptgapmin11000.woff"); |
| 33 } |
| 34 @font-face { |
| 35 font-family: subsuperscriptgapmin11000superscriptbottommaxwithsubscript3000; |
| 36 src: url("/fonts/math/scripts-subsuperscriptgapmin11000-superscriptbottommax
withsubscript3000.woff"); |
| 37 } |
| 38 @font-face { |
| 39 font-family: subscripttopmax4000; |
| 40 src: url("/fonts/math/scripts-subscripttopmax4000.woff"); |
| 41 } |
| 42 @font-face { |
| 43 font-family: superscriptbottommin8000; |
| 44 src: url("/fonts/math/scripts-superscriptbottommin8000.woff"); |
| 45 } |
| 46 @font-face { |
| 47 font-family: subscriptbaselinedropmin9000; |
| 48 src: url("/fonts/math/scripts-subscriptbaselinedropmin9000.woff"); |
| 49 } |
| 50 @font-face { |
| 51 font-family: superscriptbaselinedropmax10000; |
| 52 src: url("/fonts/math/scripts-superscriptbaselinedropmax10000.woff"); |
| 53 } |
| 54 </style> |
| 55 <script> |
| 56 var emToPx = 10 / 1000; // font-size: 10px, font.em = 1000 |
| 57 var epsilon = 1; |
| 58 |
| 59 function getBox(aId) { |
| 60 return document.getElementById(aId).getBoundingClientRect(); |
| 61 } |
| 62 |
| 63 setup({ explicit_done: true }); |
| 64 window.addEventListener("load", function() { |
| 65 document.fonts.ready.then(runTests); |
| 66 }); |
| 67 |
| 68 function runTests() { |
| 69 test(function() { |
| 70 var v = 3000 * emToPx; |
| 71 assert_approx_equals(getBox("ref001").left - getBox("sub001").right, v, ep
silon, "msub: Space after subscript"); |
| 72 assert_approx_equals(getBox("ref002").left - getBox("sup002").right, v, ep
silon, "msup: Space after superscript"); |
| 73 assert_approx_equals(getBox("ref003").left - getBox("sup003").right, v, ep
silon, "msubsup: Space after superscript"); |
| 74 assert_approx_equals(getBox("sup0042").left - getBox("sup0041").right, v,
epsilon, "mmultiscripts: Space after first superscript"); |
| 75 assert_approx_equals(getBox("sup0043").left - getBox("sup0042").right, v,
epsilon, "mmultiscripts: Space after second superscript"); |
| 76 assert_approx_equals(getBox("ref004").left - getBox("sup0043").right, v, e
psilon, "mmultiscripts: Space after last superscript"); |
| 77 }, "SpaceAfterScript"); |
| 78 |
| 79 test(function() { |
| 80 var v = 7000 * emToPx; |
| 81 assert_approx_equals(getBox("ref101").bottom - getBox("sup102").bottom, v,
epsilon, "msup: Superscript shift"); |
| 82 assert_approx_equals(getBox("ref101").bottom - getBox("sup103").bottom, v,
epsilon, "msubsup: Superscript shift"); |
| 83 assert_approx_equals(getBox("ref101").bottom - getBox("sup1041").bottom, v
, epsilon, "mmultiscripts: First superscript shift"); |
| 84 assert_approx_equals(getBox("ref101").bottom - getBox("sup1042").bottom, v
, epsilon, "mmultiscripts: Second superscript shift"); |
| 85 assert_approx_equals(getBox("ref101").bottom - getBox("sup1043").bottom, v
, epsilon, "mmultiscripts: Last superscript shift"); |
| 86 }, "SuperscriptShiftUp"); |
| 87 |
| 88 test(function() { |
| 89 var v = 5000 * emToPx; |
| 90 assert_approx_equals(getBox("ref201").bottom - getBox("sup202").bottom, v,
epsilon, "msup: Superscript shift"); |
| 91 assert_approx_equals(getBox("ref201").bottom - getBox("sup203").bottom, v,
epsilon, "msubsup: Superscript shift"); |
| 92 assert_approx_equals(getBox("ref201").bottom - getBox("sup2041").bottom, v
, epsilon, "mmultiscripts: First superscript shift"); |
| 93 assert_approx_equals(getBox("ref201").bottom - getBox("sup2042").bottom, v
, epsilon, "mmultiscripts: Second superscript shift"); |
| 94 assert_approx_equals(getBox("ref201").bottom - getBox("sup2043").bottom, v
, epsilon, "mmultiscripts: Last superscript shift"); |
| 95 }, "SuperscriptShiftUpCramped"); |
| 96 |
| 97 test(function() { |
| 98 var v = 6000 * emToPx; |
| 99 assert_approx_equals(getBox("sub301").bottom - getBox("ref300").bottom, v,
epsilon, "msup: Subscript shift"); |
| 100 assert_approx_equals(getBox("sub302").bottom - getBox("ref300").bottom, v,
epsilon, "msubsup: Subscript shift"); |
| 101 assert_approx_equals(getBox("sub303").bottom - getBox("ref300").bottom, v,
epsilon, "mmultiscripts: First subscript shift"); |
| 102 assert_approx_equals(getBox("sub304").bottom - getBox("ref300").bottom, v,
epsilon, "mmultiscripts: Second subscript shift"); |
| 103 }, "SubscriptShiftDown"); |
| 104 |
| 105 test(function() { |
| 106 var v = 11000 * emToPx; |
| 107 assert_approx_equals(getBox("sub4011").top - getBox("sup4012").bottom, v,
epsilon, "msubsup: SubSuperscript gap"); |
| 108 assert_approx_equals(getBox("sub4021").top - getBox("sup4022").bottom, v,
epsilon, "mmultiscripts: SubSuperscript gap"); |
| 109 }, "SubSuperscriptGapMin"); |
| 110 |
| 111 test(function() { |
| 112 var v1 = 11000 * emToPx; |
| 113 var v2 = 3000 * emToPx; |
| 114 assert_approx_equals(getBox("sub501").top - getBox("sup501").bottom, v1, e
psilon, "msubsup: SubSuperscript gap"); |
| 115 assert_approx_equals(getBox("ref500").bottom - getBox("sup501").bottom, v2
, epsilon, "msubsup: Superscript bottom"); |
| 116 assert_approx_equals(getBox("sub502").top - getBox("sup502").bottom, v1, e
psilon, "mmultiscripts: SubSuperscript gap"); |
| 117 assert_approx_equals(getBox("ref500").bottom - getBox("sup502").bottom, v2
, epsilon, "mmultiscripts: Superscript bottom"); |
| 118 }, "SuperscriptBottomMaxWithSubscript"); |
| 119 |
| 120 test(function() { |
| 121 var v = 4000 * emToPx; |
| 122 assert_approx_equals(getBox("ref600").bottom - getBox("sub601").top, v, ep
silon, "msub: Subscript top"); |
| 123 }, "SubscriptTopMax"); |
| 124 |
| 125 test(function() { |
| 126 var v = 8000 * emToPx; |
| 127 assert_approx_equals(getBox("ref700").bottom - getBox("sub701").bottom, v,
epsilon, "msub: Superscript bottom"); |
| 128 }, "SuperscriptBottomMin"); |
| 129 |
| 130 test(function() { |
| 131 var v = 9000 * emToPx; |
| 132 assert_approx_equals(getBox("sub801").bottom - getBox("base801").bottom, v
, epsilon, "msub: Superscript drop"); |
| 133 }, "SubscriptBaselineDrop"); |
| 134 |
| 135 test(function() { |
| 136 var v = 10000 * emToPx; |
| 137 assert_approx_equals(getBox("sup901").bottom - getBox("base901").top, v, e
psilon, "msup: Superscript drop"); |
| 138 }, "SuperscriptBaselineDrop"); |
| 139 |
| 140 done(); |
| 141 } |
| 142 </script> |
| 143 </head> |
| 144 <body> |
| 145 <p> |
| 146 <math style="font-family: spaceafterscript3000;"> |
| 147 <msub> |
| 148 <mspace height="2em" width="2em" mathbackground="blue"/> |
| 149 <mspace id="sub001" height="1em" width="1em" mathbackground="red"/> |
| 150 </msub> |
| 151 <mspace id="ref001" height="1em" width="1em" mathbackground="green"/> |
| 152 </math> |
| 153 <math style="font-family: spaceafterscript3000;"> |
| 154 <msup> |
| 155 <mspace height="2em" width="2em" mathbackground="blue"/> |
| 156 <mspace id="sup002" height="1em" width="1em" mathbackground="red"/> |
| 157 </msup> |
| 158 <mspace id="ref002" height="1em" width="1em" mathbackground="green"/> |
| 159 </math> |
| 160 <math style="font-family: spaceafterscript3000;"> |
| 161 <msubsup> |
| 162 <mspace height="2em" width="2em" mathbackground="blue"/> |
| 163 <mspace/> |
| 164 <mspace id="sup003" height="1em" width="1em" mathbackground="red"/> |
| 165 </msubsup> |
| 166 <mspace id="ref003" height="1em" width="1em" mathbackground="green"/> |
| 167 </math> |
| 168 <math style="font-family: spaceafterscript3000;"> |
| 169 <mmultiscripts> |
| 170 <mspace height="2em" width="2em" mathbackground="blue"/> |
| 171 <none/> |
| 172 <mspace id="sup0041" height="1em" width="1em" mathbackground="red"/> |
| 173 <none/> |
| 174 <mspace id="sup0042" height="1em" width="1em" mathbackground="red"/> |
| 175 <none/> |
| 176 <mspace id="sup0043" height="1em" width="1em" mathbackground="red"/> |
| 177 </mmultiscripts> |
| 178 <mspace id="ref004" height="1em" width="1em" mathbackground="green"/> |
| 179 </math> |
| 180 </p> |
| 181 <hr/> |
| 182 <p> |
| 183 <math style="font-family: superscriptshiftup7000;"> |
| 184 <mspace id="ref101" height="1em" width="1em" mathbackground="green"/> |
| 185 <msup> |
| 186 <mspace height="2em" width="2em" mathbackground="blue"/> |
| 187 <mspace id="sup102" height="1em" width="1em" mathbackground="red"/> |
| 188 </msup> |
| 189 <msubsup> |
| 190 <mspace height="2em" width="2em" mathbackground="blue"/> |
| 191 <mspace height="1em" width="1em" mathbackground="red"/> |
| 192 <mspace id="sup103" height="1em" width="1em" mathbackground="red"/> |
| 193 </msubsup> |
| 194 <mmultiscripts> |
| 195 <mspace height="2em" width="2em" mathbackground="blue"/> |
| 196 <none/> |
| 197 <mspace id="sup1041" height="1em" width="1em" mathbackground="red"/> |
| 198 <none/> |
| 199 <mspace id="sup1042" height="1em" width="1em" mathbackground="red"/> |
| 200 <none/> |
| 201 <mspace id="sup1043" height="1em" width="1em" mathbackground="red"/> |
| 202 </mmultiscripts> |
| 203 </math> |
| 204 </p> |
| 205 <hr/> |
| 206 <p> |
| 207 <math style="font-family: superscriptshiftupcramped5000;"> |
| 208 <msqrt> |
| 209 <mspace id="ref201" height="1em" width="1em" mathbackground="green"/> |
| 210 <msup> |
| 211 <mspace height="2em" width="2em" mathbackground="blue"/> |
| 212 <mspace id="sup202" height="1em" width="1em" mathbackground="red"/> |
| 213 </msup> |
| 214 <msubsup> |
| 215 <mspace height="2em" width="2em" mathbackground="blue"/> |
| 216 <mspace height="1em" width="1em" mathbackground="blue"/> |
| 217 <mspace id="sup203" height="1em" width="1em" mathbackground="red"/> |
| 218 </msubsup> |
| 219 <mmultiscripts> |
| 220 <mspace height="2em" width="2em" mathbackground="blue"/> |
| 221 <none/> |
| 222 <mspace id="sup2041" height="1em" width="1em" mathbackground="red"/> |
| 223 <none/> |
| 224 <mspace id="sup2042" height="1em" width="1em" mathbackground="red"/> |
| 225 <none/> |
| 226 <mspace id="sup2043" height="1em" width="1em" mathbackground="red"/> |
| 227 </mmultiscripts> |
| 228 </msqrt> |
| 229 </math> |
| 230 </p> |
| 231 <hr/> |
| 232 <p> |
| 233 <math style="font-family: subscriptshiftdown6000;"> |
| 234 <mspace id="ref300" height="1em" width="1em" mathbackground="green"/> |
| 235 <msub> |
| 236 <mspace height="2em" width="2em" mathbackground="blue"/> |
| 237 <mspace id="sub301" height="1em" width="1em" mathbackground="red"/> |
| 238 </msub> |
| 239 <msubsup> |
| 240 <mspace height="2em" width="2em" mathbackground="blue"/> |
| 241 <mspace id="sub302" height="1em" width="1em" mathbackground="red"/> |
| 242 <mspace height="1em" width="1em" mathbackground="blue"/> |
| 243 </msubsup> |
| 244 <mmultiscripts> |
| 245 <mspace height="2em" width="2em" mathbackground="blue"/> |
| 246 <mspace id="sub303" height="1em" width="1em" mathbackground="red"/> |
| 247 <none/> |
| 248 <mspace id="sub304" height="1em" width="1em" mathbackground="red"/> |
| 249 <none/> |
| 250 </mmultiscripts> |
| 251 </math> |
| 252 </p> |
| 253 <hr/> |
| 254 <p> |
| 255 <math style="font-family: subsuperscriptgapmin11000;"> |
| 256 <msubsup> |
| 257 <mspace height="2em" width="2em" mathbackground="blue"/> |
| 258 <mspace id="sub4011" height="1em" width="1em" mathbackground="red"/> |
| 259 <mspace id="sup4012" height="1em" width="1em" mathbackground="red"/> |
| 260 </msubsup> |
| 261 <mmultiscripts> |
| 262 <mspace height="2em" width="2em" mathbackground="blue"/> |
| 263 <none/> |
| 264 <none/> |
| 265 <mspace id="sub4021" height="1em" width="1em" mathbackground="red"/> |
| 266 <mspace id="sup4022" height="1em" width="1em" mathbackground="red"/> |
| 267 </mmultiscripts> |
| 268 </math> |
| 269 </p> |
| 270 <hr/> |
| 271 <p> |
| 272 <math style="font-family: subsuperscriptgapmin11000superscriptbottommaxwit
hsubscript3000;"> |
| 273 <mspace id="ref500" height="1em" width="1em" mathbackground="green"/> |
| 274 <msubsup> |
| 275 <mspace height="2em" width="2em" mathbackground="blue"/> |
| 276 <mspace id="sub501" height="1em" width="1em" mathbackground="red"/> |
| 277 <mspace id="sup501" height="1em" width="1em" mathbackground="red"/> |
| 278 </msubsup> |
| 279 <mmultiscripts> |
| 280 <mspace height="2em" width="2em" mathbackground="blue"/> |
| 281 <none/> |
| 282 <none/> |
| 283 <mspace id="sub502" height="1em" width="1em" mathbackground="red"/> |
| 284 <mspace id="sup502" height="1em" width="1em" mathbackground="red"/> |
| 285 </mmultiscripts> |
| 286 </math> |
| 287 </p> |
| 288 <hr/> |
| 289 <p> |
| 290 <math style="font-family: subscripttopmax4000;"> |
| 291 <mspace id="ref600" height="1em" |
| 292 width="1em" mathbackground="green"/> |
| 293 <msub> |
| 294 <mspace height="2em" width="2em" mathbackground="blue"/> |
| 295 <mspace id="sub601" height="10em" |
| 296 width="1em" mathbackground="red"/> |
| 297 </msub> |
| 298 </math> |
| 299 </p> |
| 300 <hr/> |
| 301 <p> |
| 302 <math style="font-family: superscriptbottommin8000;"> |
| 303 <mspace id="ref700" height="1em" |
| 304 width="1em" mathbackground="green"/> |
| 305 <msup> |
| 306 <mspace height="2em" width="2em" mathbackground="blue"/> |
| 307 <mspace id="sub701" depth="1em" |
| 308 width="1em" mathbackground="red"/> |
| 309 </msup> |
| 310 </math> |
| 311 </p> |
| 312 <hr/> |
| 313 <p> |
| 314 <math style="font-family: subscriptbaselinedropmin9000;"> |
| 315 <msub> |
| 316 <mspace id="base801" height="2em" width="2em" mathbackground="blue"/> |
| 317 <mspace id="sub801" height="1em" |
| 318 width="1em" mathbackground="red"/> |
| 319 </msub> |
| 320 </math> |
| 321 </p> |
| 322 <hr/> |
| 323 <p> |
| 324 <math style="font-family: superscriptbaselinedropmax10000;"> |
| 325 <msup> |
| 326 <mspace id="base901" height="15em" width="2em" mathbackground="blue"/> |
| 327 <mspace id="sup901" height="1em" |
| 328 width="1em" mathbackground="red"/> |
| 329 </msup> |
| 330 </math> |
| 331 </p> |
| 332 <hr/> |
| 333 </body> |
| 334 </html> |
OLD | NEW |