Number font in mathml for DocBook

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
expatriate
Posts: 39
Joined: Wed Dec 31, 2008 12:42 am

Number font in mathml for DocBook

Post by expatriate » Tue Dec 15, 2009 9:35 pm

Changing the font to sans-serif for a DocBook article containing mathml formulae changes the math font too, which is what I hoped. But it doesn't change the number font (at least, not for FOP PDF output), which remains serif. Can this be fixed?

iulian_velea
Posts: 63
Joined: Fri Dec 12, 2003 6:34 pm
Contact:

Re: Number font in mathml for DocBook

Post by iulian_velea » Wed Dec 16, 2009 12:35 pm

Hello,

What I understand from your message is that you want to change the font of the MathML equations in the final FOP PDF output.
The MathML equations can be included in the DocBook documents as inline content or as an external graphic.

For formulae referenced using <fo:external-graphic> there is no support for transmitting the ".fo" context when transformed to PDF.

Inline MathML is supported through the <fo:instream-foreign-object> tag.
MathML specified inline will take the following attributes from the surrounding ".fo" context:

* Font size
* Font color
* Background color
* Name of the fonts used.

So if you want to change the font of the MathML objects, you need to specify values for the font related attributes of the instream-foreign-object.
To do this you need to modify the DocBook stylesheet responsible for transforming the MathML into FO. The stylesheet is located in the
"{Oxygen_Installation_Folder}/frameworks/docbook/xsl/fo/math.xsl" file.
The template that applies to the MathML sections can be modified like this for instance (I changed the font family and font size):

Code: Select all

<!-- "Support" for MathML -->

<xsl:template match="mml:math" xmlns:mml="http://www.w3.org/1998/Math/MathML">
<xsl:choose>
<!-- * If user is using passivetex, we don't wrap the output in -->
<!-- * fo:instream-foreign-object (which passivetex doesn't support). -->
<xsl:when test="not($passivetex.extensions = 0)">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<fo:instream-foreign-object font-family="Monospaced" font-size="20">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</fo:instream-foreign-object>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

Post Reply