You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.



Enable MathML on other Platforms

The rendering of MathML in Mozilla is native. The MathML module is a built-in component of the Gecko layout engine and so it is not possible to use it in isolation outside of Mozilla. It is built upon APIs provided by Gecko, and incorporates elements needed for the particular aspects of MathML. However, it can be used wherever the Gecko layout engine is used. You can choose to embed Gecko in your application with MathML included alongside the other goodies that Mozilla provides. The activation of MathML has been designed to happen lazily (i.e., if/when a page with MathML content is encountered for the first time as the user browses), and measurements have shown that MathML has no perceptible impact on page load performance.

Since it is an add-on, it can be left out when you are initially porting Gecko to your platform, and once you have successfully ported Mozilla while disabling MathML (or with simple stubs for the extra APIs needed by the MathML component), there are essentially two main things that you need to do to hook MathML properly. The rest of the MathML renderer is entirely cross-platform but the two specific things that are needed to render MathML properly on your platform are vital. Both are related to fonts.

  1. Hook the ucvmath module properly.
    MathML processing involves special characters not found in ordinary fonts. The ucvmath module provides the necessary encoding data to access these.

  2. Implement nsIRenderingContext::GetBoundingMetrics()
    The usual font metrics only provide an overall set of metrics that are meant to be a best fit for all characters in the font. Quality mathematical typesetting, however, requires the precise glyph outline of each character. The GetBoundingMetrics() function is used to obtain the metrics needed for precise MathML placements.
MathML is enabled by default in the official releases for the three main Mozilla platforms (Windows, Linux, Mac -- from m1.1). Other platforms (e.g., OS2) for which no MathML-enabled builds are available so far are platforms that don't yet implement the extra hooks. It is informative to see how these were addressed in other situations. To this end, included below are some links that might be of assistance in your porting (also included are the bonsai checkins with comments that have references to these bug numbers if you want to see the diffs in a nicer HTML format).

Roger B. Sidje <rbs@maths.uq.edu.au>