[Fontconfig] Request for implementing font substitution for CJK fonts

Raimund Steger rs at mytum.de
Sun Jun 10 04:11:15 PDT 2012


Raimund Steger wrote:
> BlissSam wrote:
>> [...]
>> Mapping specific to generic, and map generic to specific,
>
> You summarized a correct way of doing this in a few words
> [...]

NB. I figure as an easy way of generating such rules you could use an 
XSLT to support some bogus group tag like:

----8<-------------

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="fontconfig">
<fontconfig>
<xsl:for-each select="*">
   <xsl:choose>
     <xsl:when test="name(.)='familygroup'">

       <xsl:for-each select="family">
         <alias>
           <family><xsl:value-of select="."/></family>
           <default>
             <family><xsl:value-of select="../@name"/></family>
           </default>
         </alias>
       </xsl:for-each>

       <alias>
         <family><xsl:value-of select="@name"/></family>
         <prefer>
         <xsl:for-each select="family">
           <family><xsl:value-of select="."/></family>
         </xsl:for-each>
         </prefer>
       </alias>

     </xsl:when>
     <xsl:otherwise>
       <xsl:copy-of select="."/>
     </xsl:otherwise>
   </xsl:choose>
</xsl:for-each>

</fontconfig>
</xsl:template>
</xsl:stylesheet>

----8<-------------

This would allow you to use:

   <familygroup name="Testgroup">
     <family>Test1</family>
     <family>Test2</family>
   </familygroup>

and apply it with

   xsltproc familygroup.xslt fonts.conf.in \
       | xmllint --format - > fonts.conf


Aside from that, I've just taken a look at the 65-fonts-persian.conf 
file Behdad mentioned. Actually I don't think having something similar 
for the most common CJK fonts would be that much of a problem, be it 
just to balance things out :-)


Raimund


More information about the Fontconfig mailing list