Difference between revisions of "Font configuration/Examples"

From ArchWiki
Jump to: navigation, search
m (Basic config with no hinting for italic or bold and some other tuning: - very nice brebs, clean up style a little bit)
(Liberation fonts: render-style settings have nothing to do with choice of fonts.)
 
(35 intermediate revisions by 10 users not shown)
Line 1: Line 1:
 
[[Category:Fonts]]
 
[[Category:Fonts]]
Configurations can vary to a degree.  Please feel free to post your fontconfig configurations and the rationale behind them.
+
[[ja:フォント設定/サンプル]]
 +
[[ru:Font configuration/Examples]]
 +
See [[Font configuration]] for the main article.  
  
== brebs' configuration ==
+
Configurations can vary to a degree.  Please post Fontconfig configurations with an explanation for why they were done.
  
This is a quest to get all fonts looking beautiful at all sizes, weights, etc., by tweaking the fontconfig rules. The latest version is [http://forums.gentoo.org/viewtopic-p-6183606.html#6183606 maintained here] -- brebs
+
== Hinted fonts ==
  
== Basic config with no hinting for ''italic'' or '''bold''' and some other tuning==
+
{{hc|$XDG_CONFIG_HOME/fontconfig/fonts.conf|<nowiki>
 +
<?xml version='1.0'?>
 +
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
 +
<fontconfig>
 +
<match target="font">
 +
<edit mode="assign" name="antialias">
 +
<bool>true</bool>
 +
</edit>
 +
<edit mode="assign" name="embeddedbitmap">
 +
<bool>false</bool>
 +
</edit>
 +
<edit mode="assign" name="hinting">
 +
<bool>true</bool>
 +
</edit>
 +
<edit mode="assign" name="hintstyle">
 +
<const>hintslight</const>
 +
</edit>
 +
<edit mode="assign" name="lcdfilter">
 +
<const>lcddefault</const>
 +
</edit>
 +
<edit mode="assign" name="rgba">
 +
<const>rgb</const>
 +
</edit>
 +
</match>
 +
</fontconfig>
 +
</nowiki>}}
 +
 
 +
== No hinting for ''italic'' or '''bold''' ==
  
 
<pre>
 
<pre>
Line 42: Line 71:
 
</pre>
 
</pre>
  
==Sharp fonts==
+
== 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">
 
  <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
Line 50: Line 78:
 
     <edit name="antialias" mode="assign"><bool>true</bool></edit>
 
     <edit name="antialias" mode="assign"><bool>true</bool></edit>
 
     <edit name="hinting" 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="hintstyle" mode="assign"><const>hintfull</const></edit>  &lt;!-- try hintmedium if it looks bad -->
 
     <edit name="lcdfilter" mode="assign"><const>lcddefault</const></edit>
 
     <edit name="lcdfilter" mode="assign"><const>lcddefault</const></edit>
     <edit name="rgba" mode="assign"><const>rgb</const></edit>
+
     <edit name="rgba" mode="assign"><const>rgb</const></edit>            &lt;!-- set to match your display -->
 
   </match>
 
   </match>
 
  </fontconfig>
 
  </fontconfig>
 +
 +
== Enable anti-aliasing only for bigger fonts ==
 +
 +
Some users prefer the sharper rendering that anti-aliasing does not offer:
 +
 +
{{bc|<nowiki>
 +
<?xml version="1.0"?>
 +
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
 +
<fontconfig>
 +
  <match target="font">
 +
    <edit name="antialias" mode="assign">
 +
      <bool>false</bool>
 +
    </edit>
 +
  </match>
 +
 +
  <match target="font" >
 +
    <test name="size" qual="any" compare="more">
 +
      <double>12</double>
 +
    </test>
 +
    <edit name="antialias" mode="assign">
 +
      <bool>true</bool>
 +
    </edit>
 +
  </match>
 +
 +
  <match target="font" >
 +
    <test name="pixelsize" qual="any" compare="more">
 +
      <double>16</double>
 +
    </test>
 +
    <edit name="antialias" mode="assign">
 +
      <bool>true</bool>
 +
    </edit>
 +
  </match>
 +
</fontconfig>
 +
</nowiki>}}
 +
 +
== Default fonts ==
 +
 +
{{Remove|We can't have such section for every font in the repositories that users might prefer. Everything necessary is already in [[Font_configuration#Replace_or_set_default_fonts]]. See also [[Talk:Croscore_Fonts#move_to_fonts_page]].|Talk:Font_configuration/Examples#Auto-generation_of_.22use_xxx_font.22_config_via_a_script.3F}}
 +
 +
=== Liberation fonts ===
 +
 +
For font consistency, all applications should be set to use the serif, sans-serif, and monospace aliases, which are mapped to particular fonts by fontconfig. The Liberation fonts were chosen to follow metric-compatibility of the MS Core fonts.
 +
 +
{{bc|1=
 +
<?xml version="1.0"?>
 +
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
 +
<fontconfig>
 +
    <match target="pattern">
 +
        <test qual="any" name="family"><string>serif</string></test>
 +
        <edit name="family" mode="assign" binding="same"><string>Liberation Serif</string></edit>
 +
    </match>
 +
    <match target="pattern">
 +
        <test qual="any" name="family"><string>sans-serif</string></test>
 +
        <edit name="family" mode="assign" binding="same"><string>Liberation Sans</string></edit>
 +
    </match>
 +
    <match target="pattern">
 +
        <test qual="any" name="family"><string>monospace</string></test>
 +
        <edit name="family" mode="assign" binding="same"><string>Liberation Mono</string></edit>
 +
    </match>
 +
</fontconfig>
 +
}}
 +
 +
=== Chrome OS fonts ===
 +
 +
Web browser and another common applications use {{ic|Serif}}, {{ic|Sans-Serif}} and {{ic|Monospace}} as default fonts ([[Fonts#Font alias]]). The procedure to change default fonts is similar to replace them. For example, to use Chrome OS fonts {{AUR|ttf-chromeos-fonts}}:
 +
 +
{{bc|<nowiki>
 +
<?xml version="1.0"?>
 +
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
 +
<fontconfig>
 +
  <!-- Set preferred serif, sans serif, and monospace fonts. -->
 +
  <alias>
 +
    <family>serif</family>
 +
    <prefer><family>Tinos</family></prefer>
 +
  </alias>
 +
  <alias>
 +
    <family>sans-serif</family>
 +
    <prefer><family>Arimo</family></prefer>
 +
  </alias>
 +
  <alias>
 +
    <family>sans</family>
 +
    <prefer><family>Arimo</family></prefer>
 +
  </alias>
 +
  <alias>
 +
    <family>monospace</family>
 +
    <prefer><family>Cousine</family></prefer>
 +
  </alias>
 +
</fontconfig>
 +
</nowiki>}}
 +
 +
=== Google Noto Fonts ===
 +
 +
The following configuration might be necessary to make use of [https://www.google.com/get/noto/ Google's Noto Fonts] available in the [[official repositories]].
 +
 +
{{bc|<nowiki>
 +
<?xml version="1.0"?>
 +
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
 +
<fontconfig>
 +
  <alias> <family>serif</family>      <prefer> <family>Noto Serif</family> </prefer> </alias>
 +
  <alias> <family>sans-serif</family> <prefer> <family>Noto Sans</family>  </prefer> </alias>
 +
  <alias> <family>sans</family>      <prefer> <family>Noto Sans</family>  </prefer> </alias>
 +
  <alias> <family>monospace</family>  <prefer> <family>Noto Mono</family>  </prefer> </alias>
 +
 
 +
  <!-- WARNING: LOTS OF metric-incompatible bindings here! -->
 +
  <match> <test name="family"> <string>Arial</string> </test>          <edit name="family" mode="assign" binding="strong"> <string>Noto Sans</string>  </edit> </match>
 +
  <match> <test name="family"> <string>Helvetica</string> </test>      <edit name="family" mode="assign" binding="strong"> <string>Noto Sans</string>  </edit> </match>
 +
  <match> <test name="family"> <string>Verdana</string> </test>        <edit name="family" mode="assign" binding="strong"> <string>Noto Sans</string>  </edit> </match>
 +
  <match> <test name="family"> <string>Tahoma</string> </test>          <edit name="family" mode="assign" binding="strong"> <string>Noto Sans</string>  </edit> </match>
 +
  <match> <test name="family"> <string>Times New Roman</string> </test> <edit name="family" mode="assign" binding="strong"> <string>Noto Serif</string> </edit> </match>
 +
  <match> <test name="family"> <string>Times</string> </test>          <edit name="family" mode="assign" binding="strong"> <string>Noto Serif</string> </edit> </match>
 +
  <!--match> <test name="family"> <string>Georgia</string> </test>        <edit name="family" mode="assign" binding="strong"> <string>Noto Serif</string> </edit> </match-->
 +
  <match> <test name="family"> <string>Consolas</string> </test>        <edit name="family" mode="assign" binding="strong"> <string>Noto Mono</string>  </edit> </match>
 +
  <match> <test name="family"> <string>Courier New</string> </test>    <edit name="family" mode="assign" binding="strong"> <string>Noto Mono</string>  </edit> </match>
 +
</fontconfig>
 +
</nowiki>}}
 +
 +
== Patched packages ==
 +
 +
{{Warning|AUR packages are maintained separately from applications in the [[official repositories]]. The whole graphical system can become inoperable, if the user-installed core graphical libraries become incompatible.}}
 +
 +
{{Note|
 +
* Configuration is usually necessary.
 +
* The new font rendering will not be available until applications restart.
 +
* Applications which [[Wikipedia:Static library|statically link]] to a library will not be affected by the system library, or patches applied to it.
 +
}}
 +
 +
* {{App|freetype2-ubuntu|Font configuration shipped with Ubuntu. [http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/wily/fontconfig/wily/files/head:/debian/patches/] [http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/wily/freetype/wily/files/head:/debian/patches-freetype/]|https://launchpad.net/ubuntu/+source/freetype|{{AUR|freetype2-ubuntu}} {{AUR|fontconfig-ubuntu}}}}
 +
* {{App|[[Infinality]]|Font configuration files, patches, and scripts.|https://github.com/bohoomil/fontconfig-ultimate|{{AUR|freetype2-infinality}} {{AUR|fontconfig-infinality}}}}
 +
 +
To restore the original packages, reinstall {{Pkg|freetype2}}, {{pkg|cairo}}, and {{pkg|fontconfig}} as dependencies (use the {{ic|--asdeps}} flag with pacman when reinstalling). Include {{pkg|lib32-cairo}}, {{pkg|lib32-fontconfig}}, and {{pkg|lib32-freetype2}} if you also installed 32-bit versions.
 +
 +
== See also ==
 +
 +
* [http://forums.gentoo.org/viewtopic-p-7273876.html#7273876 Gentoo forums]

Latest revision as of 12:49, 28 April 2016

See Font configuration for the main article.

Configurations can vary to a degree. Please post Fontconfig configurations with an explanation for why they were done.

Hinted fonts

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

No hinting for italic or bold

<?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

<!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>   <!-- try hintmedium if it looks bad -->
    <edit name="lcdfilter" mode="assign"><const>lcddefault</const></edit>
    <edit name="rgba" mode="assign"><const>rgb</const></edit>             <!-- set to match your display -->
  </match>
</fontconfig>

Enable anti-aliasing only for bigger fonts

Some users prefer the sharper rendering that anti-aliasing does not offer:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="font">
    <edit name="antialias" mode="assign">
      <bool>false</bool>
    </edit>
  </match>

  <match target="font" >
    <test name="size" qual="any" compare="more">
      <double>12</double>
    </test>
    <edit name="antialias" mode="assign">
      <bool>true</bool>
    </edit>
  </match>

  <match target="font" >
    <test name="pixelsize" qual="any" compare="more">
      <double>16</double>
    </test>
    <edit name="antialias" mode="assign">
      <bool>true</bool>
    </edit>
  </match>
</fontconfig>

Default fonts

Tango-edit-cut.pngThis section is being considered for removal.Tango-edit-cut.png

Reason: We can't have such section for every font in the repositories that users might prefer. Everything necessary is already in Font_configuration#Replace_or_set_default_fonts. See also Talk:Croscore_Fonts#move_to_fonts_page. (Discuss in Talk:Font_configuration/Examples#Auto-generation_of_.22use_xxx_font.22_config_via_a_script.3F)

Liberation fonts

For font consistency, all applications should be set to use the serif, sans-serif, and monospace aliases, which are mapped to particular fonts by fontconfig. The Liberation fonts were chosen to follow metric-compatibility of the MS Core fonts.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <match target="pattern">
        <test qual="any" name="family"><string>serif</string></test>
        <edit name="family" mode="assign" binding="same"><string>Liberation Serif</string></edit>
    </match>
    <match target="pattern">
        <test qual="any" name="family"><string>sans-serif</string></test>
        <edit name="family" mode="assign" binding="same"><string>Liberation Sans</string></edit>
    </match>
    <match target="pattern">
        <test qual="any" name="family"><string>monospace</string></test>
        <edit name="family" mode="assign" binding="same"><string>Liberation Mono</string></edit>
    </match>
</fontconfig>

Chrome OS fonts

Web browser and another common applications use Serif, Sans-Serif and Monospace as default fonts (Fonts#Font alias). The procedure to change default fonts is similar to replace them. For example, to use Chrome OS fonts ttf-chromeos-fontsAUR:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <!-- Set preferred serif, sans serif, and monospace fonts. -->
  <alias>
    <family>serif</family>
    <prefer><family>Tinos</family></prefer>
  </alias>
  <alias>
    <family>sans-serif</family>
    <prefer><family>Arimo</family></prefer>
  </alias>
  <alias>
    <family>sans</family>
    <prefer><family>Arimo</family></prefer>
  </alias>
  <alias>
    <family>monospace</family>
    <prefer><family>Cousine</family></prefer>
  </alias>
</fontconfig>

Google Noto Fonts

The following configuration might be necessary to make use of Google's Noto Fonts available in the official repositories.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <alias> <family>serif</family>      <prefer> <family>Noto Serif</family> </prefer> </alias>
  <alias> <family>sans-serif</family> <prefer> <family>Noto Sans</family>  </prefer> </alias>
  <alias> <family>sans</family>       <prefer> <family>Noto Sans</family>  </prefer> </alias>
  <alias> <family>monospace</family>  <prefer> <family>Noto Mono</family>  </prefer> </alias>
  
  <!-- WARNING: LOTS OF metric-incompatible bindings here! -->
  <match> <test name="family"> <string>Arial</string> </test>           <edit name="family" mode="assign" binding="strong"> <string>Noto Sans</string>  </edit> </match>
  <match> <test name="family"> <string>Helvetica</string> </test>       <edit name="family" mode="assign" binding="strong"> <string>Noto Sans</string>  </edit> </match>
  <match> <test name="family"> <string>Verdana</string> </test>         <edit name="family" mode="assign" binding="strong"> <string>Noto Sans</string>  </edit> </match>
  <match> <test name="family"> <string>Tahoma</string> </test>          <edit name="family" mode="assign" binding="strong"> <string>Noto Sans</string>  </edit> </match>
  <match> <test name="family"> <string>Times New Roman</string> </test> <edit name="family" mode="assign" binding="strong"> <string>Noto Serif</string> </edit> </match>
  <match> <test name="family"> <string>Times</string> </test>           <edit name="family" mode="assign" binding="strong"> <string>Noto Serif</string> </edit> </match>
  <!--match> <test name="family"> <string>Georgia</string> </test>         <edit name="family" mode="assign" binding="strong"> <string>Noto Serif</string> </edit> </match-->
  <match> <test name="family"> <string>Consolas</string> </test>        <edit name="family" mode="assign" binding="strong"> <string>Noto Mono</string>  </edit> </match>
  <match> <test name="family"> <string>Courier New</string> </test>     <edit name="family" mode="assign" binding="strong"> <string>Noto Mono</string>  </edit> </match>
</fontconfig>

Patched packages

Warning: AUR packages are maintained separately from applications in the official repositories. The whole graphical system can become inoperable, if the user-installed core graphical libraries become incompatible.
Note:
  • Configuration is usually necessary.
  • The new font rendering will not be available until applications restart.
  • Applications which statically link to a library will not be affected by the system library, or patches applied to it.
  • freetype2-ubuntu — Font configuration shipped with Ubuntu. [1] [2]
https://launchpad.net/ubuntu/+source/freetype || freetype2-ubuntuAUR fontconfig-ubuntuAUR
  • Infinality — Font configuration files, patches, and scripts.
https://github.com/bohoomil/fontconfig-ultimate || freetype2-infinalityAUR fontconfig-infinalityAUR

To restore the original packages, reinstall freetype2, cairo, and fontconfig as dependencies (use the --asdeps flag with pacman when reinstalling). Include lib32-cairo, lib32-fontconfig, and lib32-freetype2 if you also installed 32-bit versions.

See also