commit a75bf1afc2b13540dbfa051b66642bf5db53d241 parent 056cba64ec0afc7cad299aa5d4a5b1b38ffe0b45 Author: Ben Alpert <spicyjalapeno@gmail.com> Date: Fri, 29 Aug 2014 12:28:43 -0700 Add \scriptspace after superscripts and subscripts Summary: Plain TeX assigns `\scriptspace=0.5pt`, which is used in Rules 18bcd in the TeXbook's Appendix G. Test Plan: - Look at `x^{x^{x_{x_{x_{x_x}}}}}\biggr|`, see a gap that looks similar to the one produced by real TeX. - Look at the huxley tests, see that they look reasonable. Make sure that all changes to other huxley tests are now correct, and only changed because of this. Reviewers: emily Reviewed By: emily Subscribers: jessie Differential Revision: http://phabricator.khanacademy.org/D12763 Diffstat:
9 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/buildTree.js b/buildTree.js @@ -196,6 +196,11 @@ var groupTypes = { p = fontMetrics.metrics.sup2; } + var multiplier = Style.TEXT.sizeMultiplier * + options.style.sizeMultiplier; + // \scriptspace is 0.5pt = 0.05em * 10pt/em + var scriptspace = 0.05 / multiplier + "em"; + var supsub; if (!group.value.sup) { @@ -206,6 +211,7 @@ var groupTypes = { sub.height - 0.8 * fontMetrics.metrics.xHeight); subwrap.style.top = v + "em"; + subwrap.style.marginRight = scriptspace; subwrap.depth = subwrap.depth + v; subwrap.height = 0; @@ -221,6 +227,7 @@ var groupTypes = { sup.depth + 0.25 * fontMetrics.metrics.xHeight); supwrap.style.top = -u + "em"; + supwrap.style.marginRight = scriptspace; supwrap.height = supwrap.height + u; supwrap.depth = 0; @@ -252,6 +259,9 @@ var groupTypes = { supwrap.style.top = -u + "em"; subwrap.style.top = v + "em"; + supwrap.style.marginRight = scriptspace; + subwrap.style.marginRight = scriptspace; + supwrap.height = supwrap.height + u; supwrap.depth = 0; diff --git a/test/huxley/DeepFontSizing.hux/firefox-1.png b/test/huxley/DeepFontSizing.hux/firefox-1.png Binary files differ. diff --git a/test/huxley/Huxleyfile.json b/test/huxley/Huxleyfile.json @@ -117,5 +117,11 @@ "name": "VerticalSpacing", "screenSize": [1024, 768], "url": "http://localhost:7936/test/huxley/test.html?pre=potato<br>blah&post=<br>moo&m=x^{\\Huge y}z" + }, + + { + "name": "SupSubHorizSpacing", + "screenSize": [1024, 768], + "url": "http://localhost:7936/test/huxley/test.html?m=x^{x^{x}}\\Big|x_{x_{x_{x_{x}}}}\\bigg|x^{x^{x_{x_{x_{x_{x}}}}}}\\bigg|" } ] diff --git a/test/huxley/Overline.hux/firefox-1.png b/test/huxley/Overline.hux/firefox-1.png Binary files differ. diff --git a/test/huxley/Spacing.hux/firefox-1.png b/test/huxley/Spacing.hux/firefox-1.png Binary files differ. diff --git a/test/huxley/SupSubCharacterBox.hux/firefox-1.png b/test/huxley/SupSubCharacterBox.hux/firefox-1.png Binary files differ. diff --git a/test/huxley/SupSubHorizSpacing.hux/firefox-1.png b/test/huxley/SupSubHorizSpacing.hux/firefox-1.png Binary files differ. diff --git a/test/huxley/SupSubHorizSpacing.hux/record.json b/test/huxley/SupSubHorizSpacing.hux/record.json @@ -0,0 +1,5 @@ +[ + { + "action": "screenshot" + } +] diff --git a/test/huxley/VerticalSpacing.hux/firefox-1.png b/test/huxley/VerticalSpacing.hux/firefox-1.png Binary files differ.