OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf-8"> |
| 5 <title>Subscripts and Superscripts metrics</title> |
| 6 <link rel="help" href="http://www.mathml-association.org/MathMLinHTML5/S3.html#S
S4"> |
| 7 <meta name="assert" content="Verify metrics of scripted elements for bases of di
fferent heights."> |
| 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 </style> |
| 15 <script> |
| 16 /* This test does not use any specific fonts and so the exact rules are not |
| 17 specified precisely. We assume reasonable values for script shifts and |
| 18 spacing. */ |
| 19 |
| 20 function getBox(aId) { |
| 21 var box = document.getElementById(aId).getBoundingClientRect(); |
| 22 box.middle = (box.bottom + box.top) / 2; |
| 23 return box; |
| 24 } |
| 25 |
| 26 setup({ explicit_done: true }); |
| 27 window.addEventListener("load", runTests); |
| 28 |
| 29 var sizeArray = [50, 75, 100]; |
| 30 |
| 31 function runTests() { |
| 32 test(function() { |
| 33 var e = 1; |
| 34 sizeArray.forEach(function(size) { |
| 35 assert_approx_equals(getBox("msub" + size + "base").middle, getBox("bas
eline").bottom, e, "msub base " + size + "is placed on the baseline"); |
| 36 assert_approx_equals(getBox("msup" + size + "base").middle, getBox("bas
eline").bottom, e, "msup base " + size + "is placed on the baseline"); |
| 37 assert_approx_equals(getBox("msubsup" + size + "base").middle, getBox("
baseline").bottom, e, "msubsup base " + size + "is placed on the baseline"); |
| 38 assert_approx_equals(getBox("multi" + size + "base").middle, getBox("ba
seline").bottom, e, "mmultiscripts base " + size + "is placed on the baseline"); |
| 39 }); |
| 40 }, "Alignment on the baseline for bases of different heights"); |
| 41 |
| 42 test(function() { |
| 43 var e = 5; |
| 44 sizeArray.forEach(function(size) { |
| 45 assert_approx_equals(getBox("msub" + size + "sub").middle, getBox("msub
" + size + "base").bottom, e, "msub script " + size + "is placed at the top of o
f the base"); |
| 46 }); |
| 47 }, "Vertical position of the scripts for bases of different heights"); |
| 48 |
| 49 done(); |
| 50 } |
| 51 </script> |
| 52 </head> |
| 53 <body> |
| 54 <p> |
| 55 <math> |
| 56 <mspace id="baseline" width="30px" height="2px" depth="0px" mathbackground
="blue"/> |
| 57 <msub id="msub50"> |
| 58 <mspace id="msub50base" width="30px" height="50px" depth="50px" mathback
ground="black"/> |
| 59 <mspace id="msub50sub" width="10px" height="5px" depth="5px" mathbackgro
und="black"/> |
| 60 </msub> |
| 61 <msup id="msup50"> |
| 62 <mspace id="msup50base" width="30px" height="50px" depth="50px" mathback
ground="black"/> |
| 63 <mspace id="msup50sup" width="10px" height="5px" depth="5px" mathbackgro
und="black"/> |
| 64 </msup> |
| 65 <msubsup id="msubsup50"> |
| 66 <mspace id="msubsup50base" width="30px" height="50px" depth="50px" mathb
ackground="black"/> |
| 67 <mspace id="msubsup50sub" width="10px" height="5px" depth="5px" mathback
ground="black"/> |
| 68 <mspace id="msubsup50sup" width="10px" height="5px" depth="5px" mathback
ground="black"/> |
| 69 </msubsup> |
| 70 <mmultiscripts id="multi50"> |
| 71 <mspace id="multi50base" width="30px" height="50px" depth="50px" mathbac
kground="black"/> |
| 72 <mspace id="multi50postsub" width="10px" height="5px" depth="5px" mathba
ckground="black"/> |
| 73 <mspace id="multi50postsup" width="10px" height="5px" depth="5px" mathba
ckground="black"/> |
| 74 <mprescripts/> |
| 75 <mspace id="multi50presub" width="10px" height="5px" depth="5px" mathbac
kground="black"/> |
| 76 <mspace id="multi50presup" width="10px" height="5px" depth="5px" mathbac
kground="black"/> |
| 77 </mmultiscripts> |
| 78 <msub id="msub75"> |
| 79 <mspace id="msub75base" width="30px" height="75px" depth="75px" mathback
ground="black"/> |
| 80 <mspace id="msub75sub" width="10px" height="5px" depth="5px" mathbackgro
und="black"/> |
| 81 </msub> |
| 82 <msup id="msup75"> |
| 83 <mspace id="msup75base" width="30px" height="75px" depth="75px" mathback
ground="black"/> |
| 84 <mspace id="msup75sup" width="10px" height="5px" depth="5px" mathbackgro
und="black"/> |
| 85 </msup> |
| 86 <msubsup id="msubsup75"> |
| 87 <mspace id="msubsup75base" width="30px" height="75px" depth="75px" mathb
ackground="black"/> |
| 88 <mspace id="msubsup75sub" width="10px" height="5px" depth="5px" mathback
ground="black"/> |
| 89 <mspace id="msubsup75sup" width="10px" height="5px" depth="5px" mathback
ground="black"/> |
| 90 </msubsup> |
| 91 <mmultiscripts id="multi75"> |
| 92 <mspace id="multi75base" width="30px" height="75px" depth="75px" mathbac
kground="black"/> |
| 93 <mspace id="multi75postsub" width="10px" height="5px" depth="5px" mathba
ckground="black"/> |
| 94 <mspace id="multi75postsup" width="10px" height="5px" depth="5px" mathba
ckground="black"/> |
| 95 <mprescripts/> |
| 96 <mspace id="multi75presub" width="10px" height="5px" depth="5px" mathbac
kground="black"/> |
| 97 <mspace id="multi75presub" width="10px" height="5px" depth="5px" mathbac
kground="black"/> |
| 98 </mmultiscripts> |
| 99 <msub id="msub100"> |
| 100 <mspace id="msub100base" width="30px" height="100px" depth="100px" mathb
ackground="black"/> |
| 101 <mspace id="msub100sub" width="10px" height="5px" depth="5px" mathbackgr
ound="black"/> |
| 102 </msub> |
| 103 <msup id="msup100"> |
| 104 <mspace id="msup100base" width="30px" height="100px" depth="100px" mathb
ackground="black"/> |
| 105 <mspace id="msup100sup" width="10px" height="5px" depth="5px" mathbackgr
ound="black"/> |
| 106 </msup> |
| 107 <msubsup id="msubsup100"> |
| 108 <mspace id="msubsup100base" width="30px" height="100px" depth="100px" ma
thbackground="black"/> |
| 109 <mspace id="msubsup100sub" width="10px" height="5px" depth="5px" mathbac
kground="black"/> |
| 110 <mspace id="msubsup100sup" width="10px" height="5px" depth="5px" mathbac
kground="black"/> |
| 111 </msubsup> |
| 112 <mmultiscripts id="multi100"> |
| 113 <mspace id="multi100base" width="30px" height="100px" depth="100px" math
background="black"/> |
| 114 <mspace id="multi100postsub" width="10px" height="5px" depth="5px" mathb
ackground="black"/> |
| 115 <mspace id="multi100postsup" width="10px" height="5px" depth="5px" mathb
ackground="black"/> |
| 116 <mprescripts/> |
| 117 <mspace id="multi100presub" width="10px" height="5px" depth="5px" mathba
ckground="black"/> |
| 118 <mspace id="multi100presup" width="10px" height="5px" depth="5px" mathba
ckground="black"/> |
| 119 </mmultiscripts> |
| 120 </math> |
| 121 </p> |
| 122 <hr/> |
| 123 </body> |
| 124 </html> |
OLD | NEW |