Skip to content

Commit 7dfe1cb

Browse files
authored
Merge pull request #1327 from mathjax/fix/nofont
Allow the no-font components to still have a default font, just not a packed one.
2 parents 3fdbdae + bb59da7 commit 7dfe1cb

File tree

4 files changed

+4
-21
lines changed

4 files changed

+4
-21
lines changed

components/mjs/output/chtml/nofont.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

components/mjs/output/svg/nofont.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

components/mjs/output/util.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {hasWindow} from '#js/util/context.js';
55
export const FONTPATH = hasWindow ?
66
'https://cdn.jsdelivr.net/npm/@mathjax/%%FONT%%-font':
77
'@mathjax/%%FONT%%-font';
8-
98
export const OutputUtil = {
109
config(jax, jaxClass, defaultFont, fontClass) {
1110

@@ -14,7 +13,7 @@ export const OutputUtil = {
1413
combineDefaults(MathJax.config, jax, MathJax.config.output || {});
1514

1615
let config = MathJax.config[jax];
17-
let font = config.font || defaultFont;
16+
let font = config.font || config.fontData || defaultFont;
1817
if (typeof(font) !== 'string') {
1918
config.fontData = font;
2019
config.font = font = font.NAME;
@@ -30,7 +29,7 @@ export const OutputUtil = {
3029
}
3130
const name = font.substring(1, font.length - 1);
3231

33-
if (name !== defaultFont) {
32+
if (name !== defaultFont || !fontClass) {
3433

3534
MathJax.loader.addPackageData(`output/${jax}`, {extraLoads: [`${font}/${jax}`]});
3635

components/webpack.common.cjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,11 @@ const PLUGINS = function (js, dir, target, font, jax, name) {
8484
// Replace default font with the no-font file
8585
//
8686
if (!font) {
87-
const jax = (name.match(/chtml|svg/) || ['chtml'])[0];
88-
const nofont = path.resolve(DIRNAME, target, 'output', jax, 'nofont.js');
8987
plugins.push(
9088
new webpack.NormalModuleReplacementPlugin(
91-
/DefaultFont.js/,
89+
/-font\/.*?\/default\.js/,
9290
function (resource) {
93-
resource.request = path.relative(resource.context, nofont).replace(/^([^.])/, './$1');
91+
resource.request = resource.request.replace(/\/.*?\/default\.js/, '/nofont.js');
9492
}
9593
)
9694
);

0 commit comments

Comments
 (0)