MathML Crowdfunding
MathML
Crowdfunding

Blog de Frédéric

To content | To menu | To search

Tag - fonts

Entries feed - Comments feed

Saturday, June 23 2012

Mozilla MathML Project: installation of mathematical fonts

Just before I posted my blog entry about mathematical fonts, I received a mail from Dave Barton about which mathematical fonts to use in browsers. We also have this kind of discussion at MathJax. So I think this issue is important and I would like to give more updates:

  • Mac OS X: STIX fonts are currently installed by default on Lion (and not shipped in Webkit browsers as I claimed in my previous post).
  • Linux: I asked Mike Hommey to update Iceweasel's font dependencies. To all the package maintainers of Linux distributions: Firefox no longer uses Mathematica or TeX fonts since at least version 4.0 ; the latest versions rely on MathJax fonts, STIX fonts and Asana Math.
  • Windows: Recent versions have Cambria Math installed but Firefox can not use it yet. I just read this article about MSI for deploying Fonts. The approach seems pretty easy: it uses the free software WiX to create a font installer from a small XML file. Any volunteer to create such an installer for MathJax fonts, STIX fonts and Asana Math?
  • Android: The situation is not really clear to me, but according to Bill Gianopoulos it is difficult to install fonts on some devices and the MathML font add-on seems a good alternative. If I understand correctly, this add-on works on native Android build but not XUL-based ones. Bill's builds contain an experimental patch to make a modified version of the add-on usable in XUL-based build too.
  • About warning that mathematical fonts are missing and suggesting to install them: my approach has not raised much enthusiasm so far, so I'm not sure the patches will be integrated in Firefox.

Saturday, April 21 2012

Mozilla MathML Project: about mathematical fonts

After yet another feedback about the fact that Mozilla's MathML rendering is ugly without appropriate fonts installed, more progress has be made towards our font improvement plan. In this post I will talk about what is going on, even if that is still work-in-progress. I will hopefully have the occasion to describe the evolution in my next status report for Gecko 13, 14 and 15. I will also mention other activities in the MathML project.

The Big Picture

First it may be worth to recall again why appropriate fonts are necessary to render mathematical expressions correctly. One of the most obvious reason is that there are exotic mathematical symbols not contained in mainstream fonts. The style of the font, its spacing etc are also more subtle aspects (that may depend on tastes or habits) making people feel that a formula is "good-looking".

More importantly, some symbols (e.g. sums or integrals) should be displayed larger in some situations while others (e.g. braces or roots) have to stretch to cover subexpressions. For that purpose, one needs fonts with size variants as well as glyphs to build characters by parts.

Since Firefox 3.6, the Mozilla MathML team has made several efforts to improve the font support. The table below compares the rendering of a Nightly build (with work-in-progress patches) against the default rendering of Firefox 3.6.

Default (Firefox 3.6) No fonts (Firefox 3.6)
Default No fonts
Asana, MathJax, STIX Asana Font MathJax fonts STIX fonts

The Default Rendering

Let's first consider the default rendering. Note that some generic Unicode code points exist to stretch characters and are used if possible. Hence, this rendering may be worse or better than the one shown above, depending on which fonts are available on the system.

Additionally since bug 414277 is fixed, a scale transform may also be applied to stretch a character if it is not possible to construct it from the fonts available (compare the current default version with the one of Firefox 3.6). Note that for some less often used operators (e.g. quadruple arrow) this latter technique is the only way to stretch them because no mathematical fonts provide the necessary glyphs.

Although the default rendering is acceptable in some situations like elementary math, specific fonts are indispensable to obtain a decent rendering with more advanced notations. There are essentially two directions possible: support more fonts and/or ensure recommended fonts are available. That is the subject of the two next sections.

Generic Support for Open Type fonts

The first direction is to support as much fonts as possible, to increase the chance to find one that can be used. Many mathematical fonts are installed by default on most operating systems, like Cambria Math or Symbol. These fonts allow to display the most common mathematical symbols and to use Unicode constructions to stretch operators.

To obtain complete support of a given font, we currently use our own tables to describe the size variants and constructions. However, we have to write these tables for each font and so this method does not provide a generic way to support mathematical fonts. MathJax fonts will be supported in Firefox 13 and become the default. For the moment, STIX fonts are completely supported since Firefox 3.7 and Asana font is supported since Firefox 7.

Many new Open Type mathematical fonts have recently appeared, but there are technical limitations that prevent us to use our current approach. The big advantage of these recent fonts is that they contain a table describing the size variants and constructions. Hence a worthwhile work could be to refactor our code for stretchy operators and to be able to directly read the tables from the font files. The corresponding Bugzilla entries are bug 663740 and bug 407059. That would give us a generic support for all Open Type mathematical fonts that have the relevant table. This is also interesting to provide more font styles to the users. Here is a list of the Open Type mathematical fonts I am aware of:

  • Cambria Math
  • Neo Euler
  • STIX 1.1
  • Latin Modern Math
  • Lucida fonts
  • Asana Math

Additionally, these fonts actually contain a wealth of information allowing accurate positioning and spacing for the mathematical formulas. In the future we could use the Open Type Math table instead of our heuristic rules inspired from TeX. That could greatly improve the rendering of the formulas.

Ensuring Availability of Recommended Fonts

The second direction is to ensure that recommended fonts are available. Indeed, the main fonts on which we rely are generally not installed by default on the operating systems. Moreover, the installation procedure may not be convenient for all users and there are even some platforms like mobile devices where it is difficult to install new fonts.

We are working to make Web fonts usable to stretch MathML operators. When this bug is fixed, it will be possible either to ship some fonts inside the browser (as Webkit folks do) or available from a public server (as MathJax folks do). However, size and licence may be a problem for the former option. As for the latter, MathJax experience shows that mathematical fonts are generally too big to make this efficient (download time, caching etc), especially on mobile devices.

Another option is to make the installation easier. The MathML-fonts add-on has been written for that purpose. The users will just have to install these mathematical fonts like any other restartless Firefox add-on. The add-on essentially attaches a stylesheet to each page visited. This stylesheet contains @font-face rules to load the mathematical fonts contained in the add-on. Again, the work is not finished yet: because of the bug mentioned above, these rules do not work for stretchy MathML operators yet. Moreover, whatever the technique used, it seems impossible to register the stylesheet with e10s Fennec. That is annoying, since as said above this add-on is particularly important for mobile devices. I expect the first issue to be fixed in Firefox 15 but the second one is a bit out of the scope of the Mozilla MathML team...

The plan is then to display an information bar suggesting to install the add-on when a page containing MathML is visited. Actually, this message will only appear when we detect a stretch failure for MathML operators. Once this bug fixed, that will end a series of regular reports that started more than 10 years ago!

Friday, June 11 2010

stixfonts.org was last updated on 28 May. The next update will occur mid-June.

Two weeks ago, STIX Fonts Version 1.0 was finally released! Hence after about 15 years of work and regular announce of upcoming release, we now have a comprehensive set of Unicode fonts for mathematical symbols. Hopefully, this will greatly improve the rendering of MathML in browsers. However, this new version is not entirely compatible with the current version of Firefox, because some font files were renamed. A patch landed yesterday on trunk to fix this issue but I don't know whether it will also be pushed to old branch. For those who want to test the new STIX Fonts with the current version of Firefox, you just need to install STIX 1.0 and keep the former STIXSiz*.otf files from STIX Beta...