Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
534 views
in Technique[技术] by (71.8m points)

xsl fo - 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 3x
plugin : pdf2, apache fo.

question from:https://stackoverflow.com/questions/66063729/how-to-apply-small-caps-to-a-string-via-xsl-fo

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...