Page MenuHomePhabricator

Fonts for native MathML
Closed, ResolvedPublic

Description

The change to use the old math fonts with native MathML (MathJax and STIXGeneral) was not integrated in the initial part of Moritz's work because of concerns with Web fonts. I guess there is already an exception with MathJax which uses its own resource loader system to handle Web fonts ; but we can probably do better with native MathML here. In particular, I think MediaWiki has some code to handle Web fonts for specific languages and scripts, so we can certainly reuse that for math (I'll need to check what is done).

At the moment, the status is that:

  1. There are known bugs in OpenType MATH fonts, the most serious one is an ascent/descent bug with some of them (including STIX or Latin Modern fonts).
  1. For stretchy operators, WebKit still only supports Unicode-based construction and my patches to support OpenType MATH fonts are unlikely to be integrated into release builds soon. The initial plan was to not enable MathML on WebKit by default, so we can probably ignore it for now.
  1. Gecko 31 (corresponding to the next Firefox ESR) will have support for OpenType MATH fonts and is scheduled for the end of July. There is a workaround for the ascent/descent bug of 1) on Linux/Mac/Mobiles and Cambria Math is not affected on Windows.

Regarding fonts, I'm working to make OpenType MATH fonts installed by default but at the moment:

  1. On Windows 7 or higher (i.e. the version officially maintained by Microsoft), Cambria Math is installed by default and can be used for Gecko 31
  2. On Mac 10.8 or higher, STIX is installed by default but I'm not sure it is the version with a MATH table. Older Mac versions don't have it installed.
  3. On Linux and other desktop platforms, many packages are available but not necessarily installed by default.
  4. Mobile platforms don't have MATH fonts by default.
  5. TeX distributions (TeX Live, MiKTeX etc) contains MATH fonts (e.g. Latin Modern Math or STIX), so in theory TeX users should already have appropriate fonts on their systems.

So my proposal would be:

@namespace url('http://www.w3.org/1998/Math/MathML');
math {

// Start with "Cambria Math" (Gecko 31 on Windows >= 7)
// Then try "Latin Modern Math" or "STIX Math" since they are very common on desktop (Gecko 31 on desktop when e.g. a TeX distribution or STIX are installed). More can be added (there are 12 MATH fonts)
// Then try "Latin Modern Math" as a web font (mobile platforms and other systems missing MATH fonts)
// Then try the old math fonts MathJax_Main and STIXGeneral (backward compatibility). More can be added (cf Gecko's mathml.css ua stylesheet)
font-family: "Cambria Math", "Latin Modern Math", "STIX Math", LatinModernWOFF, MathJax_Main, STIXGeneral, serif;

}
mtext {

// use the same font-family as the surrounding text or reset to 'initial'
// (for example if someone uses non-Latin scripts in \text)
font-family: ...;

}
@font-face {

// Latin Modern Math
// http://fred-wang.github.io/MathFonts/LatinModern/latinmodern-math.woff
font-family: LatinModernWOFF;
src: url('latinmodern-math.woff');

}

Note that this will be *only* adding a 472kb web font in contrast to the previous attempts with STIXGeneral and MathJax fonts. Also, this Web font fallback is unlikely to be used on Windows and on desktop platforms when a TeX distribution is installed.


Version: unspecified
Severity: normal

Details

Reference
bz65532

Related Objects

StatusAssignedTask
ResolvedNone
Resolvedfredw
ResolvedNone

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 3:26 AM
bzimport added a project: Math.
bzimport set Reference to bz65532.
bzimport added a subscriber: Unknown Object (MLST).
fredw created this task.May 20 2014, 1:44 PM
fredw added a comment.May 20 2014, 1:47 PM

In a more compact form:

@namespace url('http://www.w3.org/1998/Math/MathML');
math {

font-family: "Cambria Math", "Latin Modern Math", "STIX Math", LatinModernWOFF, MathJax_Main, STIXGeneral, serif;

}
mtext {

font-family: initial;

}
@font-face {

font-family: LatinModernWOFF;
src: url('latinmodern-math.woff');

}

Change 134362 had a related patch set uploaded by Frédéric Wang:
Fonts for native MathML

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

fredw added a comment.May 20 2014, 2:47 PM

https://www.mediawiki.org/wiki/Extension:UniversalLanguageSelector seems very specific to language support, I'm not sure we can use that. The change only adds one WOFF font, so I guess that should be fine. I've dropped the mtext font-family too, as I'm not sure what's best.

I opened https://gerrit.wikimedia.org/r/134362 to keep that in mind when we have the MathML mode available and used with Gecko.

Change 134362 merged by jenkins-bot:
Fonts for native MathML

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