Skip to content

Commit c7f3ba0

Browse files
authored
Merge pull request #1449 from mathjax/update/font-sizes
Update font-size macros to correct LaTeX values and make fontsizev3 package for backward compatibility
2 parents 3d1a515 + 1c64d74 commit c7f3ba0

File tree

7 files changed

+82
-18
lines changed

7 files changed

+82
-18
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"build": {
3+
"id": "[tex]/fontsizev3",
4+
"component": "input/tex/extensions/fontsizev3",
5+
"targets": ["input/tex/fontsizev3"]
6+
},
7+
"webpack": {
8+
"name": "input/tex/extensions/fontsizev3",
9+
"libs": [
10+
"components/src/input/tex-base/lib",
11+
"components/src/core/lib"
12+
]
13+
}
14+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './lib/fontsizev3.js';

components/mjs/source.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const source = {
4949
'[tex]/empheq': `${src}/input/tex/extensions/empheq/empheq.js`,
5050
'[tex]/enclose': `${src}/input/tex/extensions/enclose/enclose.js`,
5151
'[tex]/extpfeil': `${src}/input/tex/extensions/extpfeil/extpfeil.js`,
52+
'[tex]/fontsizev3': `${src}/input/tex/extensions/fontsizev3/fontsizev3.js`,
5253
'[tex]/gensymb': `${src}/input/tex/extensions/gensymb/gensymb.js`,
5354
'[tex]/html': `${src}/input/tex/extensions/html/html.js`,
5455
'[tex]/mathtools': `${src}/input/tex/extensions/mathtools/mathtools.js`,

testsuite/tests/input/tex/__snapshots__/Base.test.ts.snap

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7654,53 +7654,53 @@ exports[`Roots Tweaked Root 1`] = `
76547654
76557655
exports[`Setting sizes Empty 1`] = `
76567656
"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\Huge" display="block">
7657-
<mstyle mathsize="2.49em" data-latex="\\Huge"></mstyle>
7657+
<mstyle mathsize="2.074em" data-latex="\\Huge"></mstyle>
76587658
</math>"
76597659
`;
76607660
76617661
exports[`Setting sizes Huge 1`] = `
76627662
"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\Huge a" display="block">
7663-
<mstyle mathsize="2.49em" data-latex="\\Huge a">
7663+
<mstyle mathsize="2.074em" data-latex="\\Huge a">
76647664
<mi data-latex="a">a</mi>
76657665
</mstyle>
76667666
</math>"
76677667
`;
76687668
76697669
exports[`Setting sizes LARGE 1`] = `
76707670
"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\LARGE a" display="block">
7671-
<mstyle mathsize="1.73em" data-latex="\\LARGE a">
7671+
<mstyle mathsize="1.44em" data-latex="\\LARGE a">
76727672
<mi data-latex="a">a</mi>
76737673
</mstyle>
76747674
</math>"
76757675
`;
76767676
76777677
exports[`Setting sizes Large 1`] = `
76787678
"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\Large a" display="block">
7679-
<mstyle mathsize="1.44em" data-latex="\\Large a">
7679+
<mstyle mathsize="1.2em" data-latex="\\Large a">
76807680
<mi data-latex="a">a</mi>
76817681
</mstyle>
76827682
</math>"
76837683
`;
76847684
76857685
exports[`Setting sizes Tiny 1`] = `
76867686
"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\Tiny a" display="block">
7687-
<mstyle mathsize="0.6em" data-latex="\\Tiny a">
7687+
<mstyle mathsize="0.5em" data-latex="\\Tiny a">
76887688
<mi data-latex="a">a</mi>
76897689
</mstyle>
76907690
</math>"
76917691
`;
76927692
76937693
exports[`Setting sizes huge 1`] = `
76947694
"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\huge a" display="block">
7695-
<mstyle mathsize="2.07em" data-latex="\\huge a">
7695+
<mstyle mathsize="1.728em" data-latex="\\huge a">
76967696
<mi data-latex="a">a</mi>
76977697
</mstyle>
76987698
</math>"
76997699
`;
77007700
77017701
exports[`Setting sizes large 1`] = `
77027702
"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\large a" display="block">
7703-
<mstyle mathsize="1.2em" data-latex="\\large a">
7703+
<mstyle mathsize="1.095em" data-latex="\\large a">
77047704
<mi data-latex="a">a</mi>
77057705
</mstyle>
77067706
</math>"
@@ -7724,15 +7724,15 @@ exports[`Setting sizes scriptsize 1`] = `
77247724
77257725
exports[`Setting sizes small 1`] = `
77267726
"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\small a" display="block">
7727-
<mstyle mathsize="0.85em" data-latex="\\small a">
7727+
<mstyle mathsize="0.9em" data-latex="\\small a">
77287728
<mi data-latex="a">a</mi>
77297729
</mstyle>
77307730
</math>"
77317731
`;
77327732
77337733
exports[`Setting sizes tiny 1`] = `
77347734
"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\tiny a" display="block">
7735-
<mstyle mathsize="0.5em" data-latex="\\tiny a">
7735+
<mstyle mathsize="0.6em" data-latex="\\tiny a">
77367736
<mi data-latex="a">a</mi>
77377737
</mstyle>
77387738
</math>"

testsuite/tests/input/tex/__snapshots__/Mathtools.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3901,7 +3901,7 @@ exports[`Mathtools Symbols Other 1`] = `
39013901
</mrow>
39023902
<munder data-latex="\\mathop{\\Large\\kern-.1em\\boldsymbol{\\times}\\kern-.1em}_n">
39033903
<mrow data-mjx-texclass="OP" data-latex="\\mathop{\\Large\\kern-.1em\\boldsymbol{\\times}\\kern-.1em}">
3904-
<mstyle mathsize="1.44em" data-latex="\\Large\\kern-.1em\\boldsymbol{\\times}\\kern-.1em">
3904+
<mstyle mathsize="1.2em" data-latex="\\Large\\kern-.1em\\boldsymbol{\\times}\\kern-.1em">
39053905
<mspace width="-.1em" linebreak="nobreak" data-latex="\\kern-.1em"></mspace>
39063906
<mo data-latex="\\boldsymbol{\\times}" mathvariant="bold">&#xD7;</mo>
39073907
<mspace width="-.1em" linebreak="nobreak" data-latex="\\kern-.1em"></mspace>

ts/input/tex/base/BaseMappings.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -452,16 +452,20 @@ new sm.CommandMap('macros', {
452452
textsf: [BaseMethods.HBox, null, VARIANT.SANSSERIF],
453453
texttt: [BaseMethods.HBox, null, VARIANT.MONOSPACE],
454454

455-
tiny: [BaseMethods.SetSize, 0.5],
456-
Tiny: [BaseMethods.SetSize, 0.6], // non-standard
455+
Tiny: [BaseMethods.SetSize, 0.5],
456+
tiny: [BaseMethods.SetSize, 0.6],
457457
scriptsize: [BaseMethods.SetSize, 0.7],
458-
small: [BaseMethods.SetSize, 0.85],
458+
SMALL: [BaseMethods.SetSize, 0.7],
459+
Small: [BaseMethods.SetSize, 0.8],
460+
footnotesize: [BaseMethods.SetSize, 0.8],
461+
small: [BaseMethods.SetSize, 0.9],
459462
normalsize: [BaseMethods.SetSize, 1.0],
460-
large: [BaseMethods.SetSize, 1.2],
461-
Large: [BaseMethods.SetSize, 1.44],
462-
LARGE: [BaseMethods.SetSize, 1.73],
463-
huge: [BaseMethods.SetSize, 2.07],
464-
Huge: [BaseMethods.SetSize, 2.49],
463+
large: [BaseMethods.SetSize, 1.095],
464+
Large: [BaseMethods.SetSize, 1.2],
465+
LARGE: [BaseMethods.SetSize, 1.44],
466+
huge: [BaseMethods.SetSize, 1.728],
467+
Huge: [BaseMethods.SetSize, 2.074],
468+
HUGE: [BaseMethods.SetSize, 2.49],
465469

466470
arcsin: BaseMethods.NamedFn,
467471
arccos: BaseMethods.NamedFn,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*************************************************************
2+
*
3+
* Copyright (c) 2026 The MathJax Consortium
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/**
19+
* @file Configuration file for the v3-compatible font size macros (\large, etc.)
20+
*
21+
* @author dpvc@mathjax.org (Davide P. Cervone)
22+
*/
23+
24+
import { HandlerType, ConfigurationType } from '../HandlerTypes.js';
25+
import { CommandMap } from '../TokenMap.js';
26+
import { Configuration } from '../Configuration.js';
27+
import BaseMethods from '../base/BaseMethods.js';
28+
29+
new CommandMap('fontsizev3-macros', {
30+
tiny: [BaseMethods.SetSize, 0.5], // // should have been .6
31+
Tiny: [BaseMethods.SetSize, 0.6], // // should have been .5
32+
scriptsize: [BaseMethods.SetSize, 0.7],
33+
small: [BaseMethods.SetSize, 0.85], // // should have been .9
34+
normalsize: [BaseMethods.SetSize, 1.0],
35+
large: [BaseMethods.SetSize, 1.2], // // should have been 1.095
36+
Large: [BaseMethods.SetSize, 1.44], // // should have been 1.2
37+
LARGE: [BaseMethods.SetSize, 1.73], // // should have been 1.44
38+
huge: [BaseMethods.SetSize, 2.07], // // should have been 1.728
39+
Huge: [BaseMethods.SetSize, 2.49], // // should have been 2.074
40+
});
41+
42+
export const FontSizeV3Configuration = Configuration.create('fontsizev3', {
43+
[ConfigurationType.HANDLER]: { [HandlerType.MACRO]: ['fontsizev3-macros'] },
44+
});

0 commit comments

Comments
 (0)