Difference between revisions of "Font configuration/Examples"

From ArchWiki
Jump to: navigation, search
(Replaced my out-of-date config with a link to the latest)
m (Basic config with no hinting for italic or bold and some other tuning: - very nice brebs, clean up style a little bit)
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
[[Category:Fonts]]
 
Configurations can vary to a degree.  Please feel free to post your fontconfig configurations and the rationale behind them.
 
Configurations can vary to a degree.  Please feel free to post your fontconfig configurations and the rationale behind them.
 
== Web developer's ==
 
 
A web developer's configuration (modified) taken from the forums. Back up current settings before testing the ones below:
 
 
<pre>
 
<?xml version="1.0"?>
 
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
 
 
<!-- The cathectic LCD tweaks, from linuxquestions.org,
 
http://www.linuxquestions.org/questions/showthread.php?postid=1361098#post1361098 -->
 
 
<fontconfig>
 
 
    <match target="font" >
 
        <!-- Disable sub-pixel rendering.
 
            X detects it anyway, and if you set this as well, it just looks really horrible -->
 
        <edit mode="assign" name="rgba" >
 
            <const>none</const>
 
        </edit>
 
       
 
        <!-- Autohinter is not turned on automatically.
 
            Only disable this if you have recompiled Freetype with the bytecode interpreter,
 
            which is run automatically. -->
 
        <edit mode="assign" name="autohint">
 
            <bool>true</bool>
 
        </edit>
 
        <!-- Change hintstyle to full -->
 
        <edit mode="assign" name="hintstyle">
 
            <const>hintfull</const>
 
        </edit>
 
    </match>
 
 
    <match target="font">
 
        <!-- Disable auto hinting for bold fonts -->
 
        <test name="weight" compare="more">
 
            <const>medium</const>
 
        </test>
 
        <edit name="autohint" mode="assign">
 
            <bool>false</bool>
 
        </edit>
 
    </match>
 
 
    <!-- Helvetica is a non true type font, and will look bad.
 
        This replaces it with whatever is the default sans-serif font -->
 
    <match target="pattern" name="family" >
 
        <test name="family" qual="any" >
 
            <string>Helvetica</string>
 
        </test>
 
        <edit mode="assign" name="family" >
 
            <string>sans-serif</string>
 
        </edit>
 
    </match>
 
 
</fontconfig>
 
</pre>
 
  
 
== brebs' configuration ==
 
== brebs' configuration ==
Line 67: Line 12:
 
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
 
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
 
<fontconfig>
 
<fontconfig>
<match target="font" >
+
  <match target="font" >
<edit mode="assign" name="autohint"> <bool>true</bool></edit>
+
    <edit mode="assign" name="autohint"> <bool>true</bool></edit>
<edit mode="assign" name="hinting"> <bool>false</bool></edit>
+
    <edit mode="assign" name="hinting">   <bool>false</bool></edit>
<edit mode="assign" name="lcdfilter"> <const>lcddefault</const></edit>
+
    <edit mode="assign" name="lcdfilter"> <const>lcddefault</const></edit>
<edit mode="assign" name="hintstyle"> <const>hintslight</const></edit>
+
    <edit mode="assign" name="hintstyle"> <const>hintslight</const></edit>
<edit mode="assign" name="antialias"> <bool>true</bool></edit>
+
    <edit mode="assign" name="antialias"> <bool>true</bool></edit>
<edit mode="assign" name="rgba"> <const>rgb</const></edit>
+
    <edit mode="assign" name="rgba">     <const>rgb</const></edit>
</match>
+
  </match>
  
<match target="font">
+
  <match target="font">
<test name="pixelsize" qual="any" compare="more"><double>15</double></test>
+
    <test name="pixelsize" qual="any" compare="more"><double>15</double></test>
<edit mode="assign" name="lcdfilter"><const>lcdlight</const></edit>
+
    <edit mode="assign" name="lcdfilter"><const>lcdlight</const></edit>
<edit mode="assign" name="hintstyle"><const>hintnone</const></edit></match>
+
    <edit mode="assign" name="hintstyle"><const>hintnone</const></edit>
 +
  </match>
  
<match target="font">
+
  <match target="font">
<test name="weight" compare="more"><const>medium</const></test>
+
    <test name="weight" compare="more"><const>medium</const></test>
<edit mode="assign" name="hintstyle"><const>hintnone</const></edit>
+
    <edit mode="assign" name="hintstyle"><const>hintnone</const></edit>
<edit mode="assign" name="lcdfilter"><const>lcdlight</const></edit></match>
+
    <edit mode="assign" name="lcdfilter"><const>lcdlight</const></edit>
 +
  </match>
  
<match target="font">
+
  <match target="font">
<test name="slant" compare="not_eq"><double>0</double></test>
+
    <test name="slant" compare="not_eq"><double>0</double></test>
<edit mode="assign" name="hintstyle"><const>hintnone</const></edit>
+
    <edit mode="assign" name="hintstyle"><const>hintnone</const></edit>
<edit mode="assign" name="lcdfilter"><const>lcdlight</const></edit></match>
+
    <edit mode="assign" name="lcdfilter"><const>lcdlight</const></edit>
 +
  </match>
  
 
</fontconfig>
 
</fontconfig>
 
</pre>
 
</pre>
 +
 +
==Sharp fonts==
 +
It took me a while to find font settings that are sharp and not overly blurred. This font config does exactly that and seems to work fine everywhere. I searched for this because "Chromium" wasn't looking good with no aliasing at all. The below config fixes that as well.
 +
 +
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
 +
<fontconfig>
 +
  <match target="font">
 +
    <edit name="antialias" mode="assign"><bool>true</bool></edit>
 +
    <edit name="hinting" mode="assign"><bool>true</bool></edit>
 +
    <edit name="hintstyle" mode="assign"><const>hintfull</const></edit>
 +
    <edit name="lcdfilter" mode="assign"><const>lcddefault</const></edit>
 +
    <edit name="rgba" mode="assign"><const>rgb</const></edit>
 +
  </match>
 +
</fontconfig>

Revision as of 14:39, 28 August 2012

Configurations can vary to a degree. Please feel free to post your fontconfig configurations and the rationale behind them.

brebs' configuration

This is a quest to get all fonts looking beautiful at all sizes, weights, etc., by tweaking the fontconfig rules. The latest version is maintained here -- brebs

Basic config with no hinting for italic or bold and some other tuning

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
  <match target="font" >
    <edit mode="assign" name="autohint">  <bool>true</bool></edit>
    <edit mode="assign" name="hinting">	  <bool>false</bool></edit>
    <edit mode="assign" name="lcdfilter"> <const>lcddefault</const></edit>
    <edit mode="assign" name="hintstyle"> <const>hintslight</const></edit>
    <edit mode="assign" name="antialias"> <bool>true</bool></edit>
    <edit mode="assign" name="rgba">      <const>rgb</const></edit>
  </match>

  <match target="font">
    <test name="pixelsize" qual="any" compare="more"><double>15</double></test>
    <edit mode="assign" name="lcdfilter"><const>lcdlight</const></edit>
    <edit mode="assign" name="hintstyle"><const>hintnone</const></edit>
  </match>

  <match target="font">
    <test name="weight" compare="more"><const>medium</const></test>
    <edit mode="assign" name="hintstyle"><const>hintnone</const></edit>
    <edit mode="assign" name="lcdfilter"><const>lcdlight</const></edit>
  </match>

  <match target="font">
    <test name="slant"  compare="not_eq"><double>0</double></test>
    <edit mode="assign" name="hintstyle"><const>hintnone</const></edit>
    <edit mode="assign" name="lcdfilter"><const>lcdlight</const></edit>
  </match>

</fontconfig>

Sharp fonts

It took me a while to find font settings that are sharp and not overly blurred. This font config does exactly that and seems to work fine everywhere. I searched for this because "Chromium" wasn't looking good with no aliasing at all. The below config fixes that as well.

<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="font">
    <edit name="antialias" mode="assign"><bool>true</bool></edit>
    <edit name="hinting" mode="assign"><bool>true</bool></edit>
    <edit name="hintstyle" mode="assign"><const>hintfull</const></edit>
    <edit name="lcdfilter" mode="assign"><const>lcddefault</const></edit>
    <edit name="rgba" mode="assign"><const>rgb</const></edit>
  </match>
</fontconfig>