Fix font choice in operators like \log (e.g. \boldsymbol{\log}) (#2041)

* Fix font choice in operators like \log (e.g. \boldsymbol{\log})

Fix #1971 by correctly passing arguments into the font choice for
the HTML handler for operators like \log.

* Extend BoldSymbol screenshot test

* Require options argument in mathsym to avoid this type of bug in the future

* Update screenshot
This commit is contained in:
Erik Demaine
2019-07-16 18:08:17 -04:00
committed by Ron Kok
parent 3d9a094b67
commit 08df67b7cd
6 changed files with 5 additions and 6 deletions

View File

@@ -103,13 +103,11 @@ const makeSymbol = function(
/** /**
* Makes a symbol in Main-Regular or AMS-Regular. * Makes a symbol in Main-Regular or AMS-Regular.
* Used for rel, bin, open, close, inner, and punct. * Used for rel, bin, open, close, inner, and punct.
*
* TODO(#953): Make `options` mandatory and always pass it in.
*/ */
const mathsym = function( const mathsym = function(
value: string, value: string,
mode: Mode, mode: Mode,
options?: Options, options: Options,
classes?: string[] = [], classes?: string[] = [],
): SymbolNode { ): SymbolNode {
// Decide what font to render the symbol in by its entry in the symbols // Decide what font to render the symbol in by its entry in the symbols
@@ -119,7 +117,7 @@ const mathsym = function(
// text ordinal and is therefore not present as a symbol in the symbols // text ordinal and is therefore not present as a symbol in the symbols
// table for text, as well as a special case for boldsymbol because it // table for text, as well as a special case for boldsymbol because it
// can be used for bold + and - // can be used for bold + and -
if ((options && options.font && options.font === "boldsymbol") && if (options.font === "boldsymbol" &&
lookupSymbol(value, "Main-Bold", mode).metrics) { lookupSymbol(value, "Main-Bold", mode).metrics) {
return makeSymbol(value, "Main-Bold", mode, options, return makeSymbol(value, "Main-Bold", mode, options,
classes.concat(["mathbf"])); classes.concat(["mathbf"]));

View File

@@ -105,7 +105,7 @@ export const htmlBuilder: HtmlBuilderSupSub<"op"> = (grp, options) => {
// operators, like \limsup // operators, like \limsup
const output = []; const output = [];
for (let i = 1; i < group.name.length; i++) { for (let i = 1; i < group.name.length; i++) {
output.push(buildCommon.mathsym(group.name[i], group.mode)); output.push(buildCommon.mathsym(group.name[i], group.mode, options));
} }
base = buildCommon.makeSpan(["mop"], output, options); base = buildCommon.makeSpan(["mop"], output, options);
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -65,7 +65,8 @@ BinCancellation: |
BinomTest: \dbinom{a}{b}\tbinom{a}{b}^{\binom{a}{b}+17} BinomTest: \dbinom{a}{b}\tbinom{a}{b}^{\binom{a}{b}+17}
BoldSpacing: \mathbf{A}^2+\mathbf{B}_3*\mathscr{C}' BoldSpacing: \mathbf{A}^2+\mathbf{B}_3*\mathscr{C}'
BoldSymbol: | BoldSymbol: |
\sum_{\boldsymbol{\alpha}}^{\boldsymbol{\beta}} \boldsymbol{\omega}+ \int_{\boldsymbol{\alpha}}^{\boldsymbol{\beta}} \boldsymbol{\Omega}+\boldsymbol{Ax2k\omega\Omega\imath+} \\ \sum_{\boldsymbol{\alpha}}^{\boldsymbol{\beta}} \boldsymbol{\omega}+ \boldsymbol{\int_\alpha^\beta} \boldsymbol{\Omega + {}} \\
\boldsymbol{\lim_{x \to \infty} \log Ax2k\omega\Omega\imath+} \\
x \boldsymbol{+} y \boldsymbol{=} z x \boldsymbol{+} y \boldsymbol{=} z
Boxed: \boxed{F=ma} \quad \boxed{ac}\color{magenta}{\boxed{F}}\boxed{F=mg} Boxed: \boxed{F=ma} \quad \boxed{ac}\color{magenta}{\boxed{F}}\boxed{F=mg}
Cases: | Cases: |