diff --git a/modules/fonts.xml b/modules/fonts.xml index a306914..6fa85d6 100644 --- a/modules/fonts.xml +++ b/modules/fonts.xml @@ -31,6 +31,57 @@ </common> </template> + <!-- + Set a specific typeface. This is kind of tricky, since standard LaTeX and XeLaTeX use different font naming schemes, and in (X)HTML we also need to be able to specify fallbacks. The upshot is that you have to provide three different font specifications for the same typeface! + + Note that if the relevant attribute for the current format is omitted, then the font element will be ignored. + + @latex: The name of the typeface for standard LaTeX, e.g., "bfu". + + @xelatex: The name of the typeface for XeLaTeX, e.g., "Futura Book". + + @html: The name of the typeface followed by a list of fallbacks, e.g., "'Futura Book', Helvetica, Arial, sans-serif". Font names containing whitespace, numbers or punctuation should be enclosed in SINGLE quotes. + + @fontspec-options: Any options that apply to the typeface when loading with fontspec, e.g., "Scale=MatchLowercase". + --> + <template name="font" match="font|typeface"> + <common formats="/latex/"> + <xsl:if test="@latex"> + <xsl:text>{\fontfamily{</xsl:text> + <xsl:value-of select="@latex" /> + <xsl:text>}\selectfont</xsl:text> + <xsl:apply-templates /> + <xsl:text>}</xsl:text> + </xsl:if> + </common> + <common formats="/xelatex/"> + <xsl:if test="@xelatex"> + <xsl:text>{\fontspec</xsl:text> + <xsl:if test="@fontspec-options"> + <xsl:text>[</xsl:text> + <xsl:value-of select="@fontspec-options" /> + <xsl:text>]</xsl:text> + </xsl:if> + <xsl:text>{</xsl:text> + <xsl:value-of select="@xelatex" /> + <xsl:text>}</xsl:text> + <xsl:apply-templates /> + <xsl:text>}</xsl:text> + </xsl:if> + </common> + <common formats="/html/xhtml/"> + <xsl:if test="@html"> + <span> + <xsl:attribute name="style"> + <xsl:text>font-family: </xsl:text> + <xsl:value-of select="@html" /> + <xsl:text>;</xsl:text> + </xsl:attribute> + </span> + </xsl:if> + </common> + </template> + <!-- Font sizing, using relative font size elements borrowed from LaTeX. Note that we use CSS relative font sizes (smaller and larger), which means that we have to string a bunch of them together to achieve the same effect as a single command in LaTeX. We can't use absolute sizes in CSS as they would probably look different on different machines.