| 1 |
Math typesetting information |
| 2 |
============================ |
| 3 |
|
| 4 |
In summer of 2007 (as I write) MicroSoft is proposing an extension to OpenType |
| 5 |
which will allow fonts to contain information useful for mathematical |
| 6 |
typesetting. The information all lives in a new ``'MATH'`` table. FontForge now |
| 7 |
allows you to perform basic editing on this table. |
| 8 |
|
| 9 |
|
| 10 |
Constants |
| 11 |
--------- |
| 12 |
|
| 13 |
.. figure:: /images/MATH-Constants.png |
| 14 |
|
| 15 |
The table is divided into several parts. One part provides information on |
| 16 |
font-wide constants (And I do not mean "pi" or 2.71828... when I say constant |
| 17 |
here). These have to do with the size of various elements of mathematical |
| 18 |
formulae with respect to one another, and the spacing between them. So |
| 19 |
``FractionNumeratorGapMin`` specifies the minimum gap (white space) between the |
| 20 |
bottom of the numerator of a fraction and the fraction bar (the rule between the |
| 21 |
numerator and denominator. |
| 22 |
|
| 23 |
I will not describe all of these constants here, there are about 60 of them (and |
| 24 |
they take up 8 panes in the dialog). Most are fairly self-explanatory, but some |
| 25 |
I do not understand myself. FontForge has little popup messages plagerized from |
| 26 |
the specification which try to go into more detail. |
| 27 |
|
| 28 |
Some of these constants are stored as percentages of some other size |
| 29 |
(ScriptPercentScaleDown is and means that sub-elements should be drawn at a |
| 30 |
pointsize 73% of the current one -- I think). But most constants are represented |
| 31 |
in em-units, and most of these may also have device table adjustments specified. |
| 32 |
(At small pixel sizes (such as those used for screen fonts) the rounding error |
| 33 |
introduced by converting from em-units to pixels may be as large as the movement |
| 34 |
itself. A device table allows you to specify that (in the case of AxisHeight |
| 35 |
above) when the font is rasterized to be 10 pixels high the Axis should be moved |
| 36 |
up by one pixel). |
| 37 |
|
| 38 |
FontForge is not always configured to support device tables, so if these columns |
| 39 |
are missing you just need to reconfigure and rebuild it. |
| 40 |
|
| 41 |
|
| 42 |
Glyph specific information |
| 43 |
-------------------------- |
| 44 |
|
| 45 |
In addition to the constants there are various bits of data that potentially |
| 46 |
pertain to each glyph. |
| 47 |
|
| 48 |
|
| 49 |
Extended Shapes |
| 50 |
^^^^^^^^^^^^^^^ |
| 51 |
|
| 52 |
.. image:: /images/MATH-Exten.png |
| 53 |
:align: right |
| 54 |
|
| 55 |
The simplest of these per-glyph data is a flag which indicates whether a glyph |
| 56 |
is an extended shape. Extended shapes tend to be taller than normal characters |
| 57 |
and need to have superscripts raised higher than normal shapes. |
| 58 |
|
| 59 |
This sub-table consists of a list of glyph names and an indication of whether |
| 60 |
this glyph is an extended shape (you may add additional glyphs at the bottom of |
| 61 |
the list, order is irrelevant here). |
| 62 |
|
| 63 |
|
| 64 |
.. _math.Italic: |
| 65 |
|
| 66 |
Italic Correction |
| 67 |
^^^^^^^^^^^^^^^^^ |
| 68 |
|
| 69 |
.. figure:: /images/MATH-Italic.png |
| 70 |
|
| 71 |
The concept of "Italic correction" will be familiar to users of TeX. Basically |
| 72 |
when an upright glyph is placed after an italic (or oblique) glyph the slanted |
| 73 |
glyph may overlap the upright one slightly (since it is designed to fit next to |
| 74 |
another slanted glyph). The italic correction is a small addition to the glyph's |
| 75 |
advance width applied when followed by an upright glyph (and in some other cases |
| 76 |
too). |
| 77 |
|
| 78 |
If you allow the mouse cursor to hover over an entry a small window will pop up |
| 79 |
showing the glyph, the normal advance width (as a dotted line), and the |
| 80 |
corrected advance width. |
| 81 |
|
| 82 |
Here again you are allowed to specify a device table to adjust the correction. |
| 83 |
|
| 84 |
|
| 85 |
.. _math.TopAccent: |
| 86 |
|
| 87 |
Top Accent Attachment |
| 88 |
^^^^^^^^^^^^^^^^^^^^^ |
| 89 |
|
| 90 |
.. figure:: /images/MATH-TopAccent.png |
| 91 |
|
| 92 |
When positioning an accent above a glyph Mathematical typesetting follows complex |
| 93 |
rules to determine how high about the glyph it should go. The standard Mark To |
| 94 |
Base GPOS lookup is inappropriate here. |
| 95 |
|
| 96 |
Instead all that needs to be specified is the horizontal position at which the |
| 97 |
glyph and accent should attach. |
| 98 |
|
| 99 |
This table can be used to specify that position in both the base glyph and the |
| 100 |
accent. In the example at right I show one of each. The vertical line indicates |
| 101 |
the attachment position in each, and the glyphs will be adjusted so the two |
| 102 |
lines match up. |
| 103 |
|
| 104 |
Again a device table may be specified to control positioning at small pixel |
| 105 |
sizes. |
| 106 |
|
| 107 |
|
| 108 |
.. _math.MathKern: |
| 109 |
|
| 110 |
Math Kerning |
| 111 |
^^^^^^^^^^^^ |
| 112 |
|
| 113 |
.. image:: /images/MATH-MathKern.png |
| 114 |
:align: right |
| 115 |
|
| 116 |
This subtable is used when positioning subscripts and superscripts at various |
| 117 |
corners of a glyph. A glyph may have a superscript attached to either its top |
| 118 |
left or top right edge (limits for integral signs use the same mechanism, and |
| 119 |
probably other concepts will as well), and a subscript at the bottom left or |
| 120 |
right. |
| 121 |
|
| 122 |
In a slanted glyph it is clear that the horizontal positioning of a subscript |
| 123 |
should be different from the horizontal positioning of a superscript -- A |
| 124 |
problem similar to the italic correction. But this is more complex as the |
| 125 |
positioning point may depend on the size of the sub/superscript and exactly |
| 126 |
where it attaches vertically. |
| 127 |
|
| 128 |
This subtable allows you to specify a list of glyph kerning/height pairs for |
| 129 |
each corner of the glyph. Click on the word "Change" above to get a new dialog. |
| 130 |
These data may be specified textually: |
| 131 |
|
| 132 |
.. figure:: /images/MATH-MathKernText.png |
| 133 |
|
| 134 |
At any given height a kerning value may be specified. This value is relative to |
| 135 |
the default position of the subscript (and I'm not entirely sure what that is). |
| 136 |
As always device table adjustments may be specified. |
| 137 |
|
| 138 |
FontForge also allows you to specify these data graphically |
| 139 |
|
| 140 |
.. figure:: /images/MATH-MathKernGraph.png |
| 141 |
|
| 142 |
FontForge displays bottom right attachments relative to the advance width line |
| 143 |
of the glyph |
| 144 |
|
| 145 |
FontForge displays top right attachments relative to the advance width plus the |
| 146 |
italic correction. |
| 147 |
|
| 148 |
FontForge displays bottom left attachments relative to the origin of the glyph. |
| 149 |
|
| 150 |
FontForge displays top left attachments relative to the italic correction. |
| 151 |
|
| 152 |
Note: If you are familiar with the MATH table spec you will recall that the last |
| 153 |
kern value does not have a height attached to it. FontForge tries to guess a |
| 154 |
reasonable value for the unspecified height (because it makes editing easier if |
| 155 |
I let the user move a point around), but have no fears, that guessed at value |
| 156 |
will never show up in the MATH table itself. |
| 157 |
|
| 158 |
|
| 159 |
.. _math.Variants: |
| 160 |
|
| 161 |
Vertical and Horizontal Glyph Variants |
| 162 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 163 |
|
| 164 |
.. figure:: /images/MATH-VertVariants.png |
| 165 |
|
| 166 |
Some glyphs, like parentheses and brackets need to be drawn in many sizes |
| 167 |
depending on the size of the formula they are enclosing. One possibility is just |
| 168 |
to draw them at a larger pointsize, but that is non-optimal because then the |
| 169 |
glyph will be symmetrically scaled and so much bolder than it should be. Another |
| 170 |
solution is to design several variants of these glyphs at steadily increasing |
| 171 |
sizes. A third solution (which we will come to in the next section) is to design |
| 172 |
the glyph in sections so that it can be composed at any size. |
| 173 |
|
| 174 |
In this sub-table you may specify a normal sized glyph (here "leftparen") and |
| 175 |
then a list of variants in increasing sizes. |
| 176 |
|
| 177 |
Glyphs may be grow along either the vertical axis (as here) or the horizontal |
| 178 |
axis. |
| 179 |
|
| 180 |
|
| 181 |
.. _math.GlyphConstruction: |
| 182 |
|
| 183 |
Vertical and Horizontal Glyph Construction |
| 184 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 185 |
|
| 186 |
.. figure:: /images/MATH-GlyphConstruction.png |
| 187 |
|
| 188 |
As I said above, it is also possible to build a glyph out of bits of other |
| 189 |
glyphs. |
| 190 |
|
| 191 |
Each such constructed glyph has (potentially) and Italic Correction (and device |
| 192 |
table adjustment). This value should be independent of the size of the glyph. |
| 193 |
|
| 194 |
The components are rather difficult to specify in this display, but if you |
| 195 |
scroll the dialog to the far right you will find a little rectanglular box, and |
| 196 |
clicking on this will produce the dialog below. |
| 197 |
|
| 198 |
.. image:: /images/MATH-GlyphConstructionDlg.png |
| 199 |
|
| 200 |
.. image:: /images/MATH-GlyphConstructed.png |
| 201 |
:align: right |
| 202 |
|
| 203 |
Every component is either an "Extender" component -- which means it may be stuck in |
| 204 |
the composed glyph as often as needed (or not at all) to make the glyph be as |
| 205 |
big as needed. |
| 206 |
|
| 207 |
Component glyphs may overlap one another. You may specify a maximum overlap for |
| 208 |
each end of each component. You may also specify how much the component adds to |
| 209 |
the total height (or width) of the composed glyph. |
| 210 |
|
| 211 |
Finally there is a font-wide constant (in the Connectors pane of the Constants |
| 212 |
section) called MinConnectorOverlap which specifies that glyphs must overlap by |
| 213 |
at least this amount. |
| 214 |
|
| 215 |
The per-glyph information may also be specified from the |
| 216 |
:doc:`Glyph Information dialog. <charinfo>` |
| 217 |
|
| 218 |
I wish to thank Sergey Malkin at MicroSoft who provided me with a copy of the |
| 219 |
spec, and Apostolos Syropoulos who provided me with a test font containing a |
| 220 |
'MATH' table. |