Linux XFT and MathML

From MozillaZine Knowledge Base
Revision as of 22:25, 13 September 2006 by Np (talk | contribs) (page display -> websites)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

In order to view MathML content, you must have the appropriate fonts installed. On Linux systems, the fonts come in two formats; type1 for a non-XFT build (default for Mozilla Suite) and Truetype for an XFT build (default for Firefox, Thunderbird and RPM packaged Mozilla Suite builds. This page concentrates specifically on the XFT enabled case.

How do I tell if I have an XFT enabled build?

In the address bar of your browser, type about:buildconfig This produces a list of the options used when building the browser. If the list of options includes the string --enable-xft then you have an XFT enabled build.

Which fonts do I need?

Assuming you have a MathML enabled build, you need Truetype format font files. There are two sets of files that you need:

You may also require a symbol font, although this does not have to be a Truetype font - see the section on installing an symbol font later in the article.

Installing the fonts

Both sets of fonts are distributed in compressed form:

  • The TeX fonts are in a .tar.gz archive
  • The Mathematica fonts are in a self extracting zip archive which may be opened using a standard zip utility such as unzip or file-roller

Distribution specific methods for installing the fonts

  • If you are running a recent Gnome desktop environment then the fonts may be made avaliable to the current user by simply copying the font files to the .fonts subdirectory of the user's home directory
  • If you are using a recent KDE desktop environment then there is a font installation utility provided with your system

A generic way of installing fonts

These instructions are based on the installing fonts under Linux document at linux.org.mt. You will probably need root access to follow these instructions.

  • Create a directory for your fonts. Typically this will be something like /usr/share/fonts/tex Decompress the archives you downloaded and copy the .ttf files to this directory
  • From the directory you copied the fonts to, enter the commands:
 ttmkfontdir > fonts.scale
 mkfontdir

This should create a file fonts.scale and fonts.dir

  • The X server needs to know about the fonts. With some distributions, it might be possible to run the command:
 chkfontpath -a /usr/local/fonts/tex

where /usr/local/fonts/tex should be replaced by the directory in which you placed the fonts. If this command does not exist, you will need to edit the X font configuraion file directly. Typically, this will be loacted somewhere like /usr/etc/X11/fs/config or /etc/X11/xfs/config. Look for a line starting with 'catalog=' and append the name of the directory you installed the fonts to onto this line.

  • You may need to restart your X server for changes to take effect. If your computer boots straight into X, you can restart using ctrl+alt+backspace - this will kill the X Server and you will be required to log on again. Rememebr to save your work first!
  • It should now be possible to see the newly installed fonts in Xfs - supporting applications.

Installing the Symbol font

By default, Mozilla is able to make use of a Symbol font in type1 format, because these are more widely available. However, the default name of the symbol font that comes with most Linux distributions is not recognised by Mozilla.

One way to obtain a symbol font is to change the name of an installed symbol font so it is recognised by Mozilla. You will need to locate a symbol font on your system (more detail would be good here). Open the fonts.spec file in the directory containing the symbol font and find lines containing "Standard Symbols L"; duplicate these lines, replacing the string "Standard Symbols L" with "Symbol".

  • Adobe Acrobat may come with a font which is already named "Symbol" so the above step isn't necessary (I tried installing acrobat and this didn't work... has anyone got this to work?)

Using a Truetype Symbol font

  • If you have access to a Truetype Symbol font, you may use it, but you will have to edit the Mozilla configuation in order for it to be recognised
  • Install the font, as for the mathematica and TeX fonts
  • Navigate to the path mozilla/res/fonts (where mozilla is the base directory of your Mozilla install e.g. /usr/local/MozillaFirefox) and open the file fontsEncoding.properties
  • Uncomment the lines:
 #encoding.symbol.ttf = Adobe-Symbol-Encoding
 #encoding.symbol.ftcmap = mac_roman

i.e. replace them with:

 encoding.symbol.ttf = Adobe-Symbol-Encoding
 encoding.symbol.ftcmap = mac_roman

Getting freetype working with non-Xft builds

If your build does not have --enable-xft, it is possible that it still has the TrueType support compiled in. This support is different from that with --enable-xft builds. It is generally agreed that --enable-xft builds produce better looking results.

  • In order to use TrueType MathML fonts, you must have freetype support working, either via --enable-xft or via a freetype support compiled in. This section assumes the latter. That your build doesn't have --enable-xft, but freetype is installed and mozilla can find it. You need to set the pref:
 font.FreeType2.enable=true
  • Type about:config into the location bar and use the filter box to select only entries containing the term 'freetype'
  • Find the pref named font.Freetype2.enable and select modify from the context menu. Set the value to true.
  • If freetype isn't installed, we need more instructions. In the meantime, look at the instructions on the enabling freetype page.

Advanced Topics

There are various ways to get nicer fonts or enable more fonts. Hopefully someone who knows them will add them here.

Testing MathML fonts

The MathML torture page is a good place to start testing fonts

Further Information

The MathML project page has more information about all aspects of MathML in Mozilla.