[HOME] jsMath (Authors) [Prev][Up][Skip][Next]

Adding Fonts to jsMath

JsMath comes with the information necessary to handle six of the TeX fonts: cmr10, cmmi10, cmsy10, cmex10, cmti10 and cmbx10. These are the Computer Modern roman, math italic, math symbol, extended symbol, text italic and bold text fonts. These are also the fonts whose .ttf files are available on the fonts download page. These are adequate for most situations, but some authors will want to use some of the other TeX fonts.

Several of the additional common fonts are available from the extra-fonts download page. These include the Computer Modern bold italic math font (cmmib10), the AMS Fractur, Greek and calligraphic fonts (eufm10, eurm10 and eusm10), and the AMS math symbol fonts (msam10, msbm10).

To use these fonts in your own pages, first download and unpack the correct .ZIP file from the extra-fonts download page. Put the resulting folder into the jsMath/fonts folder on your server. So if you are planning to use cmmib10, then you should end up with a folder called jsMath/fonts/cmmib10 on your server.

If you are using easy/load.js to load jsMath, you can add the new font to the loadFonts array in easy/load.js. For example,

    loadFonts: ["cmmib10"],
will cause the cmmib10 font to be available on every page that uses easy/load.js. If you are loading jsMath.js by hand, then in the HTML file that will be using the new font, include the line
    <SCRIPT> jsMath.Font.Load("cmmib10") </SCRIPT>
right after loading jsMath.js. That will load the data needed for jsMath to handle the cmmib10 font.

Some of the definition files will include macros for accessing the contents of the font. See the comments within the individual def.js files for details of what is defined by the file. Every definition file provides a macro that lets you switch to the given font in the same way that \rm and \bf work in math mode. For example, cmmib10 defines \cmmib for switching to cmmib10. Note, however, that it is only easy to access certain font positions this way (namely the positions corresponding to the letters of the alphabet); the definition file should provide other macros for obtaining the other characters in the font.

If there are no special macros for accessing the font, you can still produce the various characters from the font by using the \char{font}{number} macro, where font is the name of the font and number is the position of the character in the font, either in decimal or hexadecimal. For example, \char{cmmib10}{15}) and \char{cmmib10}{0x0F} both should produce a bold italic lower-case epsilon. (See the font tables available on the extra-font download page for the characters available in each font and their positions.)

You may need to enclose the \char command within a macro like \mathrel or \mathop to let jsMath know how you plan to use the symbol. For example, you may use \mathrel{\char{msam10}{0x26}} to get a greater-than sign over a tilde as a relation, and \mathbin{\char{msam10}{0x01}} to get a plus-sign in a square as a binary operator. See The TeXBook page 155 for more details on these macros.

If you will be using a symbol frequently, you can define a macro to make it easier to access the character. For example

  <SCRIPT> jsMath.Macro('boxplus','\\mathbin{\\char{msam10}{0x01}}'); </SCRIPT>
(after you load jsMath.js) will define \boxplus so that it produces the plus-sign in a box as a binary operator. See the sections on defining macros for jsMath for more details.



Get jsMath at SourceForge.net. Fast, secure and Free Open Source software downloads [HOME] jsMath web pages
Created: 10 Jul 2005
Last modified: 13 Sep 2008 09:48:57
Comments to: dpvc@union.edu
[Next] Defining Macros for jsMath
[Skip] Browser Support for jsMath
[Up] Information for jsMath Authors
[Prev] Adjusting Multiple jsMath Parameters