Main stylesheet


Main idea

Each MathML element can be viewed as a box that will be placed on the final SVG document. A box is represented by a minimum of six attributes that give information about its position and its size.

Attributes of a box

X, Y

Represent the two dimension coordinates of the upper left corner of the box.

WIDTH, HEIGHT

Represent the size of the box.

BASELINE

Represents the line on which the character will be aligned. Analogies can be made with the light guide lines on a lined sheet.

FONTSIZE

Determines the font size used in this box.

pMML2SVG works with the XML tree and transforms MathML to SVG in two passes. The first pass, called formatting mode, anotates each node of the MathML tree with information about position and size in order to compute a box. These annotations are placed as attributes on the node and belong to a temporary namespace named t. A namespace is a family of XML tags and attributes defined in an XML schemas. The second pass, named drawing mode, interprets annotations in order to draw the boxes on the SVG result canevas.

Some boxes need additionnal information to render correctly. For example, for the fraction, coordinates have to be added to place the fraction bar. Each element will describe which information is added to the tree and how it is handled.

An XSLT template is written for each MathML element and for each pass. It means that to implement a MathML element, two templates have to be written. One for the formatting mode and one for the drawing mode.

Table of Contents

svgMasterUnit
initSize
minSize
delimPart
delimScale
thin
medium
thick
rowElement
getMiddle — Determines the space between the baseline and the middle of the line. This middle is the horizontal bar of the plus operator.
computeSize
computeSizeMult — Compute the factor that will multiply (or divide) the initial size in the computeSize function.
unitInPx
getSpaceLiteral
chooseAttribute — Selects the best value between the three paramaters.
getFontNameVariant — Computes the variant of the font name with respect to the style parameters.
setStyle — Computes a CSS style rule for an element with respect to all style attributes.
stringWidth — Function that simply calls the stringWidth template.
stringWidth
math:math — Root element of the transformation.