[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] clean and mode-less param switching ideas
This can be done using a customization of the template named 'set.flow.properties' as well as a couple of attribute-sets. Generally, the body font is set in only a few places in an FO file. The root.properties attribute-set puts the font-family property on the fo:root element, which makes it the font for all text not otherwise specified. That means it is applied to all page-sequences, unless one of them overrides it. Setting the font-family property on an fo:flow start tag in a page-sequence will override the root font value. First, let me mention that when resetting the XSL-FO font-family property, just setting it to a new font name is generally not sufficient for handling symbols. Most fonts don't have all the symbols. So the font-family property should be set to a comma-separated font list that adds at least the Symbol font, and possibly others. The DocBook stylesheets use an internal param named 'body.fontset' for that reason. See this doc for more info: http://www.sagehill.net/docbookxsl/SpecialChars.html#fontFamilyList So I would suggest you create new params 'alt.body.font.family' and 'alt.body.fontset' to specify the font name and font list, respectively. Then you can use the new fontset in the customized templates and attribute-sets. Here is a sample customization that detects when a part element has a role="part2" attribute and changes the font. You can change the test to whatever criteria you use. <xsl:param name="alt.body.font.family">Helvetica</xsl:param> <xsl:param name="alt.body.fontset"> <xsl:value-of select="$alt.body.font.family"/> <xsl:if test="$alt.body.font.family != '' and $symbol.font.family != ''">,</xsl:if> <xsl:value-of select="$symbol.font.family"/> </xsl:param> <xsl:template name="set.flow.properties"> <xsl:param name="element" select="local-name(.)"/> <xsl:param name="master-reference" select="''"/> <!-- This template is called after each <fo:flow> starts. --> <!-- Customize this template to set attributes on fo:flow --> <!-- remove -draft from reference --> <xsl:variable name="pageclass"> <xsl:choose> <xsl:when test="contains($master-reference, '-draft')"> <xsl:value-of select="substring-before($master-reference, '-draft')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$master-reference"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:choose> <xsl:when test="$fop.extensions != 0 or $passivetex.extensions != 0"> <!-- body.start.indent does not work well with these processors --> </xsl:when> <xsl:when test="starts-with($pageclass, 'body') or starts-with($pageclass, 'lot') or starts-with($pageclass, 'front') or $element = 'preface' or (starts-with($pageclass, 'back') and $element = 'appendix')"> <xsl:attribute name="start-indent"> <xsl:value-of select="$body.start.indent"/> </xsl:attribute> <xsl:attribute name="end-indent"> <xsl:value-of select="$body.end.indent"/> </xsl:attribute> </xsl:when> </xsl:choose> <!-- Add this test to change the font-family for a special flow --> <xsl:if test="ancestor::part[@role = 'part2']"> <xsl:attribute name="font-family"> <xsl:value-of select="$alt.body.fontset"/> </xsl:attribute> </xsl:if> </xsl:template> <!-- The following changes handle the header and footer font, since those are in the static content and not inside fo:flow --> <xsl:attribute-set name="footer.content.properties"> <xsl:attribute name="font-family"> <xsl:choose> <xsl:when test="ancestor::part[@role = 'part2']"> <xsl:value-of select="$alt.body.fontset"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$body.fontset"/> </xsl:otherwise> </xsl:choose> </xsl:attribute> </xsl:attribute-set> <xsl:attribute-set name="header.content.properties"> <xsl:attribute name="font-family"> <xsl:choose> <xsl:when test="ancestor::part[@role = 'part2']"> <xsl:value-of select="$alt.body.fontset"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$body.fontset"/> </xsl:otherwise> </xsl:choose> </xsl:attribute> </xsl:attribute-set> There are a few other attribute-sets that use $body.fontset, such as footnotes. If you want complete coverage, check out the fo/param.xsl file and use similar xsl:choose statements for the font-family in those attribute-sets as well. Bob Stayton Sagehill Enterprises bobs@sagehill.net ----- Original Message ----- From: "Shane Handford" <shandford@castlerockresearch.com> To: <docbook-apps@lists.oasis-open.org> Sent: Wednesday, June 24, 2009 10:07 AM Subject: [docbook-apps] clean and mode-less param switching ideas > Does anyone have any ideas on how I could affect global stylesheet params > such as body.font.family for different sections of my output? > > eg. a book in two parts - first and second parts use separate fonts. > > saxon:assign is too risky and unpredictable. > > I rather not recreate templates with modes to switch the font. > > I'm probably going to fork out my code to use a different param based on > context. Just wondering if anyone has any other suggestions. > > Thanks ! > > ~Shane > > --------------------------------------------------------------------- > To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org > For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org > > >
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]