math:mi|math:mn|math:mtext|math:ms (in formatting mode) — Formatting a token element.
<xsl:template match="math:mi|math:mn|math:mtext|math:ms" mode="formatting"> <xsl:param name="x"/> <xsl:param name="y"/> <xsl:param name="baseline" select="0"/> <xsl:param name="fontName" tunnel="yes"/> <xsl:param name="scriptlevel" tunnel="yes"/> <xsl:param name="mathvariant" tunnel="yes"/> <xsl:param name="mathcolor" tunnel="yes"/> <xsl:param name="mathbackground" tunnel="yes"/> ... </xsl:template>
All these elements are treated the same way with a few exceptions. Therefore, in the implemented stylesheet, they share the same template, both for formatting and for drawing. These elements are the leaf of the MathML tree, they do not have any children, they only contain text.
After computing the font size of these elements, the ms
lquote
and rquote
attributes are retrieved. These attributes determine which symbol will be used to surround the text, respectively, on the left and on the right.
After that, the text content of the element is retrieved. lquote
is added before the first character and rquote
after the last one if the element is ms
.
Next, the font variant is computed to retrieve the width and the height of the text. An mi
element with one letter
(except infinity symbol) has to be displayed in italic, so the font variant is computed using that particularities. All the parameters of the box
can now be computed: the height is given by font metrics file, the width is computed using the stringWidth
function and
the baseline is set on the bottom of the text with descender stretching under it. The box also contains an other measure:
HEIGHTOVERBASELINE
which is the height of the box from its baseline to its top edge. Here is a figure that represent the box
for a token element:
The left bearing of the box is computed to shift the character inside the box. If no bearing is computed, some characters are drawn outside the box. For exemple, the left part of an italic f goes out of the left side of the box if no shift value is added by using the left bearing. The right bearing is computed to place the subscript closer to some characters. In the case of an italic f , if the subscript is placed after the letter box, it will be too far away from f . If the right bearing is withdrawn from the coordinates of the right side of the box, the subscript will be drawn closer.
Finally, the tree node is annotated with the box representation and with style (attributes STYLE
) information about the box.
A shift value (SHIFTX
) is also added when the token has a left bearing. The left bearing is a negative value from the left value of
the first character bounding box. It occurs, for example, with an italic
f
.