You are here: MathML project > Implementation of MathML in Mozilla
Fonts for MathML-enabled Mozilla
MathML has over 2000 predefined entities, many of which are associated to various symbols used in mathematics and science. Recently, assignments for these symbols were approved by the Unicode Consortium. Mozilla can display any of these symbols provided suitable Unicode fonts are installed.
Mozilla is internally Unicode-based. Furthermore, in accordance with the W3C CSS2 recommendation on fonts, authors can specify an ordered list of particular fonts which they prefer (using the font-family property of CSS), with the assurance that Mozilla's font engine will hunt for alternate fonts whenever their specified fonts are not found on a particular user' system. If no appropriate font is ultimately found for a given character, Mozilla will instead display a box containing the hexadecimal representation of the Unicode code point for the character.
It follows that, on two similar systems, while one user may see a document rendered correctly, the other user may see something completely different. To see MathML as intended, you need sufficient font support, which may mean installing some fonts. Just having a MathML-enabled browser is not necessarily enough.
The fonts that should be installed for the best MathML rendering depend on which version of Mozilla is being used. Please read section Mozilla 1.8 (for Firefox 2.0) or Mozilla 1.9 (for Firefox 3.0) as appropriate.
Mozilla 1.9
STIX Beta Fonts
The STIX Fonts Project has been developing a comprehensive set of fonts that cover all the symbols in MathML, and has made available a beta release of these fonts, which can be downloaded here.
Mozilla 1.9 (including Firefox 3.0) users should download and install the STIX Beta fonts for best MathML rendering. The link above provides a Zip archive containing the font files (which have the ".otf" extension). The fonts may be installed by extracting the files from the Zip archive, then following instructions for Microsoft Windows, or copying the files to a "~/Library/Fonts" folder on Mac OS X, or to a "~/.fonts/" directory (which may need to be created) on Unix/Linux systems. Alternatively, follow dafont's "How to install a font".
(These fonts are OpenType PostScript fonts, which are supported by most modern operating systems. However some operating systems (including OS/2) may not support these fonts. On such systems [only systems without support for OpenType Postscript fonts], it will be necessary to convert the fonts to a supported format or use an unofficial TrueType conversion.)
Reset Old Preferences
If users have previously changed the "font.mathfont-family" preference for a previous version of Mozilla, then it is best to reset this to the default value. To do this, enter the URL "about:config", "Filter" for "mathfont", and "Reset" to the default value through the context menu on the preference.
Other fonts
It may be best to uninstall BaKoMa TrueType Computer Modern fonts if these have been installed (perhaps for a previous version of Mozilla) because these fonts use a character encoding that is inconsistent with Unicode recommendations. These fonts are not normally used, and thus may not cause problems, but if a document explicitly requests font-family "CMSY10" or "CMEX10" or similar, and the BaKoMa fonts are installed, then they will get used, which will likely result in the wrong symbols being shown.
There are some other fonts that provide good Unicode support for most mathematical characters, but without STIX Beta fonts some stretchy operators will not stretch to the appropriate size in Mozilla. Most notably, radical signs and under- and over-braces will not stretch to fit their content without STIX Beta fonts.
Stretched operators are drawn by using glyphs for larger variants of the character or by assembling glyphs for a few pieces of the character. These variant or part glyphs do not in general have Unicode assignments, and so font-specific support is required for some characters. Mozilla 1.9 has general support for the common delimiters and arrows that have the necessary Unicode assignments. For other characters, there is font-specific support only for STIX Beta fonts.
The following fonts are not necessary when the STIX Beta fonts are installed, but are worth noting because of their Unicode support for many mathematical characters.
-
Asana Math is freely available under the SIL Open Font License and has good support for mathematical characters. The font contains the necessary glyphs for stretchy operators but Mozilla does not yet make use of all of these.
-
DejaVu Serif and DejaVu Sans are freely available and installed with many Linux distributions. They contain support for many mathematical characters, and Mozilla will display some MathML reasonably on systems with these fonts installed, even without STIX Beta fonts. The font only contains glyphs for stretchy operators that have Unicode assignments.
-
Cambria Math is preinstalled on Microsoft Windows Vista, and also comes with Miscrosoft Office 2007 or Microsoft PowerPoint Viewer 2007. The font has good support for mathematical characters, and so, with any of these products installed, Mozilla will be able to display some MathML reasonably even without STIX Beta fonts. The font contains the necessary glyphs for stretchy operators but Mozilla does not yet make use of all of these. The license allows you to "use this font as permitted by the EULA for the product in which this font is included to display and print content", so consulting your lawyer is recommended if considering installing this on systems without the associated product.
-
On Mac OS X, the Apple's "Apple Symbols" and "Symbol" fonts provide support for many mathematical characters, so Mac users can view some MathML reasonably even without STIX Beta fonts installed.
Both Asana Math and Cambria Math include a MATH table as an extension to OpenType that would enable selecting glyphs for stretchy operators in a not-so-font-specific manner, but Mozilla does not yet make use of this.
Mozilla 1.8
| Fonts to Install for Mozilla 1.8 |
|---|
|
| Test Drive |
| The aim is to only see a minimum number of '?' as possible in this list of characters/entities for scientific documents. The list is best viewed with a Unicode-based browser such as Mozilla (a MathML-enabled build gives access to more glyphs via the ucvmath module). |
Mozilla 1.8 (including Firefox 2.0) was developed before any STIX fonts were publicly available. It was developed for use with Mathematica and/or Computer Modern fonts. Users may still benefit from installing the STIX fonts, but will still need to install Mathematica fonts and/or possibly BakoMa Computer Modern fonts.
Use the font installers (on the right) to install the fonts on your system if you do not have them already. MIT has developed convenient font installers for Windows and the Mac, following licensing negotiations through this project and mozilla.org staff (especially considering the open-source nature of Mozilla). The respective font owners have made provision for the fonts to be packaged into these installers, with the aim of helping to boost the adoption of MathML into the mainstream.
For your information, recommended fonts include:
-
TeX's Computer Modern Fonts
The TrueType fonts of interest are provided by virtue of the BakoMa license. The Type1 versions are from AMS. Note that TeX fonts are not bundled in the Mac installer due to bug 161137. You must not install these TeX fonts on the Mac now. To stop Mozilla from popping up the missing font dialog about TeX fonts, just set the user preference "font.mathfont-family" to "Math1, Math2, Math4, Symbol" in about:config orprefs.js. -
Mathematica 4.1 Fonts
The TrueType font packs are provided by Wolfram Research, Inc., for Windows and the Mac. The Type1 versions are in the PFA and PCF formats. -
Other Fonts
- MT Extra -- this is only in the Windows installer.
- Lucida Sans Unicode -- this is not in the installers but it is worth installing (separately) if you can. It contains many useful mathematical symbols. For Windows users, the installation of new fonts is explained in this font installation procedure.
Refer to the instructions on the Fonts to Install for Mozilla 1.8 section above.
Known Problems
Reported fonts' problems for which no built-in error recovery mechanism exists in Mozilla 1.8.
- On the Mac, bug 161137 causes MathML to render wrong symbols if TeX fonts are installed.
- On Win9x/NT/2000: If you see symbols (like the square-root symbol)
that appear jagged, then you are not using TeX fonts from the Bakoma
collection.
Work-around: Download the fonts from the Bakoma collection given above.
Customize the fonts used for stretchy characters
Due to the fact that a browser is used by various users under different configurations, Mozilla's MathML engine doesn't make assumptions on the particular configuration that a viewer may have, and uses a greedy search when looking for the best glyph that fits in a certain situation. As a result, a document is sometimes displayed with a mixture of glyphs with different characteristics because these glyphs happen to be picked from different font families.
It is possible for you, as a viewer, to instruct the MathML engine to
only use some of the fonts that you prefer. The following description
applies to fonts that only affect stretchy characters. Other characters
will continue to be rendered with other fonts (these are also
configurable -- but their configuration is not described here). You will
have to edit
prefs.js in your profile directory
(tip: you can also edit your preferences by entering about:config in the address bar).
To illustrate the impact of the choice of fonts, here are screenshots of a same page rendered with different stretchy font settings. These will give you a precise idea why it is academical/subjective, but still itchy enough for some people to insist on one or the other, just like one person might prefer Times while another prefers Verdana. The screenshots use an excerpt from the GNU Scientific Library manpage (c.f. bug 118475):
- Default screenshot: this is the default rendering obtained with the default installation.
-
Mathematica
screenshot: this is the rendering obtained by instructing the
MathML engine to use Mathematica fonts when a character is being
stretched. This can be achieved by adding this line in your
prefs.js:user_pref("font.mathfont-family", "Math1, Math2, Math4, Symbol"); -
TeX
screenshot: this is the rendering obtained by instructing the
MathML engine to use TeX's Computer Modern fonts when a character is
being stretched. This can be achieved by adding this line in your
prefs.js:user_pref("font.mathfont-family", "CMSY10, CMEX10, Symbol");
As a web viewer reading pages produced by others, it is possible for
you to set the list differently from the examples above. In fact, it is
possible to specify fonts per each individual stretchy character (in the
mathfont.properties file which contains
some of the encoding data of MathML
characters).
The recommended rule of thumb is to install all the fonts (if
possible) but use the above screenshots to decide whether you prefer
stretchy characters to be rendered by TeX fonts or Mathematica fonts,
then set the font.mathfont-family
accordingly. The reasoning here is that some of these fonts also contain
normal (i.e., non stretchy characters) and you don't want to lose them,
if possible. Both TeX fonts and Mathematica fonts work fine on Windows
and Linux. As indicated above, TeX fonts cause troubles on the Mac and so
Mathematica fonts are preferred there even for normal characters (see
also bug 228804
comment 32).
As a web author producing pages to be read by others, it is also
possible for you to instruct their MathML engine to only use some of the
fonts that you prefer for your documents (see the documentation in
mathml.css, and how this is used to setup
the alternate stylesheets that appear in the demos
of MathML tags). The caveat to remember:
- if a viewer has set the pref above, the fonts selected from your list are checked against the list that the viewer has chosen.
- viewers can choose to override document fonts altogether (by visiting the Fonts pref dialog and unchecking the pref to allow document fonts in the usual way).