stringWidth
<xsl:template name="stringWidth"> <xsl:param name="str"/> <xsl:param name="strLen"/> <xsl:param name="i" select="1"/> <xsl:param name="size" select="0"/> <xsl:param name="fontName" select="'STIXGeneral'"/> <xsl:param name="variant" select="''"/> ... </xsl:template>
It is a recursive function that sums the width of each character
that composes the string. A correction is added to the top and to the bottom of the string. This correction is computed using
the bounding box of, respectively, the first and the last character of the string. These two corrections are compute in the
leftBearing
and rightBearing
variables.
Note that the recursion will always end because the index i
will finally reached strLen
. Moreover,
it is never recursively called with the same parameter values as the first call because the index i
is
always incremented by one.
String to compute the width.
Number of character in the string.
Index of the character that is currently handled.
This parameter is an accumulator that contains the size (in em) for the first i-1
characters of the string.
List of fonts that will be used to render the string.
Variant for the font.