How can I conditionalize fonts based on language?

136 views
Skip to first unread message

mkaa...@gmail.com

unread,
Nov 5, 2013, 6:30:33 PM11/5/13
to dita-o...@googlegroups.com
Use case: For Chinese documents, I want to use Adobe Song for every font.

Currently, Chinese characters are using Adobe song but all numerals and punctuation flip to Arial Unicode MS.

My current approach is to do it at the ANT level and conditionally specify a catalog.xml which specifies a specific font-mappings file.

    <condition property="xml.catalog.files" 
             value="${customization.dir}/catalog-ZH.xml" 
             else="${customization.dir}/catalog.xml;${dita.plugin.org.dita.pdf2.dir}/cfg/catalog.xml;${dita.dir}/catalog-dita.xml">
    <equals arg1="${document.locale}" arg2="zh_CN"/>
    </condition>

This logic seems correct, but unfortunately, document.locale isn't set at this point in build.xml.

Is there a better way to achieve what I'm trying to do or an easy way to get ant to set document.locale earlier?

Thanks!
Matt

Jarno Elovirta

unread,
Nov 5, 2013, 6:45:06 PM11/5/13
to Matt Kaatman, dita-o...@googlegroups.com
If other languages do not need I18N processing, disable I18N completely and manage fonts in your XSL overrides?

J

--
You received this message because you are subscribed to the Google Groups "DITA-OT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dita-ot-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

mkaa...@gmail.com

unread,
Nov 5, 2013, 8:45:34 PM11/5/13
to dita-o...@googlegroups.com, Matt Kaatman
I'm currently dependent on them still. Working my way off of them but it could be a while still.

Any other ideas for a plan B to hold me over until then?

Thanks!
Matt

Kathy Pitts

unread,
Nov 5, 2013, 9:28:51 PM11/5/13
to mkaa...@gmail.com, dita-o...@googlegroups.com
Hello Matt,
 
If you are generating a PDF, have you tried changing the font-mappings.xml file?
 
Regards,
Kathy

Matt Kaatman

unread,
Nov 5, 2013, 9:34:15 PM11/5/13
to Kathy Pitts, dita-o...@googlegroups.com
Hey Kathy,

Yes, in the font-mappings for each logical font (Sans, Serif, and monospace)

I have Chinese defined and that works great:
      <physical-font char-set="Simplified Chinese">
        <font-face>AdobeSongStd-Light</font-face>
      </physical-font>

But it doesn't cover numbers and punctuation which are falling under default and not Simplified Chinese

      <physical-font char-set="default">
        <font-face>Helvetica, Arial Unicode MS</font-face>
      </physical-font>

If I force default to use Adobe Song, Chinese is perfect. However, that messes up the rest of my translations. I was hoping to find a way to conditionalize it based on language.

I guess worst case scenario, I'll just have to create a separate plugin for Chinese with this single change and try to keep everything else in sync. I was hoping to avoid that scenario.




Jarno Elovirta

unread,
Nov 6, 2013, 4:43:50 AM11/6/13
to Matt Kaatman, Kathy Pitts, dita-o...@googlegroups.com
I haven't checked if it's possible, but could you override the i18n/zh_CN.xml with your own version that maps punctuation to Simplified Chinese too?

J

mkaa...@gmail.com

unread,
Nov 6, 2013, 4:39:36 PM11/6/13
to dita-o...@googlegroups.com, Matt Kaatman, Kathy Pitts
Hey Jarno, That's perfect. I added two blocks

One for punctuation:
           <character-range>
    <start include="yes">&#x0021;</start>
    <end include="yes">&#x00BF;</end>
 </character-range>

One for numbering:
           <character-range>
     <start include="yes">&#x0030;</start>
     <end include="yes">&#x0039;</end>
  </character-range>

I might extend the range quite a bit so that nearly everything is covered, but this is working great!

Matt

mkaa...@gmail.com

unread,
Nov 6, 2013, 5:33:35 PM11/6/13
to dita-o...@googlegroups.com
One final update. For reasons I don't quite understand, the only thing that was slipping through was page numbers in the TOC and footer.

I handled these two cases by adding attributes:
<xsl:attribute name="font-family"><xsl:choose><xsl:when test="//*[contains(@xml:lang, 'zh-CN')]">SansZH</xsl:when><xsl:otherwise>Sans</xsl:otherwise></xsl:choose></xsl:attribute>

And defining a SansZH in my font mappings where the default font pointed to Adobe Song.

Jarno Elovirta

unread,
Nov 6, 2013, 5:35:22 PM11/6/13
to Matt Kaatman, dita-o...@googlegroups.com
Page numbers are generated by an XSL instruction and are not recognized by I18N process, that’s the reason.

J

Rahul H

unread,
Jan 16, 2017, 8:22:43 AM1/16/17
to DITA-OT Users

Hi Team,

I have similar issue in DITA PDF generation. I have one chine topic with Chinese and English text with punctuation. All Chinese charters are getting simsun and English charters are getting Arial. but problem here is apostrophe in English text is getting simsun!.. how can add arial for apostrophe too. I have posted same in this group but no one replied.

Thanks
Rahul
Reply all
Reply to author
Forward
0 new messages