[...]

> I use command:
>    a2x -f pdf --fop --xsl-file=my_fo.xsl top.txt
>
> The file "my_fo.xsl" is a wrapper around default /etc/.../fo.xsl:
> <xsl:stylesheet version="1.0"
>                xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>                xmlns:fo="http://www.w3.org/1999/XSL/Format";>
>  <xsl:import href="/etc/asciidoc/docbook-xsl/fo.xsl"/>
>  <xsl:template match="phrase[@role='zh']">
>    <fo:inline font-family="UMingCN">
>      <xsl:apply-templates/>
>    </fo:inline>
>  </xsl:template>
> </xsl:stylesheet>

Thanks Antonio, doing that isn't too bad (now we know that is).

@Stuart, I have attached a suggested FAQ entry to keep this info,
Antonio should check it of course :)

Since Gour found a workaround which meant he didn't have to persuade
dblatex to do the same thing, the answer is for FOP only at the
moment.

Cheers
Lex

>
> In my document I switch to Chinese font ("UMingCN" in this case)
> typing:
>    this is English while [zh]#this is Chinese# and this is back
> English.
>
> The wrapper can be easily extended to support Russian and ancient
> Greek ;)
>
> --
> You received this message because you are subscribed to the Google Groups 
> "asciidoc" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/asciidoc?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"asciidoc" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/asciidoc?hl=en.

== Using roles to select fonts for PDF

Some applications require mixing fonts beyond the set of faces
normally provided by default (normal, monospace, italic etc.) for example
mixed language text where the font used for the majority of text does
not contain suitable glyphs in the minority language.

As AsciiDoc can not provide presentation markup since it is not
provided by Docbook this is achieved by marking text which should
use a different font with a custom role which can be rendered by
the the docbook toolchain.

[NOTE]
For XHTML outputs AsciiDoc translates the role attribute to a
class which can be selected and styled by CSS as described in the
AsciiDoc users guide.

The Docbook toolchains will have to be configured to render the
text that you mark with the custom role.

For FOP a small XSL wrapper is needed, say a file called +my_fo.xsl+
containing:

----
<xsl:stylesheet version="1.0"
               xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
               xmlns:fo="http://www.w3.org/1999/XSL/Format";>
 <xsl:import href="/etc/asciidoc/docbook-xsl/fo.xsl"/>
 <xsl:template match="phrase[@role='f2']">
   <fo:inline font-family="the font for f2">
     <xsl:apply-templates/>
   </fo:inline>
 </xsl:template>
</xsl:stylesheet>
----

This is used with `a2x` by:

 a2x -f pdf --fop --xsl-file=my_fo.xsl input.txt

and the AsciiDoc source marked by:

 normal text [f2]#special font is like this# and back to normal

Thanks to Antonio Borneo for this answer.

Reply via email to