# HG changeset patch # Parent 2b583fdbae0cc1d95237a3bc8f9ecd74541dfca1 # User Frédéric Wang Part 4: reftest. r=karl, b=407059 diff --git a/layout/reftests/fonts/math/README b/layout/reftests/fonts/math/README 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/ diff --git a/layout/reftests/fonts/math/generate.py b/layout/reftests/fonts/math/generate.py new file mode 100644 --- /dev/null +++ b/layout/reftests/fonts/math/generate.py @@ -0,0 +1,230 @@ +#!/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 = 1024 + +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(2 * em, 0) + p.lineTo(2 * em, s) + p.lineTo(0, s) + 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(4 * em, 0) +p.lineTo(2 * em, s) +p.lineTo(0, s) +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(2 * em/10, 0) + p.lineTo(2 * em/10, s) + p.lineTo(0, s) + 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 = "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 = "h0" +f[hstretchy[2]].horizontalVariants = "h1" +f[hstretchy[3]].horizontalVariants = "h2" +f[hstretchy[4]].horizontalComponents = f[hstretchy[0]].horizontalComponents + + +f[vstretchy[0]].verticalVariants = "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 = "v0" +f[vstretchy[2]].verticalVariants = "v1" +f[vstretchy[3]].verticalVariants = "v2" +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, 6, 8, 10em. +for i in [1, 2, 6, 8, 10]: + 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(s, 0) + p.lineTo(s, s) + p.lineTo(0, s) + p.closePath(); + g.width = s + +f[largeop[0]].verticalVariants = "L7 L8 L9" +f[largeop[1]].verticalVariants = "L8" + +saveMathFont(f) diff --git a/layout/reftests/fonts/math/stretchy.otf b/layout/reftests/fonts/math/stretchy.otf new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..b019fe3dc4ce5ceaabe4514b867d2520d7bebc97 GIT binary patch literal 3236 zc%0od)^nQx($@okRJ*qR z#XlP6-6nr0fZQ zN&TW2*<;j-y?%ACbs1S8I_RYOJ$r+&U^AJRPbYJm$FHocJQpIri^eMn2HMp`H&jr4 zBK6CFObVb31?0~19YH(VzFFh{%v6`0QQn2o6@mSyLRJl}&{D)F%leE6x6Wc>=P@I{JU z1e$VAGT&mk<;&(tb1Rx0eAOt?x1zu3;8cLuE78AO_0Zv#(RxPRalcJS= z9`adKh~n7ULoq(G+5oBp!F?g$F0U$=G%c204(BqtHn88<+Uk+31EF9blbk z!)bRo9P&f6v1iDeq(9|t?8#`p0MD^Sq|I;vK{ea(#lRSo#nK(LdXniVxGYn+ZpTinSzIenfZ9>h2CEj)x_d>h}vckwVD z!T0be_Tc+?3_rjR@gqErC-7tJ#ZT}geu}5?Gg!dx+mo~%Rnfij(021W^uTEtfb(!2 zhT%6DM*~V&gsboc+>Rl@H=%qp9VD5xH`ujb*d2n)I zZnQgkX|mg5jjyvx6MaQd1;eApB4ISDEHqm+H>!{yRietIVzx?mRZb2ua)`(wvo$=b zslr;6g)}#qrbw8mj4Jmksb5bM*3*zA=GG;rNOFovhLRF3sm01Yo+9OGYF2Dmh(%(N zc*J5I4-0YzV`33wJVLaT=88wmjAyn})5IBzVRD&Vr`AY#u;n7l4K=uLo(p2SbwrVtv8w6!Uy2o9weHU zkWPymwE+kPX{2?Er9yb0?F#Ahd)R-(Pc`Pp$(Jv%|1VFIUsz7QwjQOQGA!0;^Bl=? zac)@5h$3YCVLHSRJnx3gvsv~ z)V8nbUNJQhav&cH{;?{qoP)37QHnOxmyjKvp;!1OdXH|U4R1HS7!SZ9II7jf)j`^^ zvxFxgJIw{N#g{am`3xDyknvsm2=nEOGm!myDTkF}Y^2Z8b6E8pHa!R9`}I0akjFsW zNT=Dlg)om<`8_kZ{FLtT;^w6MoRlUv6*tAree5{?+)QABbegl7^vq_FZ>DCTyCksh vO7;yaunN7@u2D#pj(r>rBFAK7+BD}BCY!in3Rz<{*&2CE`to@I_J#g8K&MM3 diff --git a/layout/reftests/mathml/opentype-stretchy-ref.html b/layout/reftests/mathml/opentype-stretchy-ref.html new file mode 100644 --- /dev/null +++ b/layout/reftests/mathml/opentype-stretchy-ref.html @@ -0,0 +1,73 @@ + + + + Open Type MATH - stretchy operator + + + + + + + +

+ + + + + + + + +

+ +

+ + + + +

+ + +

+ + + +

+ + + diff --git a/layout/reftests/mathml/opentype-stretchy.html b/layout/reftests/mathml/opentype-stretchy.html new file mode 100644 --- /dev/null +++ b/layout/reftests/mathml/opentype-stretchy.html @@ -0,0 +1,73 @@ + + + + Open Type MATH - stretchy operator + + + + + + + +

+ + + + + + + + +

+ +

+ + + + +

+ + +

+ + + +

+ + + diff --git a/layout/reftests/mathml/reftest.list b/layout/reftests/mathml/reftest.list --- a/layout/reftests/mathml/reftest.list +++ b/layout/reftests/mathml/reftest.list @@ -143,16 +143,17 @@ skip-if(B2G) == maction-dynamic-1.html m == mo-lspace-rspace.html mo-lspace-rspace-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 == operator-1.xhtml operator-1-ref.xhtml +== opentype-stretchy.html opentype-stretchy-ref.html == scriptshift-1.xhtml scriptshift-1-ref.xhtml == number-size-1.xhtml number-size-1-ref.xhtml == multiscripts-1.html multiscripts-1-ref.html == 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 != menclose-1c.html menclose-1-ref.html