Re: Multiple languages in PDF?

Alemps Florimond <[email protected]> Wed, 22 Dec 2021 06:35:03 +0000 (UTC)
Newsgroups gmane.text.docbook.apps
Message-ID <[email protected]>
Hello
I would address this like that :
 <para>The Hōjōki [<foreignphrase xml:lang="ja">方丈記</foreignphrase>] is an important and popular short work of the early Kamakura period.</para>
Customise font here :
<xsl:template match="d:foreignphrase">
  <xsl:choose>
   <xsl:when test="contains(' ja ', @xml:lang)">
      <fo:inline font-family="Hiragino Mincho ProN">        <xsl:apply-templates/>
      </fo:inline>
   </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="inline.italicseq"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
"contains" is useful if you can use the same font for different languages ... : 
   <xsl:when test="contains(' ja ko zh ', @xml:lang)">
      <fo:inline font-family= Hiragino Mincho ProN">        <xsl:apply-templates/>
      </fo:inline>
   </xsl:when>

For titles, I would condition attribute font-family in the appropriate xsl:attribute-sets="section.titlepage.recto.style based on xml:lang as done above.
To make sure it is not a problem with the font itself :1. replace "Hiragino Mincho ProN" with Arial or Times or even2. set attribute font-weight="bold"

Hope this helpFlorimond
 
 
 Le mercredi 22 décembre 2021, 04:01:33 UTC+1, M. Downing Roberts <[email protected]> a écrit : 





I'm back with another question.

I'd like to combine English and Japanese text in a single book. I can set the @lang attribute on various elements, but the problem is that I need to switch fonts, too. The font that I want to use for body text doesn't include Japanese characters. I'm not sure how to embed Japanese text within a <para> of English and get it to render properly. E.g.:

> <para>The Hōjōki [方丈記] is an important and popular short work of the early Kamakura period.</para>

It seems like I need something akin to <span lang="ja"> to mark the Japanese text, and then a customization in the stylesheet to detect this and specify a suitable font. However, I'm not sure how I should handle either of these issues.

I would also like to specify a different font for the <subtitle> element. I've tried this customization:

> <xsl:template match="subtitle" mode="section.titlepage.recto.auto.mode">
> <fo:block xsl:use-attribute-sets="section.titlepage.recto.style" font-family="Hiragino Mincho ProN">
> <xsl:apply-templates select="." mode="section.titlepage.recto.mode"/>
> </fo:block>
> </xsl:template>
 
> <xsl:template match="subtitle" mode="titlepage.mode">
>   <fo:block font-family="Hiragino Mincho ProN">
>     <xsl:apply-templates mode="titlepage.mode"/>
>   </fo:block>
> </xsl:template>

...but it seems to have no effect. The font is not found, though it is installed on my machine.

What am I doing wrong? What's the best way to approach this?

Thanks!

M.