Bug 407059 - Part 5: Add reftest. r=karlt
authorFrédéric Wang <fred.wang@free.fr>
Wed, 23 Apr 2014 06:57:43 -0700
changeset 179771 427e3e62d7f3fac1bda0396254abe2f03bd318fd
parent 179770 39bcb94e9b85bb72ea926dd359f057df5e086ac0
child 179772 a7289f22cafd1a4290fde3e8bb613030b3bff4f6
push id26639
push userryanvm@gmail.com
push dateWed, 23 Apr 2014 20:42:51 +0000
treeherdermozilla-central@ed0236a51ed3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs407059
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 407059 - Part 5: Add reftest. r=karlt
layout/reftests/fonts/math/README
layout/reftests/fonts/math/generate.py
layout/reftests/fonts/math/stretchy.otf
layout/reftests/mathml/opentype-stretchy-ref.html
layout/reftests/mathml/opentype-stretchy.html
layout/reftests/mathml/reftest.list
new file mode 100644
--- /dev/null
+++ b/layout/reftests/fonts/math/README
@@ -0,0 +1,6 @@
+The fonts in this directory are autogenerated with FontForge using the Python
+script generate.py. See the comments in that file for more information on how
+to run the script.
+
+These fonts are intended to test the The MATH table and OpenType Features used
+in MathML. See layout/reftests/mathml/
new file mode 100644
--- /dev/null
+++ b/layout/reftests/fonts/math/generate.py
@@ -0,0 +1,231 @@
+#!/usr/bin/python
+# vim: set shiftwidth=4 tabstop=8 autoindent expandtab:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# For general fontforge documentation, see:
+#   http://fontforge.sourceforge.net/
+# For fontforge scripting documentation, see:
+#   http://fontforge.sourceforge.net/scripting-tutorial.html
+#   http://fontforge.sourceforge.net/scripting.html
+# and most importantly:
+#   http://fontforge.sourceforge.net/python.html
+
+# To install what you need, on Ubuntu,
+#   sudo apt-get install python-fontforge
+
+from __future__ import print_function
+import fontforge
+
+em = 1000
+
+def newMathFont(aName):
+    print("Generating %s.otf..." % aName, end="")
+    mathFont = fontforge.font()
+    mathFont.fontname = aName
+    mathFont.familyname = aName
+    mathFont.fullname = aName
+    mathFont.copyright = "Copyright (c) 2014 Mozilla Corporation"
+    mathFont.encoding = "UnicodeFull"
+
+    # Create a space character. Also force the creation of some MATH subtables
+    # so that OTS will not reject the MATH table.
+    g = mathFont.createChar(ord(" "), "space")
+    g.width = em
+    g.italicCorrection = 0
+    g.topaccent = 0
+    g.mathKern.bottomLeft = tuple([(0,0)])
+    g.mathKern.bottomRight = tuple([(0,0)])
+    g.mathKern.topLeft = tuple([(0,0)])
+    g.mathKern.topRight = tuple([(0,0)])
+    mathFont[ord(" ")].horizontalVariants = "space"
+    mathFont[ord(" ")].verticalVariants = "space"
+    return mathFont
+
+def saveMathFont(aFont):
+    aFont.em = em
+    aFont.ascent = aFont.descent = em/2
+    aFont.hhea_ascent = aFont.os2_typoascent = aFont.os2_winascent = em/2
+    aFont.descent = aFont.hhea_descent = em/2
+    aFont.os2_typodescent = aFont.os2_windescent = em/2
+    aFont.hhea_ascent_add = aFont.hhea_descent_add = 0
+    aFont.os2_typoascent_add = aFont.os2_typodescent_add = 0
+    aFont.os2_winascent_add = aFont.os2_windescent_add = 0
+    aFont.os2_use_typo_metrics = True
+    aFont.generate(aFont.fontname + ".otf")
+    print(" done.")
+
+################################################################################
+# Glyph variants and constructions
+f = newMathFont("stretchy")
+nvariants = 3
+
+# Draw boxes for the size variants and glues
+for i in range(0, nvariants):
+    s = em * (i + 1)
+
+    g = f.createChar(-1, "h%d" % i)
+    p = g.glyphPen()
+    p.moveTo(0, -em)
+    p.lineTo(0, em)
+    p.lineTo(s, em)
+    p.lineTo(s, -em)
+    p.closePath()
+    g.width = s
+
+    g = f.createChar(-1, "v%d" % i)
+    p = g.glyphPen()
+    p.moveTo(0, 0)
+    p.lineTo(0, s)
+    p.lineTo(2 * em, s)
+    p.lineTo(2 * em, 0)
+    p.closePath();
+    g.width = 2 * em
+
+# Draw some pieces for stretchy operators
+s = em * nvariants
+
+g = f.createChar(-1, "left")
+p = g.glyphPen()
+p.moveTo(0, -2 * em)
+p.lineTo(0, 2 * em)
+p.lineTo(s, em)
+p.lineTo(s, -em)
+p.closePath();
+g.width = s
+
+g = f.createChar(-1, "right")
+p = g.glyphPen()
+p.moveTo(0, -em)
+p.lineTo(0, em)
+p.lineTo(s, 2 * em)
+p.lineTo(s, -2 * em)
+p.closePath();
+g.width = s
+
+g = f.createChar(-1, "hmid")
+p = g.glyphPen()
+p.moveTo(0, -em)
+p.lineTo(0, em)
+p.lineTo(s, 2 * em)
+p.lineTo(2 * s, em)
+p.lineTo(2 * s, -em)
+p.lineTo(s, -2 * em)
+p.closePath();
+g.width = 2 * s
+
+g = f.createChar(-1, "bottom")
+p = g.glyphPen()
+p.moveTo(0, 0)
+p.lineTo(0, s)
+p.lineTo(2 * em, s)
+p.lineTo(4 * em, 0)
+p.closePath();
+g.width = 4 * em
+
+g = f.createChar(-1, "top")
+p = g.glyphPen()
+p.moveTo(0, 0)
+p.lineTo(4 * em, 0)
+p.lineTo(2 * em, -s)
+p.lineTo(0, -s)
+p.closePath();
+g.width = 4 * em
+
+g = f.createChar(-1, "vmid")
+p = g.glyphPen()
+p.moveTo(0, s)
+p.lineTo(2 * em, s)
+p.lineTo(4 * em, 0)
+p.lineTo(2 * em, -s)
+p.lineTo(0, -s)
+p.closePath();
+g.width = 3 * em
+
+# Create small rectangle of various size for some exotic arrows that are
+# unlikely to be stretchable with standard fonts.
+hstretchy = [
+    0x219C, # leftwards wave arrow
+    0x219D, # rightwards wave arrow
+    0x219E, # leftwards two headed arrow
+    0x21A0, # rightwards two headed arrow
+    0x21A2  # leftwards arrow with tail
+]
+vstretchy = [
+    0x219F, # upwards two headed arrow
+    0x21A1, # downwards two headed arrow
+    0x21A5, # upwards arrow from bar
+    0x21A7, # downwards arrow from bar
+    0x21A8  # up down arrow with base
+]
+for i in range(0, 1 + nvariants + 1):
+    s = (i + 1) * em/10
+
+    g = f.createChar(hstretchy[i])
+    p = g.glyphPen()
+    p.moveTo(0, -em/10)
+    p.lineTo(0, em/10)
+    p.lineTo(s, em/10)
+    p.lineTo(s, -em/10)
+    p.closePath()
+    g.width = s
+
+    g = f.createChar(vstretchy[i])
+    p = g.glyphPen()
+    p.moveTo(0, 0)
+    p.lineTo(0, s)
+    p.lineTo(2 * em/10, s)
+    p.lineTo(2 * em/10, 0)
+    p.closePath();
+    g.width = 2 * em/10
+
+# hstretchy[0] and vstretchy[0] have all the variants and the components. The others only have one of them.
+s = em * nvariants
+
+f[hstretchy[0]].horizontalVariants = "uni219C h0 h1 h2"
+f[hstretchy[0]].horizontalComponents = (("left", False, 0, 0, s), \
+("h2", True, 0, 0, s), ("hmid", False, 0, 0, 2 * s), ("h2", True, 0, 0, s), \
+("right", False, 0, 0, s))
+
+f[hstretchy[1]].horizontalVariants = "uni219D h0"
+f[hstretchy[2]].horizontalVariants = "uni219E h1"
+f[hstretchy[3]].horizontalVariants = "uni21A0 h2"
+f[hstretchy[4]].horizontalVariants = "uni21A2 h2"
+f[hstretchy[4]].horizontalComponents = f[hstretchy[0]].horizontalComponents
+
+f[vstretchy[0]].verticalVariants = "uni219F v0 v1 v2"
+f[vstretchy[0]].verticalComponents = (("bottom", False, 0, 0, s), \
+("v2", True, 0, 0, s), ("vmid", False, 0, 0, 2 * s), ("v2", True, 0, 0, s), \
+("top", False, 0, 0, s))
+
+f[vstretchy[1]].verticalVariants = "uni21A1 v0"
+f[vstretchy[2]].verticalVariants = "uni21A5 v1"
+f[vstretchy[3]].verticalVariants = "uni21A7 v2"
+f[vstretchy[4]].verticalVariants = "uni21A8"
+f[vstretchy[4]].verticalComponents = f[vstretchy[0]].verticalComponents
+
+################################################################################
+# Testing DisplayOperatorMinHeight
+f.math.DisplayOperatorMinHeight =  8 * em
+largeop = [0x2A1B, 0x2A1C] # integral with overbar/underbar
+
+# Draw boxes of size 1, 2, 7, 8, 9em.
+for i in [1, 2, 7, 8, 9]:
+    s = em * i
+    if i == 1 or i == 2:
+        g = f.createChar(largeop[i-1])
+    else:
+        g = f.createChar(-1, "L%d" % i)
+    p = g.glyphPen()
+    p.moveTo(0, 0)
+    p.lineTo(0, s)
+    p.lineTo(s, s)
+    p.lineTo(s, 0)
+    p.closePath();
+    g.width = s
+
+f[largeop[0]].verticalVariants = "uni2A1B L7 L8 L9"
+f[largeop[1]].verticalVariants = "uni2A1C L8"
+
+saveMathFont(f)
new file mode 100644
index 0000000000000000000000000000000000000000..f192de346316ee35c7da99356a83361b28ed7b61
GIT binary patch
literal 3336
zc%0o=Yiv_x7=GXOw7Yb49k7e;jGf7V0dBMnGA<(-Oc#D^4ulXS4bp9ePPeso-MFL}
zq6Fp+%2m7}P7-uKh$e;zB+NAWLnJ1QA0!$HfoKGOn8i3~DX{r`=bUyIB4YUG+4;Wr
zeV^}n-}gJ;t=}5ftZ5({?IbffYieti^4mwuL>4EJw6wN%P5monr~8O9f<z?OFI%(X
zx5MpAVDBX|r#Gyg=g#@2Y9<jYXy4e><_*?#HC#d4NnnkBpSQWh-Bymab0`b^0A_40
zc>($mN~ymsyp;!_QPyEp;WqEqAQi2I$_1#b?cO$@<H(_3VDBU{%?$=R!XvxMjs7{%
zt`G|<QQUDb`cih)EwY(!if9)*ds;{3(2D70)5~C{lZo^PK0L%jv|ix%3Q#kRe~O4!
zYBfn3(}MgxCh-+}b;;Mr#fWDjt2yN*qHG)&CrZj3S<j`_G$xZ`e1V-lPoXpEc|&LP
zcaNbX2^}+ZGnLYyp-Ys`GY#EB4qj#GR^VYUS;~M_r+EpT$w8flZlWyOZ|G)PK_?7d
zLY%3FZXt!|8M+mCBh^rVg0zi7)IyudPhosR88y*tNH;mjMf0K6gS8!uR{VKk3$GCT
zMD2x73$%8knm}+{sAaQ1tdup)R@_e4e5F3Hy`{C)tJDNS!9d6xZV7<b0hbW@P&Xmv
zHUQy}FWlsZRu8xt@j9suhOf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i6{IK-+MIp!CRYXfBUE>N|
zKB_ENimU(A$#ve4vmb$b1l`#12t2pW)nrm16Js3i9#h8nb1u>S%h0QE;^je>LMHDx
ztet~ntx}XMnoI>W?H_xkGpF)bd;#88+?pzAIc`qtwG;C->Y;=5DSb&_(}fhf55I~Q
z{H|u3f2W+ZOEkrHmc-2}jlS0~p=WTp)+Y2!KA>^>w2TsEf%9bHi&R*=jO6LFHO?e(
zg`LcC3Oo~X*uiz6ZL*QWj2w0&hlCssBZn0^1m_g=biQTq#a%962-_J{Qw)vi38Cc&
z$6*C2-sAaAP1%!EoV=9ZD3<%!e)@b{Fzy*x>o&~wB-mCIF;0?pcf~zfyU90`wyODQ
mL+&@^kS>!&aMK1xWwMBTNhylxQ+BUjgk89fNbE83U%=n(=YQ`2
new file mode 100644
--- /dev/null
+++ b/layout/reftests/mathml/opentype-stretchy-ref.html
@@ -0,0 +1,73 @@
+<!doctype html>
+<html>
+  <head>
+    <title>Open Type MATH - stretchy operator</title>
+    <meta charset="utf-8"/>
+    <style type="text/css">
+      @font-face {
+        font-family: stretchy;
+        src: url(../fonts/math/stretchy.otf);
+      }
+      math {
+        font-family: stretchy;
+        font-size: 10px;
+      }
+      ::-moz-math-stretchy {
+        font-family: stretchy;
+        font-size: 10px;
+      }
+    </style>
+  </head>
+  <body>
+
+<!--
+hstretchy = [
+    0x219C, # leftwards wave arrow
+    0x219D, # rightwards wave arrow
+    0x219E, # leftwards two headed arrow
+    0x21A0, # rightwards two headed arrow
+    0x21A2  # leftwards arrow with tail
+]
+vstretchy = [
+    0x219F, # upwards two headed arrow
+    0x21A1, # downwards two headed arrow
+    0x21A5, # upwards arrow from bar
+    0x21A7, # downwards arrow from bar
+    0x21A8  # up down arrow with base
+]
+
+hstretchy[0] and vstretchy[0] have all the variants and the components. The others only have one of them.
+-->
+
+    <p>
+      <math>
+        <mstyle scriptsizemultiplier="1">
+          <mover><mo stretchy="true">&#x219D;</mo><mspace width="1em" height="1px" mathbackground="red"/></mover>
+          <mover><mo stretchy="true">&#x219E;</mo><mspace width="2em" height="1px" mathbackground="red"/></mover>
+          <mover><mo stretchy="true">&#x21A0;</mo><mspace width="3em" height="1px" mathbackground="red"/></mover>
+          <mover><mo stretchy="true">&#x21A2;</mo><mspace width="15em" height="1px" mathbackground="red"/></mover>
+        </mstyle>
+      </math>
+    </p>
+
+    <p>
+      <math><mrow><mo symmetric="false" stretchy="true" minsize="1em">&#x21A1;</mo></mrow></math>
+      <math><mrow><mo symmetric="false" stretchy="true" minsize="2em">&#x21A5;</mo></mrow></math>
+      <math><mrow><mo symmetric="false" stretchy="true" minsize="3em">&#x21A7;</mo></mrow></math>
+      <math><mrow><mo symmetric="false" stretchy="true" minsize="15em">&#x21A8;</mo></mrow></math>
+    </p>
+
+<!--
+DisplayOperatorMinHeight = 8em
+largeop = [0x2A1B, 0x2A1C] # integral with overbar/underbar
+largeop[0] has variants of size 7, 8, 9em
+largeop[1] has one variant of size 8em.
+-->
+    <p>
+      <math displaystyle="true">
+        <mrow><mo>&#x2A1C;</mo></mrow>
+      </math>
+    </p>
+
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/mathml/opentype-stretchy.html
@@ -0,0 +1,73 @@
+<!doctype html>
+<html>
+  <head>
+    <title>Open Type MATH - stretchy operator</title>
+    <meta charset="utf-8"/>
+    <style type="text/css">
+      @font-face {
+        font-family: stretchy;
+        src: url(../fonts/math/stretchy.otf);
+      }
+      math {
+        font-family: stretchy;
+        font-size: 10px;
+      }
+      ::-moz-math-stretchy {
+        font-family: stretchy;
+        font-size: 10px;
+      }
+    </style>
+  </head>
+  <body>
+
+<!--
+hstretchy = [
+    0x219C, # leftwards wave arrow
+    0x219D, # rightwards wave arrow
+    0x219E, # leftwards two headed arrow
+    0x21A0, # rightwards two headed arrow
+    0x21A2  # leftwards arrow with tail
+]
+vstretchy = [
+    0x219F, # upwards two headed arrow
+    0x21A1, # downwards two headed arrow
+    0x21A5, # upwards arrow from bar
+    0x21A7, # downwards arrow from bar
+    0x21A8  # up down arrow with base
+]
+
+hstretchy[0] and vstretchy[0] have all the variants and the components. The others only have one of them.
+-->
+
+    <p>
+      <math>
+        <mstyle scriptsizemultiplier="1">
+          <mover><mo stretchy="true">&#x219C;</mo><mspace width="1em" height="1px" mathbackground="red"/></mover>
+          <mover><mo stretchy="true">&#x219C;</mo><mspace width="2em" height="1px" mathbackground="red"/></mover>
+          <mover><mo stretchy="true">&#x219C;</mo><mspace width="3em" height="1px" mathbackground="red"/></mover>
+          <mover><mo stretchy="true">&#x219C;</mo><mspace width="15em" height="1px" mathbackground="red"/></mover>
+        </mstyle>
+      </math>
+    </p>
+
+    <p>
+      <math><mrow><mo symmetric="false" stretchy="true" minsize="1em">&#x219F;</mo></mrow></math>
+      <math><mrow><mo symmetric="false" stretchy="true" minsize="2em">&#x219F;</mo></mrow></math>
+      <math><mrow><mo symmetric="false" stretchy="true" minsize="3em">&#x219F;</mo></mrow></math>
+      <math><mrow><mo symmetric="false" stretchy="true" minsize="15em">&#x219F;</mo></mrow></math>
+    </p>
+
+<!--
+DisplayOperatorMinHeight = 8em
+largeop = [0x2A1B, 0x2A1C] # integral with overbar/underbar
+largeop[0] has variants of size 7, 8, 9em
+largeop[1] has one variant of size 8em.
+-->
+    <p>
+      <math displaystyle="true">
+        <mrow><mo>&#x2A1B;</mo></mrow>
+      </math>
+    </p>
+
+  </body>
+</html>
--- a/layout/reftests/mathml/reftest.list
+++ b/layout/reftests/mathml/reftest.list
@@ -147,16 +147,17 @@ skip-if(B2G) == maction-dynamic-1.html m
 == mo-invisibleoperators.html mo-invisibleoperators-ref.html
 == mo-invisibleoperators-2.html mo-invisibleoperators-2-ref.html
 skip-if(B2G) == maction-dynamic-3.html maction-dynamic-3-ref.html # bug 773482
 == whitespace-trim-1.html whitespace-trim-1-ref.html
 == whitespace-trim-2.html whitespace-trim-2-ref.html
 == whitespace-trim-3.html whitespace-trim-3-ref.html
 fails == whitespace-trim-4.html whitespace-trim-4-ref.html # Bug 787215
 == whitespace-trim-5.html whitespace-trim-5-ref.html
+fails-if(winWidget&&!d2d) == opentype-stretchy.html opentype-stretchy-ref.html
 == operator-1.xhtml operator-1-ref.xhtml
 == scriptshift-1.xhtml scriptshift-1-ref.xhtml
 == number-size-1.xhtml number-size-1-ref.xhtml
 fails-if(B2G) == multiscripts-1.html multiscripts-1-ref.html # B2G - slight height variation from font metrics
 == mathml-mmultiscript-base.html mathml-mmultiscript-base-ref.html
 == mathml-mmultiscript-mprescript.html mathml-mmultiscript-mprescript-ref.html
 != menclose-1a.html menclose-1-ref.html
 != menclose-1b.html menclose-1-ref.html