xsl-foditadita-ot

How to apply small-caps to a string via XSL FO


I am trying to customize the PDF2 plugin in DITA-OT. I want to apply small caps to the string "Chapter" and chapter number that appear at the start of every chapter.

What I did so far

In my custom plugin, I modified the following the __chapter__frontmatter__name__container attribute-set in the static-content-attr.xsl file to include <xsl:attribute name="font-variant">small-caps</xsl:attribute> :

 <xsl:attribute-set name="__chapter__frontmatter__name__container">
    
    <xsl:attribute name="font-size">14pt</xsl:attribute>
    <xsl:attribute name="font-weight">none</xsl:attribute>
    <xsl:attribute name="border-before-style">none</xsl:attribute>
    <xsl:attribute name="border-after-style">none</xsl:attribute>
    <xsl:attribute name="border-before-width">0pt</xsl:attribute>
    <xsl:attribute name="border-after-width">0pt</xsl:attribute>
    <xsl:attribute name="padding-top">10pt</xsl:attribute>
    <xsl:attribute name="font-variant">small-caps</xsl:attribute>
</xsl:attribute-set>

Actual Result

small-caps is not applied to the string.

enter image description here

Expected Result

enter image description here

How can I make font-variant work in XSL FO?

XML Framework : DITA
Publishing Engine : DITA-OT 3.x
Plugin : org.dita.pdf2, org.dita.pdf2.fop


Solution

  • Your syntax is correct (rather, it will be correct in the result tree). See https://www.w3.org/TR/xsl11/#font-variant

    However, FOP does not support font-variant. See https://xmlgraphics.apache.org/fop/compliance.html#fo-property-font-variant

    You may be able to get small caps if you use a small caps-only font. The FOP font page at https://xmlgraphics.apache.org/fop/2.6/fonts.html notes that OpenType includes small caps but then notes that FOP doesn't support OpenType features.

    There are other formatters that do support small caps and that work with the DITA-OT.