Page MenuHomePhabricator

(Config) Enable local STIX fonts for MathJax
Closed, ResolvedPublic

Description

Currently, MathJax 2.3 is installed, but local STIX fonts are blocked in its configuration.

MathJax should "prefer" *local* STIX font, and fall back to using TeX webfonts. This is the default behaviour for MathJax 2.3.

Sorry, I can't submit a patch; I don't have a local repository.


Version: unspecified
Severity: normal
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=35498

Details

Reference
bz63016

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:57 AM
bzimport added a project: Math.
bzimport set Reference to bz63016.
bzimport added a subscriber: Unknown Object (MLST).

Is this about code in MathJax or is this about configuration of some Wikimedia servers?

MathJax has its own configuration file (config/default.js), which is where the change needs to be made.

@Andre this is about the configuration used by the MediaWiki Math Extension.

Specifically, this line https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FMath/88d3368c23efc963ceae127bea175191bc82893e/modules%2Fext.math.mathjax.enabler.js#L25

availableFonts: ["TeX"]

which restricts MathJax to only use locally installed MathJax-TeX fonts.

The MathJax default (see http://docs.mathjax.org/en/latest/options/HTML-CSS.html) is

availableFonts: ["STIX","TeX"]

and in the next MathJax release any other MathJax-compatible font a user might have installed will be recognised as well.

Peter.

MathJax config is complicated at best, but I think it needs to be:

availableFonts: ["STIX","TeX"]
preferredFont: "STIX"
webFont: "TeX"

This should cause to use STIX or TeX when locally available, or TeX webfont if no local fonts are available.

@Erwin do you intentionally want to force the preference for locally installed fonts to STIX?

Since the math extension currently prefers TeX webfonts (not STIX webfonts), it seems more natural to prefer TeX.

This also comes at no price for your personal preference -- if you don't install the TeX fonts on your machine, MathJax will still prefer locally installed STIX fonts over any webfonts (as long as availableFonts allows it).

The preferredFont value only decides which locally installed fonts to prefer if multiple compatible fonts are installed.

@Peter, yes. I prefer the STIX fonts, and the word is that the next major version of MathJax (3.0?) will include the STIX webfonts and use it as default.

(In reply to Erwin Dokter from comment #6)

@Peter, yes. I prefer the STIX fonts, and the word is that the next major
version of MathJax (3.0?) will include the STIX webfonts and use it as
default.

MathJax v2.3 already includes STIX webfonts but there are no plans to make them the MathJax default.

(In reply to Peter Krautzberger from comment #7)

MathJax v2.3 already includes STIX webfonts

I had to check that... Indeed they do (though they are not the native upcoming STIX 2.0 webfonts). Even so, all the better. So why are we not using STIX instead of that midievil TeX font?

At the very least, it should be set to its default:

availableFonts: ["STIX","TeX"],
preferredFont: "TeX",
webFont: "TeX",

though they are not the native upcoming STIX 2.0 webfonts

Not sure what you are referring to here. MathJax contributed the STIX webfonts to STIpub in November (when MathJax v2.3 came out). The STIX webfonts are based on the older "STIX General" fonts because the newer "STIX Word" fonts do not work fully in browsers right now.

Just forget it... a year ago they were still talking about 2.0. Apparently they made it 1.1.1 instead.

Point is, can we please restore the default config?

And I have to ask again (and please refer me to the proper developer if not here): why *are* we not using STIX as default?

Everything we have is copied from Nageh's script originally, so I assume this used to be in there as well.

So.... do I need to remove this line ?
https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FMath/88d3368c23efc963ceae127bea175191bc82893e/modules%2Fext.math.mathjax.enabler.js#L25

@Derk-Jan yes, deleting that line should do the trick.

mal.malego wrote:

@DJ: Since I'm still getting these mails... I had changed my setup to prefer STIX fonts back on April 1, 2012. ;-) Anyway, while you're at editing that file, I suggest adding extensions: ["color.js"] to the config environment to make the \color commands compatible with texvc (and LaTeX). See http://docs.mathjax.org/en/latest/tex.html#color
-nageh

ehm. color.js is no longer in the setup ? I'm sure we added that at some point..

Change 124055 had a related patch set uploaded by TheDJ:
Reset the fontstack of mathjax back to defaults

https://gerrit.wikimedia.org/r/124055

mal.malego wrote:

I think so, too, I guess color.js got lost at some point during the rewrite. Btw, why is the input/MathML jax part of the config? Unless I'm mistaken the mediawiki backend doesn't provide any means for generating MathML.

@Nageh, that's for what physikerwelt is working on with his Math 2.0 and MathSearch

http://arxiv.org/abs/1304.5475
https://www.mediawiki.org/wiki/Extension:MathSearch

Change 124055 merged by jenkins-bot:
Reset the fontstack of mathjax back to defaults

https://gerrit.wikimedia.org/r/124055

It seems that we are missing some STIX font information, that RL cannot load right now.

Debug mode shows we are missing the following: http://pastebin.com/4dR6Je6y

This is exactly why I posted a followup question in r124055: where is the default config stored? If there is none, then it should be added in MathJaxEnabler.js.

That is //gerrit.wikimedia.org/r/#/c/124055/

@Erwin in ./unpacked/jax/output/HTML-CSS/config.js

But that is not the problem. We are missing the render information for the font. STIX doesn't just work, it needs to have information about the font in order to do the proper layouting. we are currently not serving that information, because the files are not in the repo and they are not provided as a bundle using RL from Math.php

Using TeX webfonts doesn't fare much better: http://pastebin.com/JL9LJCmL

Yet both seemingly display OK.

(In reply to Erwin Dokter from comment #24)

Using TeX webfonts doesn't fare much better: http://pastebin.com/JL9LJCmL

Yet both seemingly display OK.

I believe these fonts (Greek, WinChrome and WinIE6) are obsolete. The woff files are not in MathJax v2.3 but the js font data are still there. I think we can remove them from Math.php so that the resource loader won't load them (and we can remove the js data from the repo).

(In reply to Frédéric Wang from comment #25)

I believe these fonts (Greek, WinChrome and WinIE6) are obsolete. The woff
files are not in MathJax v2.3 but the js font data are still there. I think
we can remove them from Math.php so that the resource loader won't load them
(and we can remove the js data from the repo).

Well, actually some fonts are still available as otf/eot/svg. I think it would be best to ask to the MathJax team which fonts are still used and in which situations. But as I recall, these fonts were only a hack for old browsers unable to display some characters.

I see no more errors and the default configuration has been restored, rendering STIX fonts when installed. I consider this resolved.