[Fontconfig] a warning-free way to apply <edit> to multiple font families?

Raimund Steger rs at mytum.de
Wed Aug 13 17:07:40 PDT 2014


Jungshik SHIN (신정식) wrote:
> Hi,
>
> This is about https://bugs.freedesktop.org/show_bug.cgi?id=82582.
>
> In the past (e.g. fontconfig 2.7.x), I could use the following to apply
> <edit>'s to a group of font families :
>
> <match target="font">
>     <test name="family" compare="contains">
>          <string>MYingHeiB5HK</string>
>          <string>MYingHeiGB18030</string>
>          <string>MSung GB18030</string>
>          <string>MSung B5HK</string>
>      </test>
>      <!-- Turn on light auto-hint -->
>      <!-- Turn off sub-pixel anti-aliasing -->
>      <edit name="hinting" mode="assign"><bool>true</bool></edit>
>      <edit name="autohint" mode="assign"><bool>true</bool></edit>
>      <edit name="hintstyle" mode="assign"><const>hintslight</const></edit>
>      <edit name="antialias" mode="assign"><bool>true</bool></edit>
>      <edit name="rgba" mode="assign"><const>none</const></edit>
>   </match>
>

Two ways to do it -- both should work:

(1) assign a flag to the font, match on the flag:

   <match target="font">
     <test name="family"><string>MYingHeiB5HK</string></test>
     <edit mode="assign" name="custom_autohint"><bool>true</bool></edit>
   </match>
   <match target="font">
     <test name="family"><string>MYingHeiGB18030</string></test>
     <edit mode="assign" name="custom_autohint"><bool>true</bool></edit>
   </match>
   [...]
   <match target="font"> <!-- (*) -->
     <test name="custom_autohint"><bool>true</bool></test>
     <edit name="hinting" mode="assign"><bool>true</bool></edit>
     <edit name="autohint" mode="assign"><bool>true</bool></edit>
     <edit name="hintstyle" mode="assign"><const>hintslight</const></edit>
     <edit name="antialias" mode="assign"><bool>true</bool></edit>
     <edit name="rgba" mode="assign"><const>none</const></edit>
   </match>

(2) same, but match on the inverse case (shorter):

   <match target="font">
     <edit mode="assign" name="custom_autohint"><bool>true</bool></edit>
   </match>
   <match target="font">
     <test name="family" qual="all" 
compare="not_eq"><string>MYingHeiB5HK</string></test>
     <test name="family" qual="all" 
compare="not_eq"><string>MYingHeiGB18030</string></test>
     [...]
     <edit mode="assign" name="custom_autohint"><bool>false</bool></edit>

     <!-- ... edit block as in (*) above. -->
   </match>

"contains" uses substring matching, so that's hardly useful.


Raimund


-- 
Worringer Str 31 Duesseldorf 40211 DE  home: <rs at mytum.de>
+49-179-2981632 icq 16845346           work: <rs at interface-ag.de>


More information about the Fontconfig mailing list