From ad52fc9642ec24edb2526c58c46d4aa5ab925fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Sun, 27 Dec 2015 08:37:00 -0500 Subject: [PATCH] Bug 1231404 - SubscriptBaselineDropMin or SuperscriptBaselineDropMax are not read from the MATH table. r=jfkthame --- layout/mathml/nsMathMLmmultiscriptsFrame.cpp | 21 +++++++++++--- .../mathml/tests/test_opentype-scripts.html | 26 +++++++++++++++++- layout/reftests/fonts/math/generate.py | 5 ++++ layout/reftests/fonts/math/mochitest.ini | 1 + layout/reftests/fonts/math/scripts-9.otf | Bin 0 -> 1864 bytes 5 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 layout/reftests/fonts/math/scripts-9.otf diff --git a/layout/mathml/nsMathMLmmultiscriptsFrame.cpp b/layout/mathml/nsMathMLmmultiscriptsFrame.cpp index e0c8700d835b..c1d9957a3c94 100644 --- a/layout/mathml/nsMathMLmmultiscriptsFrame.cpp +++ b/layout/mathml/nsMathMLmmultiscriptsFrame.cpp @@ -203,6 +203,14 @@ nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext, scriptSpace = nsPresContext::CSSPointsToAppUnits(0.5f); } + // Try and read sub and sup drops from the MATH table. + if (mathFont) { + subDrop = mathFont-> + GetMathConstant(gfxFontEntry::SubscriptBaselineDropMin, oneDevPixel); + supDrop = mathFont-> + GetMathConstant(gfxFontEntry::SuperscriptBaselineDropMax, oneDevPixel); + } + // force the scriptSpace to be at least 1 pixel nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1); scriptSpace = std::max(onePixel, scriptSpace); @@ -390,8 +398,11 @@ nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext, // subscript subScriptFrame = childFrame; GetReflowAndBoundingMetricsFor(subScriptFrame, subScriptSize, bmSubScript); - // get the subdrop from the subscript font - GetSubDropFromChild (subScriptFrame, subDrop, aFontSizeInflation); + if (!mathFont) { + // get the subdrop from the subscript font + GetSubDropFromChild (subScriptFrame, subDrop, aFontSizeInflation); + } + // parameter v, Rule 18a, App. G, TeXbook minSubScriptShift = bmBase.descent + subDrop; trySubScriptShift = std::max(minSubScriptShift,subScriptShift); @@ -431,8 +442,10 @@ nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext, // supscript supScriptFrame = childFrame; GetReflowAndBoundingMetricsFor(supScriptFrame, supScriptSize, bmSupScript); - // get the supdrop from the supscript font - GetSupDropFromChild (supScriptFrame, supDrop, aFontSizeInflation); + if (!mathFont) { + // get the supdrop from the supscript font + GetSupDropFromChild (supScriptFrame, supDrop, aFontSizeInflation); + } // parameter u, Rule 18a, App. G, TeXbook minSupScriptShift = bmBase.ascent - supDrop; nscoord superscriptBottomMin; diff --git a/layout/mathml/tests/test_opentype-scripts.html b/layout/mathml/tests/test_opentype-scripts.html index 584d3f1e7d21..7ad0e90ab03e 100644 --- a/layout/mathml/tests/test_opentype-scripts.html +++ b/layout/mathml/tests/test_opentype-scripts.html @@ -9,7 +9,7 @@ @@ -264,5 +276,17 @@

+

+ + + + + + + +

diff --git a/layout/reftests/fonts/math/generate.py b/layout/reftests/fonts/math/generate.py index 59d2a9cb4876..b42cd3e227c5 100644 --- a/layout/reftests/fonts/math/generate.py +++ b/layout/reftests/fonts/math/generate.py @@ -479,6 +479,11 @@ f = newMathFont("scripts-8") f.math.SuperscriptBottomMin = 9 * em saveMathFont(f) +f = newMathFont("scripts-9") +f.math.SubscriptBaselineDropMin = 3 * em +f.math.SuperscriptBaselineDropMax = 5 * em +saveMathFont(f) + ################################################################################ # Testing Limits Parameters f = newMathFont("limits-1") diff --git a/layout/reftests/fonts/math/mochitest.ini b/layout/reftests/fonts/math/mochitest.ini index 0aad9823750e..ff6ebcc04ceb 100644 --- a/layout/reftests/fonts/math/mochitest.ini +++ b/layout/reftests/fonts/math/mochitest.ini @@ -31,6 +31,7 @@ support-files = /tests/fonts/math/scripts-6.otf /tests/fonts/math/scripts-7.otf /tests/fonts/math/scripts-8.otf + /tests/fonts/math/scripts-9.otf /tests/fonts/math/stack-1.otf /tests/fonts/math/stack-2.otf /tests/fonts/math/stack-3.otf diff --git a/layout/reftests/fonts/math/scripts-9.otf b/layout/reftests/fonts/math/scripts-9.otf new file mode 100644 index 0000000000000000000000000000000000000000..35984e1b4b0524d6e441c8a40f6d384085c0fd51 GIT binary patch literal 1864 zcmds2OK1~882)B=lRiyrv=T7Npha6XbrWAGMbtv@V69*f@n8)#G=a7oHY+}`P!L6p z2SHIhi+B-5^dM*s9uyBAL=Zd(Du{aU;Gxo}X#8e(8`3t2XJ<3>fB*ZR`FAG+snh^k zFaaHAUot5-hQFKw0_^}ECX=cDqvu||CjXp#w10bQrxuJ|C;u4``v>-}O|<_Ge;}6B z9~v4>=P^%z3h1{e+mX$r4;#5vcd2{CxiL$DHV}AAJjvOa9d(X1ydXluHZF~$>0^0l zdk95@OK>bbnt6Ql$z}2rfVMhs6`aZ$tOJa%)Jq6u3M5WXqz2o1zoA8EUBJs5&c|A+ zFh?Ua4=5ioDJF5iv!_%=svWds9m?L&KZ}b9kU6iZU0m>}c!#*4UPGX%>Nqs7)BNj_t1qQbdx4vB98S$ z{j@qkixEC)^2*DmpIX!O$q|hKeOCUsog29c5jf|vapJnGQJMH8w z+7*~UCCt;cfEYGYG-T)UP9a9<{gQ4-2a4J(E#nr{!;&PnaL$e4$rISbh;bGl^Ea>o zNLph~(z1s$GSOqoEwY-8II$@fPsCU(?dArpEo>i)uxaD%RbMP}4SY2*Id9f%*wek|Z95F7miXulKinDD|pgoG>{3sfuxEF@5 z99FW&oB!<%ucoR3RiS_;#IohZ($siKluF<4m-N!2ACal|zazoY&pRDc?pQ2drn+mZvE1tm>Kt=YHc&#i5^~Ty@5AMUw^bbm?>Xymi#kc);&{Km%GB+ z57yPp6sq&5t=orbJZ&*suJm=L=m37bqOO;>`y$d#Qtu@eq+%A=Nl7d3zzCL3Cz?Y& XzlF3=)&e0nt|wJZnf0iD5H