summaryrefslogtreecommitdiffstats
path: root/layout/mathml/tests/test_opentype-fraction.html
blob: ad25b2e4d3dbd87da931229a20cd354b397ddc1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<!doctype html>
<html>
  <head>
    <title>Open Type MATH - fraction</title>
    <script type="application/javascript"
            src="/tests/SimpleTest/SimpleTest.js"></script>
    <script type="application/javascript"
            src="/tests/SimpleTest/EventUtils.js"></script>
    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    <meta charset="utf-8"/>
    <style type="text/css">
      math {
        font-size: 10px;
      }
      @font-face {
        font-family: fraction-1;
        src: url(/tests/fonts/math/fraction-1.otf);
      }
      @font-face {
        font-family: fraction-2;
        src: url(/tests/fonts/math/fraction-2.otf);
      }
      @font-face {
        font-family: fraction-3;
        src: url(/tests/fonts/math/fraction-3.otf);
      }
      @font-face {
        font-family: fraction-4;
        src: url(/tests/fonts/math/fraction-4.otf);
      }
      @font-face {
        font-family: fraction-5;
        src: url(/tests/fonts/math/fraction-5.otf);
      }
      @font-face {
        font-family: fraction-6;
        src: url(/tests/fonts/math/fraction-6.otf);
      }
      @font-face {
        font-family: fraction-7;
        src: url(/tests/fonts/math/fraction-7.otf);
      }
      @font-face {
        font-family: fraction-8;
        src: url(/tests/fonts/math/fraction-8.otf);
      }
      @font-face {
        font-family: fraction-9;
        src: url(/tests/fonts/math/fraction-9.otf);
      }
    </style>
    <script type="text/javascript">
      var epsilon = 5;
      function almostEqual(x, y) { return Math.abs(x - y) < epsilon; }

      function getBox(aId) {
        return document.getElementById(aId).getBoundingClientRect();
      }

      function doTest() {
        /* inline style */
        var ref = getBox("ref").height;

        ok(almostEqual(getBox("d1").top - getBox("n1").bottom, ref * 20),
           "Bad FractionRuleThickness");

        ok(almostEqual(getBox("n1").top, getBox("n2").top) &&
           almostEqual(getBox("d2").top - getBox("n2").bottom, ref * 10.5),
           "Bad FractionNumeratorGapMin");

        ok(almostEqual(getBox("d1").bottom, getBox("d3").bottom) &&
           almostEqual(getBox("d3").top - getBox("n3").bottom, ref * 10.5),
           "Bad FractionDenominatorGapMin");

        ok(almostEqual(getBox("ref").top - getBox("n4").top, ref*3),
           "Bad FractionNumeratorShiftUp");

        ok(almostEqual(getBox("d5").bottom - getBox("ref").bottom, ref*3),
           "Bad FractionDenominatorShiftDown");

        /* display style */
        ref = getBox("dref").height;

        ok(almostEqual(getBox("dd1").top - getBox("dn1").bottom, ref * 20),
           "Bad FractionRuleThickness");

        ok(almostEqual(getBox("dn1").top, getBox("n6").top) &&
           almostEqual(getBox("d6").top - getBox("n6").bottom, ref * 10.5),
           "Bad FractionNumeratorDisplayStyleGapMin");

        ok(almostEqual(getBox("dd1").bottom, getBox("d7").bottom) &&
           almostEqual(getBox("d7").top - getBox("n7").bottom, ref * 10.5),
           "Bad FractionDenominatorDisplayStyleGapMin");

        ok(almostEqual(getBox("dref").top - getBox("n8").top, ref*3),
           "Bad FractionNumeratorDisplayStyleShiftUp");

        ok(almostEqual(getBox("d9").bottom - getBox("dref").bottom, ref*3),
           "Bad FractionDenominatorDisplayStyleShiftDown");

        SimpleTest.finish();
      }
    </script>
  </head>
  <body onload="doTest()">

    <a target="_blank"
       href="https://bugzilla.mozilla.org/show_bug.cgi?id=961365">
      Mozilla Bug 961365
    </a>

    <p id="display"></p>

    <p>
      <math>
        <mspace id="ref" height="1em" width="1em" mathbackground="green"/>
      </math>
      <math style="font-family: fraction-1;">
        <mfrac>
          <mspace id="n1" height="1em" width="1em" mathbackground="red"/>
          <mspace id="d1" height="1em" width="1em" mathbackground="red"/>
        </mfrac>
      </math>
      <math style="font-family: fraction-2;">
        <mfrac>
          <mspace id="n2" height="1em" width="1em" mathbackground="red"/>
          <mspace id="d2" height="1em" width="1em" mathbackground="red"/>
        </mfrac>
      </math>
      <math style="font-family: fraction-3;">
        <mfrac>
          <mspace id="n3" height="1em" width="1em" mathbackground="red"/>
          <mspace id="d3" height="1em" width="1em" mathbackground="red"/>
        </mfrac>
      </math>
      <math style="font-family: fraction-4;">
        <mfrac>
          <mspace id="n4" height="1em" width="1em" mathbackground="red"/>
          <mspace id="d4" height="1em" width="1em" mathbackground="red"/>
        </mfrac>
      </math>
      <math style="font-family: fraction-5;">
        <mfrac>
          <mspace id="n5" height="1em" width="1em" mathbackground="red"/>
          <mspace id="d5" height="1em" width="1em" mathbackground="red"/>
        </mfrac>
      </math>
    </p>

    <p>
      <math displaystyle="true">
        <mspace id="dref" height="1em" width="1em" mathbackground="green"/>
      </math>
      <math displaystyle="true" style="font-family: fraction-1;">
        <mfrac>
          <mspace id="dn1" height="1em" width="1em" mathbackground="red"/>
          <mspace id="dd1" height="1em" width="1em" mathbackground="red"/>
        </mfrac>
      </math>
      <math displaystyle="true" style="font-family: fraction-6;">
        <mfrac>
          <mspace id="n6" height="1em" width="1em" mathbackground="red"/>
          <mspace id="d6" height="1em" width="1em" mathbackground="red"/>
        </mfrac>
      </math>
      <math displaystyle="true" style="font-family: fraction-7;">
        <mfrac>
          <mspace id="n7" height="1em" width="1em" mathbackground="red"/>
          <mspace id="d7" height="1em" width="1em" mathbackground="red"/>
        </mfrac>
      </math>
      <math displaystyle="true" style="font-family: fraction-8;">
        <mfrac>
          <mspace id="n8" height="1em" width="1em" mathbackground="red"/>
          <mspace id="d8" height="1em" width="1em" mathbackground="red"/>
        </mfrac>
      </math>
      <math displaystyle="true" style="font-family: fraction-9;">
        <mfrac>
          <mspace id="n9" height="1em" width="1em" mathbackground="red"/>
          <mspace id="d9" height="1em" width="1em" mathbackground="red"/>
        </mfrac>
      </math>
    </p>

  </body>
</html>