Fix #711 issue with multiple superscripts.

The previous code incorrectly implemented TeXbook rules. First off,
the font metrics at issue should be those for the superscript/
subscript style, not the main style. Secondly, the metrics should be
scaled by the font size.

This changes some screenshotter tests (and they look more like TeX
now).
This commit is contained in:
Eddie Kohler
2017-06-05 23:52:16 -04:00
parent 9f3f445360
commit 3af23fd8a4
12 changed files with 8 additions and 3 deletions

View File

@@ -334,8 +334,13 @@ groupTypes.supsub = function(group, options) {
supShift = 0;
subShift = 0;
} else {
supShift = base.height - style.metrics.supDrop;
subShift = base.depth + style.metrics.subDrop;
const supstyle = style.sup();
supShift = base.height - supstyle.metrics.supDrop
* supstyle.sizeMultiplier;
const substyle = style.sub();
subShift = base.depth + substyle.metrics.subDrop
* substyle.sizeMultiplier;
}
// Rule 18c

View File

@@ -15,7 +15,7 @@ const cjkRegex = require("./unicodeRegexes").cjkRegex;
// the arrays below, in that order.
//
// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respsectively.
// This was determined by running the folllowing script:
// This was determined by running the following script:
//
// latex -interaction=nonstopmode \
// '\documentclass{article}\usepackage{amsmath}\begin{document}' \

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 14 KiB