File: font-support.rst

package info (click to toggle)
mathjax-docs 2.7+20161014-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,080 kB
  • ctags: 14
  • sloc: sh: 22; python: 19; makefile: 8
file content (93 lines) | stat: -rw-r--r-- 3,637 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
.. _font-support:

********************
MathJax Font Support
********************

MathJax currently supports the following fonts:

* MathJax TeX (default)
* STIX General
* Asana Math
* Neo Euler
* Gyre Pagella
* Gyre Termes
* Latin Modern

MathJax contains customized webfont versions of these fonts. In particular,
these customized versions are split over several files to minimize the page
load.

Since browsers do not provide APIs to access font metrics, MathJax has
to ship with the necessary font data; this font data is
generated during development and cannot be generated on the fly. In addition,
most fonts do not cover the relevant characters for mathematical layout. Finally, some
fonts (e.g. Cambria Math) store important glyphs outside the Unicode range, making them
inaccessible to JavaScript. These are the main reasons why MathJax
is unable to support arbitrary fonts at this time.


Font configuration
==================

Page authors can configure their font preference for each
:ref:`output format <output-formats>` separately, see :ref:`HTML-CSS output
processor <configure-HTML-CSS>` and :ref:`SVG output processor
<configure-SVG>`. MathJax will download the necessary webfonts and fontdata
dynamically
and only those files necessary for the content.

For the HTML-CSS
output, MathJax will download webfonts in the appropriate webfont
format (depending on the client browser); for the SVG output, MathJax will
download path data that corresponds to the fonts.

The :ref:`HTML-CSS output processor <configure-HTML-CSS>` will prefer
locally installed copies of the webfonts to minimize page load. Page authors
can set a preference via the ``availableFonts`` and
``preferredFont`` options and they can configure the webfont via the
``webFont`` option. Please note that except for STIX General, the usual
distributions of the supported fonts do not work for technical reasons. You can
download the webfonts from the `MathJax repository
<https://github.com/mathjax/MathJax/tree/master/fonts/HTML-CSS>`_.

The :ref:`SVG output processor <configure-SVG>` will not use fonts directly but
derived SVG path data to draw paths corresponding to characters. The page author
can configure the font via the ``font`` option.

There is currently no method for switching fonts after MathJax has loaded.
Similarly, page users cannot change the font configuration at this time
except by installing their preferred fonts locally.


Character fallbacks
===================

No font contains a suitable glyph for every character specified in the
Unicode standard. When MathJax encounters a character the configured font does
not support, it will fall back to other fonts in a variety of ways.

First, MathJax enhances Unicode coverage of its default TeX fonts,
e.g., combining two double integrals ``U+222C`` when a quadrupel integral
``U+2A0C`` is used. However, this cannot create every character specified
in Unicode. Next, MathJax will run through a fallback chain within the
configured fonts (e.g., upright Greek will be substituted with italic Greek).
Finally, MathJax will ask the browser to provide the glyph from a system
font. Since in that final case, MathJax will not have the necessary data on the
glyph's bounding box, MathJax will guess these metrics; this can negatively
affect layout.


Adding new fonts
================

As mentioned, MathJax needs pre-generated font data to support a fonts.
This font data can be generated using the `MathJax development tools
<https://github.com/mathjax/MathJax-dev>`_.


Font mixing
===========

Mixing multiple fonts is currently not supported. We hope to add
support in the future.