Fontconfig is a library designed to provide a list of available [[fonts]] to applications, and also for configuration for how fonts get rendered. See package {{Pkg|fontconfig}} and [[Wikipedia:Fontconfig]]. The Free type library ({{Pkg|freetype2}} package) renders the fonts, based on this configuration.

Fontconfig is a library designed to provide a list of available [[fonts]] to applications, and also for configuration for how fonts get rendered. See package {{Pkg|fontconfig}} and [[Wikipedia:Fontconfig]]. The Free type library ({{Pkg|freetype2}} package) renders the fonts, based on this configuration.

Line 19:

Line 19:

Though Fontconfig is the standard in today's Linux, some applications still rely on the original method of font selection and display, the [[X Logical Font Description]].

Though Fontconfig is the standard in today's Linux, some applications still rely on the original method of font selection and display, the [[X Logical Font Description]].

−

The font rendering packages on Arch Linux includes support for ''freetype2'' with the bytecode interpreter (BCI) enabled. Patched packages exist for better font rendering, especially with an LCD monitor. See [[#Patched packages]] below. The [[#Infinality]] package allows both auto-hinting and subpixel rendering, allows the LCD filter to be tweaked without recompiling, and allows the auto-hinter to work well with bold fonts.

+

The font rendering packages on Arch Linux includes support for ''freetype2'' with the bytecode interpreter (BCI) enabled. Patched packages exist for better font rendering, especially with an LCD monitor. See [[#Patched packages]] below. The [[#Infinality|Infinality]] package allows both auto-hinting and subpixel rendering, allows the LCD filter to be tweaked without recompiling, and allows the auto-hinter to work well with bold fonts.

−

==Font paths==

+

== Font paths ==

For fonts to be known to applications, they must be cataloged for easy and quick access.

For fonts to be known to applications, they must be cataloged for easy and quick access.

Line 30:

Line 30:

$ fc-list : file

$ fc-list : file

−

See {{ic|man fc-list}} for more out put format.

+

See {{ic|man fc-list}} for more output formats.

Check for Xorg's known font paths by reviewing its log:

Check for Xorg's known font paths by reviewing its log:

Line 48:

Line 48:

To see a list of known Xorg fonts use {{ic|xlsfonts}}, from the {{Pkg|xorg-xlsfonts}} package.

To see a list of known Xorg fonts use {{ic|xlsfonts}}, from the {{Pkg|xorg-xlsfonts}} package.

−

==Fontconfig configuration==

+

== Fontconfig configuration ==

−

Fontconfig is documented in the [http://fontconfig.org/fontconfig-user.html fonts.conf] man page.

+

Fontconfig is documented in the [http://fontconfig.org/fontconfig-user.html fonts-conf] man page.

Configuration can be done per-user through {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, and globally with {{ic|/etc/fonts/local.conf}}. The settings in the per-user configuration have precedence over the global configuration. Both these files use the same syntax.

Configuration can be done per-user through {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, and globally with {{ic|/etc/fonts/local.conf}}. The settings in the per-user configuration have precedence over the global configuration. Both these files use the same syntax.

−

{{Note|Configuration files and directories: {{ic|~/.fonts.conf}}, {{ic|~/.fonts.conf.d}} and {{ic|~/.fontconfig/*.cache-*}} are deprecated since fontconfig 2.10.1 ([http://cgit.freedesktop.org/fontconfig/commit/?id&#61;8c255fb185d5651b57380b0a9443001e8051b29d upstream commit]) and will not be read by default in the future versions of package. Use instead {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, {{ic|$XDG_CONFIG_HOME/fontconfig/conf.d}} and {{ic|$XDG_CACHE_HOME/fontconfig/*.cache-*}} respectively. If you use the second directory, the file '''must''' follow the naming convention {{ic|NN-name.conf}} (where NN it's a two digit number like 00, 10, or 99).}}

+

{{Note|Configuration files and directories: {{ic|~/.fonts.conf/}}, {{ic|~/.fonts.conf.d/}} and {{ic|~/.fontconfig/*.cache-*}} are deprecated since {{Pkg|fontconfig}} 2.10.1 ([http://cgit.freedesktop.org/fontconfig/commit/?id&#61;8c255fb185d5651b57380b0a9443001e8051b29d upstream commit]) and will not be read by default in the future versions of the package. New paths are {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}, {{ic|$XDG_CONFIG_HOME/fontconfig/conf.d/NN-name.conf}} and {{ic|$XDG_CACHE_HOME/fontconfig/*.cache-*}} respectively. If using the second location, make sure the naming is valid (where {{ic|NN}} is a two digit number like {{ic|00}}, {{ic|10}}, or {{ic|99}}).}}

−

Fontconfig gathers all its configurations in a central file ({{ic|/etc/fonts/fonts.conf}}). This file is replaced during fontconfig updates and shouldn't be edited. Fontconfig-aware applications source this file to know available fonts and how they get rendered. This file is a conglomeration of rules from the global configuration ({{ic|/etc/fonts/local.conf}}), the configured presets in {{ic|/etc/fonts/conf.d/}}, and the user configuration file ({{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}).

+

Fontconfig gathers all its configurations in a central file ({{ic|/etc/fonts/fonts.conf}}). This file is replaced during fontconfig updates and shouldn't be edited. Fontconfig-aware applications source this file to know available fonts and how they get rendered. This file is a conglomeration of rules from the global configuration ({{ic|/etc/fonts/local.conf}}), the configured presets in {{ic|/etc/fonts/conf.d/}}, and the user configuration file ({{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}). {{ic|fc-cache}} can be used to rebuild fontconfig's configuration, although changes will only be visible in newly launched applications.

{{Note|For some desktop environments (such as [[GNOME]] and [[KDE]]) using the ''Font Control Panel'' will automatically create or overwrite the user font configuration file. For these desktop environments, it is best to match your already defined font configurations to get the expected behavior.}}

{{Note|For some desktop environments (such as [[GNOME]] and [[KDE]]) using the ''Font Control Panel'' will automatically create or overwrite the user font configuration file. For these desktop environments, it is best to match your already defined font configurations to get the expected behavior.}}

Line 73:

Line 73:

The configuration examples in this article omit these tags.

The configuration examples in this article omit these tags.

−

===Presets===

+

=== Presets ===

There are presets installed in the directory {{ic|/etc/fonts/conf.avail}}. They can be enabled by creating [[Wikipedia:Symbolic link|symbolic link]]s to them, both per-user and globally, as described in {{ic|/etc/fonts/conf.d/README}}. These presets will override matching settings in their respective configuration files.

There are presets installed in the directory {{ic|/etc/fonts/conf.avail}}. They can be enabled by creating [[Wikipedia:Symbolic link|symbolic link]]s to them, both per-user and globally, as described in {{ic|/etc/fonts/conf.d/README}}. These presets will override matching settings in their respective configuration files.

[[Wikipedia:Font rasterization|Font rasterization]] converts vector font data to bitmap data so that it can be displayed. The result can appear jagged due to [[Wikipedia:Aliasing|aliasing]]. [[Wikipedia:Anti-aliasing|anti-aliasing]] is enabled by default and increases the apparent resolution of font edges.

[[Wikipedia:Font rasterization|Font rasterization]] converts vector font data to bitmap data so that it can be displayed. The result can appear jagged due to [[Wikipedia:Aliasing|aliasing]]. [[Wikipedia:Anti-aliasing|anti-aliasing]] is enabled by default and increases the apparent resolution of font edges.

[[Wikipedia:Font hinting|Font hinting]] (also known as instructing) is the use of mathematical instructions to adjust the display of an outline font so that it lines up with a rasterized grid, such as the pixel grid in a display. Fonts will not line up correctly without hinting until displays have 300 [[Wikipedia:Dots per inch|DPI]] or greater. Two types of hinting are available.

+

[[Wikipedia:Font hinting|Font hinting]] (also known as instructing) is the use of mathematical instructions to adjust the display of an outline font so that it lines up with a rasterized grid, (i.e. the pixel grid of the display). It's intended effect is to make fonts appear more crisp so that they are more readable. Fonts will line up correctly without hinting when displays have around 300 [[Wikipedia:Dots per inch|DPI]]. Two types of hinting are available.

−

====Byte-Code Interpreter (BCI)====

+

==== Byte-Code Interpreter (BCI) ====

−

Using normal hinting, TrueType hinting instructions in the font are interpreted by freetype's Byte-Code Interpreter. This works best for fonts with good hinting instructions.

+

−

To enable normal hinting:

+

Using BCI hinting, instructions in TrueType fonts fonts are rendered according to FreeTypes's interpreter. BCI hinting works well with fonts with good hinting instructions. To enable hinting:

{{bc|<nowiki>

{{bc|<nowiki>

Line 118:

Line 117:

</nowiki>}}

</nowiki>}}

−

====Autohinter====

+

==== Autohinter ====

−

Auto-discovery for hinting. This looks worse than normal hinting for fonts with good instructions, but better for those with poor or no instructions. The autohinter and subpixel rendering are not designed to work together and should not be used in combination.

+

−

To enable auto-hinting:

+

The Autohinter attempts to do automatic hinting and disregards any existing hinting information. Originally it was the default because TrueType2 fonts were patent-protected but now that these patents have expired there's very little reason to use it. It does work better with fonts that have broken or no hinting information but it will be strongly sub-optimal for fonts with good hinting information. Generally common fonts are of the later kind so autohinter will not be useful. To enable auto-hinting:

{{bc|<nowiki>

{{bc|<nowiki>

Line 131:

Line 129:

</nowiki>}}

</nowiki>}}

−

====Hint style====

+

==== Hintstyle ====

−

Hint style is the amount of influence the hinting mode has. Hinting can be set to: {{ic|hintfull}}, {{ic|hintmedium}}, {{ic|hintslight}} and {{ic|hintnone}}. With BCI hinting, hintfull should work best for most fonts. With the autohinter, hintslight is recommended.

+

Hintstyle is the amount of font reshaping done to line up to the grid. Hinting values are: {{ic|hintnone}}, {{ic|hintslight}}, {{ic|hintmedium}}, and {{ic|hintfull}}. {{ic|hintslight}} will make the font more fuzzy to line up to the grid but will be better in retaining font shape, while {{ic|hintfull}} will be a crisp font that aligns well to the pixel grid but will lose a greater amount of font shape. Preferences vary.

Subpixel rendering effectively triples the horizontal (or vertical) resolution for fonts by making use of subpixels. The autohinter and subpixel rendering are not designed to work together and should not be used in combination without the [[#Infinality]] patch set.

+

Most monitors manufactured today use the Red, Green, Blue (RGB) specification. Fontconfig will need to know your monitor type to be able to display your fonts correctly. Monitors are either: '''RGB''' (most common), '''BGR''', '''V-RGB''' (vertical), or '''V-BGR'''. A monitor test can be found [http://www.lagom.nl/lcd-test/subpixel.php here]).

−

+

−

Most monitors manufactured today use the Red, Green, Blue (RGB) specification. Fontconfig will need to know your monitor type to be able to display your fonts correctly.

{{Note|Subpixel rendering effectively triples the horizontal (or vertical) resolution for fonts by making use of subpixels. The autohinter and subpixel rendering are not designed to work together and should not be used in combination without the [[#Infinality: the generic way|Infinality]] patch set.}}

−

====LCD filter====

+

==== LCD filter ====

When using subpixel rendering, you should enable the LCD filter, which is designed to reduce colour fringing. This is described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html LCD filtering] in the FreeType 2 API reference. Different options are described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html#FT_LcdFilter FT_LcdFilter], and are illustrated by this [http://www.spasche.net/files/lcdfiltering/ LCD filter test] page.

When using subpixel rendering, you should enable the LCD filter, which is designed to reduce colour fringing. This is described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html LCD filtering] in the FreeType 2 API reference. Different options are described under [http://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html#FT_LcdFilter FT_LcdFilter], and are illustrated by this [http://www.spasche.net/files/lcdfiltering/ LCD filter test] page.

Line 179:

Line 173:

</nowiki>}}

</nowiki>}}

−

====Advanced LCD filter specification====

+

==== Advanced LCD filter specification ====

If the available, built-in LCD filters are not satisfactory, it is possible to tweak the font rendering very specifically by building a custom freetype2 package and modifying the hardcoded filters. The [[Arch Build System]] can be used to build and install packages from source.

If the available, built-in LCD filters are not satisfactory, it is possible to tweak the font rendering very specifically by building a custom freetype2 package and modifying the hardcoded filters. The [[Arch Build System]] can be used to build and install packages from source.

Line 202:

Line 196:

$ makepkg -e

$ makepkg -e

−

$ sudo pacman -Rd freetype2

+

# pacman -Rd freetype2

−

$ sudo pacman -U freetype2-VERSION-ARCH.pkg.tar.xz

+

# pacman -U freetype2-VERSION-ARCH.pkg.tar.xz

Reboot or restart X. The lcddefault filter should now render fonts differently.

Reboot or restart X. The lcddefault filter should now render fonts differently.

−

===Disable auto-hinter for bold fonts===

+

=== Disable auto-hinter for bold fonts ===

The auto-hinter uses sophisticated methods for font rendering, but often makes bold fonts too wide. Fortunately, a solution can be turning off the autohinter for bold fonts while leaving it on for the rest:

The auto-hinter uses sophisticated methods for font rendering, but often makes bold fonts too wide. Fortunately, a solution can be turning off the autohinter for bold fonts while leaving it on for the rest:

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

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

Line 255:

Line 247:

</nowiki>}}

</nowiki>}}

−

===Replace fonts===

+

=== Replace fonts ===

The most reliable way to do this is to add an XML fragment similar to the one below. ''Using the "binding" attribute will give you better results'', for example, in Firefox where you may not want to change properties of font being replaced. This will cause Ubuntu to be used in place of Georgia:

The most reliable way to do this is to add an XML fragment similar to the one below. ''Using the "binding" attribute will give you better results'', for example, in Firefox where you may not want to change properties of font being replaced. This will cause Ubuntu to be used in place of Georgia:

Line 275:

Line 267:

...

...

−

===Disable bitmap fonts===

+

=== Disable bitmap fonts ===

To disable bitmap fonts in fontconfig, use {{ic|70-no-bitmaps.conf}} (which is not placed by fontconfig by default):

To disable bitmap fonts in fontconfig, use {{ic|70-no-bitmaps.conf}} (which is not placed by fontconfig by default):

Line 315:

Line 307:

</match>

</match>

−

===Disable scaling of bitmap fonts===

+

=== Disable scaling of bitmap fonts ===

To disable scaling of bitmap fonts (which often makes them blurry), remove {{ic|/etc/fonts/conf.d/10-scale-bitmap-fonts.conf}}.

To disable scaling of bitmap fonts (which often makes them blurry), remove {{ic|/etc/fonts/conf.d/10-scale-bitmap-fonts.conf}}.

−

===Create bold and italic styles for incomplete fonts===

+

=== Create bold and italic styles for incomplete fonts ===

Freetype has the ability to automatically create ''italic'' and '''bold''' styles for fonts that do not have them, but only if explicitly required by the application. Given programs rarely send these requests, this section covers manually forcing generation of missing styles.

Freetype has the ability to automatically create ''italic'' and '''bold''' styles for fonts that do not have them, but only if explicitly required by the application. Given programs rarely send these requests, this section covers manually forcing generation of missing styles.

Line 363:

Line 355:

{{Tip| Use the value 'embolden' for existing bold fonts in order to make them even bolder.}}

{{Tip| Use the value 'embolden' for existing bold fonts in order to make them even bolder.}}

−

===Change rule overriding===

+

=== Change rule overriding ===

Fontconfig processes files in {{ic|/etc/fonts/conf.d}} in numerical order. This enables rules or files to override one another, but often confuses users about what file gets parsed last.

Fontconfig processes files in {{ic|/etc/fonts/conf.d}} in numerical order. This enables rules or files to override one another, but often confuses users about what file gets parsed last.

Line 373:

Line 365:

This change seems however to be unnecessary for the most of the cases, because a user is given enough control by default to set up own font preferences, hinting and antialiasing properties, alias new fonts to generic font families, etc.

This change seems however to be unnecessary for the most of the cases, because a user is given enough control by default to set up own font preferences, hinting and antialiasing properties, alias new fonts to generic font families, etc.

−

===Example fontconfig configurations===

+

=== Example fontconfig configurations ===

Example fontconfig configurations can be found on this [[Font_Configuration/fontconfig_Examples|page]].

Example fontconfig configurations can be found on this [[Font_Configuration/fontconfig_Examples|page]].

Line 383:

Line 375:

<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>

<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>

<fontconfig>

<fontconfig>

−

<match target="font">

+

<match target="font">

−

+

−

<edit mode="assign" name="rgba">

+

−

<const>rgb</const>

+

−

</edit>

+

−

<edit mode="assign" name="hinting">

+

<edit mode="assign" name="rgba">

−

<bool>true</bool>

+

<const>rgb</const>

−

</edit>

+

</edit>

−

<edit mode="assign" name="hintstyle">

+

<edit mode="assign" name="hinting">

−

<const>hintslight</const>

+

<bool>true</bool>

−

</edit>

+

</edit>

−

<edit mode="assign" name="antialias">

+

<edit mode="assign" name="hintstyle">

−

<bool>true</bool>

+

<const>hintslight</const>

−

</edit>

+

</edit>

−

<edit mode="assign" name="lcdfilter">

+

<edit mode="assign" name="antialias">

−

<const>lcddefault</const>

+

<bool>true</bool>

−

</edit>

+

</edit>

−

+

−

</match>

+

<edit mode="assign" name="lcdfilter">

+

<const>lcddefault</const>

+

</edit>

+

+

</match>

</fontconfig>

</fontconfig>

</nowiki>}}

</nowiki>}}

−

==Patched packages==

+

== Patched packages ==

These patched packages are available in the [[Arch User Repository|AUR]]. A few considerations:

These patched packages are available in the [[Arch User Repository|AUR]]. A few considerations:

Line 417:

Line 409:

* Applications which [[Wikipedia:Static library|statically link]] to a library will not be affected by patches applied to the system library.

* Applications which [[Wikipedia:Static library|statically link]] to a library will not be affected by patches applied to the system library.

Infinality's settings are all configurable at runtime via environment variables in {{ic|/etc/profile.d/infinality-settings.sh}}, and include the following:

Infinality's settings are all configurable at runtime via environment variables in {{ic|/etc/profile.d/infinality-settings.sh}}, and include the following:

Line 439:

Line 431:

A number of presets are included and can be used by setting the USE_STYLE variable in {{ic|/etc/profile.d/infinality-settings.sh}}.

A number of presets are included and can be used by setting the USE_STYLE variable in {{ic|/etc/profile.d/infinality-settings.sh}}.

−

{{Note|1=The user bohoomil maintains a very good configuration in his [https://github.com/bohoomil/fontconf github repo] which is available as a [https://aur.archlinux.org/packages/fontconfig-infinality-ultimate/ package] in the AUR.}}

+

==== Installation and configuration ====

−

+

{{Tip|All AUR packages in this section can also be downloaded from bohoomil's custom repository. See the [[#Install from custom repository|section below]] for how to enable this repository.}}

−

{{Note|1=Install {{AUR|grip-git}} from AUR to have a realtime preview.}}

+

{{Note|If you have been using fontconfig-infinality-ultimate < 2.11.0-2, you need to re-install (not upgrade!) fontconfig-infinality-ultimate package:

−

+

pacman -Rdd fontconfig-infinality-ultimate

−

{{AUR|freetype2-infinality}} can be installed from the [[Arch User Repository|AUR]]. Additionally, if you are using {{pkg|lib32-freetype2}} from [multilib], replace it with {{AUR|lib32-freetype2-infinality}} from the AUR. The AUR also contains a Git version of freetype2 that builds the latest development snapshot of freetype2 with the Infinality patchset: {{AUR|freetype2-git-infinality}}, {{AUR|lib32-freetype2-git-infinality}}.

+

pacman -S fontconfig-infinality-ultimate

+

}}

+

{{AUR|freetype2-infinality}} can be installed from the [[Arch User Repository|AUR]]. If you are a multilib user, also install {{AUR|lib32-freetype2-infinality}} from the AUR. The AUR also contains the latest development snapshot of freetype2 with the Infinality patchset: {{AUR|freetype2-infinality-git}} and {{AUR|lib32-freetype2-infinality-git}}.

It is recommended to also install {{AUR|fontconfig-infinality}} to enable selection of predefined font substitution styles and antialiasing settings, apart from the rendering settings of the engine itself. After doing so, you can select the font style (win7, winxp, osx, linux, ...) with:

It is recommended to also install {{AUR|fontconfig-infinality}} to enable selection of predefined font substitution styles and antialiasing settings, apart from the rendering settings of the engine itself. After doing so, you can select the font style (win7, winxp, osx, linux, ...) with:

Line 450:

Line 444:

If you set e.g. win7 or osx you need the corresponding fonts installed.

If you set e.g. win7 or osx you need the corresponding fonts installed.

−

{{Note|Default infinality settings can cause some programs to display fonts at 72 DPI instead of 96. If you notice a problem open /etc/fonts/infinality/infinality.conf search for the section on DPI and change 72 to 96. This problem can specifically affect conky causing the fonts to appear smaller than they should. Thus not aligning properly with images. }}

+

{{Note|

−

+

* The user bohoomil maintains a very good configuration in his [https://github.com/bohoomil/fontconf github repo] which is available as {{AUR|fontconfig-infinality-ultimate-git}} in the AUR.

−

{{Note|''The README for {{AUR|fontconfig-infinality}} says that /etc/fonts/local.conf should either not exist, or have no infinality-related configurations in it. The local.conf is now obsolete and completely replaced by this configuration.''}}

+

* Install {{AUR|grip-git}} from the AUR to have a realtime font preview.

+

* Default infinality settings can cause some programs to display fonts at 72 DPI instead of 96. If you notice a problem open {{ic|/etc/fonts/infinality/infinality.conf}} search for the section on DPI and change 72 to 96. This problem can specifically affect conky causing the fonts to appear smaller than they should. Thus not aligning properly with images.

+

* ''The README for {{AUR|fontconfig-infinality}} says that /etc/fonts/local.conf should either not exist, or have no infinality-related configurations in it. The local.conf is now obsolete and completely replaced by this configuration.''

+

}}

for more information see this article: http://www.infinality.net/forum/viewtopic.php?f=2&t=77

for more information see this article: http://www.infinality.net/forum/viewtopic.php?f=2&t=77

−

*[http://www.infinality.net/blog/infinality-freetype-patches/ Home page].

+

==== Install from custom repository ====

−

+

−

===Infinality: the easy way===

+

−

+

−

bohoomil also maintains '''infinality-bundle''' repository, offering three basic libraries (freetype2-infinality-ultimate, fontconfig-infinality-ultimate & cairo-infinality-ultimate) as pre-patched, pre-configured and pre-built binaries for all architectures (i686, x86_64, multilib). Using infinality-bundle makes the whole installation & configuration process dramatically simplified: all one has to do is install the three packages with

+

−

+

−

{{bc|# pacman -S infinality-bundle}}

+

−

+

−

which will replace the corresponding, generic Arch libraries (i.e. freetype2-infinality-ultimate will be used instead of freetype2, fontconfig-infinality-ultimate instead of fontconfig and fontconfig-infinality-ultimate from the AUR, and cairo-infinality-ultimate instead of the regular cairo). The libraries are fully compatible with the Arch packages and are meant to be used as drop-in replacements for them. No post installation/upgrade steps are required for most use scenarios: everything should work out of the box.

+

−

+

−

To use the repository, add

+

−

+

−

{{bc|<nowiki>[infinality-bundle]

+

−

SigLevel = Never

+

−

Server = http://bohoomil.cu.cc/infinality-bundle/$arch</nowiki>}}

+

−

to your /etc/pacman.conf.

+

−

+

−

If you want to have access to multilib versions, add the following, too:

Note that the *-ubuntu AUR packages need to be kept up-to-date by the user, and will not be updated by pacman along with other packages. The whole graphical system can become inoperable if the user-installed core graphical libraries become incompatible with the official repository applications.

Note that the *-ubuntu AUR packages need to be kept up-to-date by the user, and will not be updated by pacman along with other packages. The whole graphical system can become inoperable if the user-installed core graphical libraries become incompatible with the official repository applications.

−

===Reverting to unpatched packages===

+

=== Reverting to unpatched packages ===

To restore the unpatched packages, reinstall the originals:

To restore the unpatched packages, reinstall the originals:

Line 519:

Line 476:

# pacman -S --asdeps freetype2 cairo fontconfig

# pacman -S --asdeps freetype2 cairo fontconfig

−

==Applications without fontconfig support==

+

== Applications without fontconfig support ==

Some applications like [[URxvt]] will ignore fontconfig settings. This is very apparent when using the infinality patches which are heavily reliant on proper configuration. You can work around this by using {{ic|~/.Xresources}}, but it is not nearly as flexible as fontconfig. Example (see [[#Fontconfig configuration]] for explanations of the options):

Some applications like [[URxvt]] will ignore fontconfig settings. This is very apparent when using the infinality patches which are heavily reliant on proper configuration. You can work around this by using {{ic|~/.Xresources}}, but it is not nearly as flexible as fontconfig. Example (see [[#Fontconfig configuration]] for explanations of the options):

Line 534:

Line 491:

Make sure the settings are loaded properly when X starts with {{ic|xrdb -q}} (see [[Xresources]] for more information).

Make sure the settings are loaded properly when X starts with {{ic|xrdb -q}} (see [[Xresources]] for more information).

−

==Troubleshooting==

+

== Troubleshooting ==

=== Distorted fonts ===

=== Distorted fonts ===

Line 544:

Line 501:

Fontconfig should be able to detect DPI parameters as discovered by the Xorg server. You can check the automatically discovered DPI with {{ic|xdpyinfo}} (provided by the {{pkg|xorg-xdpyinfo}} package):

Fontconfig should be able to detect DPI parameters as discovered by the Xorg server. You can check the automatically discovered DPI with {{ic|xdpyinfo}} (provided by the {{pkg|xorg-xdpyinfo}} package):

If the DPI is detected incorrectly (usually due to an incorrect monitor EDID), you can specify it manually in the Xorg configuration, see [[Xorg#Display Size and DPI]]. This is the recommended solution, but it may not work with buggy drivers.

+

If the DPI is detected incorrectly (usually due to an incorrect monitor EDID), you can specify it manually in the Xorg configuration, see [[Xorg#Display size and DPI]]. This is the recommended solution, but it may not work with buggy drivers.

Fontconfig will default to the Xft.dpi variable if it is set. Xft.dpi is usually set by desktop environments (usually to Xorg's DPI setting) or manually in {{ic|~/.Xdefaults}} or {{ic|~/.Xresources}}. Use xrdb to query for the value:

Fontconfig will default to the Xft.dpi variable if it is set. Xft.dpi is usually set by desktop environments (usually to Xorg's DPI setting) or manually in {{ic|~/.Xdefaults}} or {{ic|~/.Xresources}}. Use xrdb to query for the value:

−

{{hc|<nowiki>$ xrdb -query | grep dpi</nowiki>|Xft.dpi: 102}}

+

{{hc|<nowiki>$ xrdb -query | grep dpi</nowiki>|

+

Xft.dpi: 102

+

}}

Those still having problems can fall back to manually setting the DPI used by fontconfig:

Those still having problems can fall back to manually setting the DPI used by fontconfig:

Line 561:

Line 522:

...

...

−

===Calibri, Cambria, Monaco, etc. not rendering properly===

+

=== Calibri, Cambria, Monaco, etc. not rendering properly ===

Some scalable fonts have embedded bitmap versions which are rendered instead, mainly at smaller sizes. Force using scalable fonts at all sizes by [[#EmbeddedBitmap|#Disabling embedded bitmap]].

Some scalable fonts have embedded bitmap versions which are rendered instead, mainly at smaller sizes. Force using scalable fonts at all sizes by [[#EmbeddedBitmap|#Disabling embedded bitmap]].

−

===Older GTK and QT applications===

+

=== Older GTK and QT applications ===

Modern GTK apps enable Xft by default but this was not the case before version 2.2. If it is not possible to update these applications, force Xft for old [[GNOME]] applications by adding to {{ic|~/.bashrc}}:

Modern GTK apps enable Xft by default but this was not the case before version 2.2. If it is not possible to update these applications, force Xft for old [[GNOME]] applications by adding to {{ic|~/.bashrc}}:

Line 575:

Line 536:

export QT_XFT=true

export QT_XFT=true

−

===Applications overriding hinting===

+

=== Applications overriding hinting ===

+

Some applications may override default fontconfig hinting and anti-aliasing settings. This may happen with [[Gnome]] 3, for example. Use the specific configuration program for the application in such cases. For gnome, try {{pkg|gnome-tweak-tool}}.

Some applications may override default fontconfig hinting and anti-aliasing settings. This may happen with [[Gnome]] 3, for example. Use the specific configuration program for the application in such cases. For gnome, try {{pkg|gnome-tweak-tool}}.

Revision as of 17:48, 25 December 2013

Fontconfig is a library designed to provide a list of available fonts to applications, and also for configuration for how fonts get rendered. See package fontconfig and Wikipedia:Fontconfig. The Free type library (freetype2 package) renders the fonts, based on this configuration.

Though Fontconfig is the standard in today's Linux, some applications still rely on the original method of font selection and display, the X Logical Font Description.

The font rendering packages on Arch Linux includes support for freetype2 with the bytecode interpreter (BCI) enabled. Patched packages exist for better font rendering, especially with an LCD monitor. See #Patched packages below. The Infinality package allows both auto-hinting and subpixel rendering, allows the LCD filter to be tweaked without recompiling, and allows the auto-hinter to work well with bold fonts.

Font paths

For fonts to be known to applications, they must be cataloged for easy and quick access.

The font paths initially known to Fontconfig are: /usr/share/fonts/ and ~/.fonts/ (of which Fontconfig will scan recursively). For ease of organization and installation, it is recommended to use these font paths when adding fonts.

To see a list of known Fontconfig fonts:

$ fc-list : file

See man fc-list for more output formats.

Check for Xorg's known font paths by reviewing its log:

$ grep /fonts /var/log/Xorg.0.log

Tip: You can also check the list of Xorg's known font paths using the command xset q.

Keep in mind that Xorg does not search recursively through the /usr/share/fonts/ directory like Fontconfig does. To add a path, the full path must be used:

Section "Files"
FontPath "/usr/share/fonts/local/"
EndSection

If you want font paths to be set on a per-user basis, you can add and remove font paths from the default by adding the following line(s) to ~/.xinitrc:

Fontconfig configuration

Configuration can be done per-user through $XDG_CONFIG_HOME/fontconfig/fonts.conf, and globally with /etc/fonts/local.conf. The settings in the per-user configuration have precedence over the global configuration. Both these files use the same syntax.

Note: Configuration files and directories: ~/.fonts.conf/, ~/.fonts.conf.d/ and ~/.fontconfig/*.cache-* are deprecated since fontconfig 2.10.1 (upstream commit) and will not be read by default in the future versions of the package. New paths are $XDG_CONFIG_HOME/fontconfig/fonts.conf, $XDG_CONFIG_HOME/fontconfig/conf.d/NN-name.conf and $XDG_CACHE_HOME/fontconfig/*.cache-* respectively. If using the second location, make sure the naming is valid (where NN is a two digit number like 00, 10, or 99).

Fontconfig gathers all its configurations in a central file (/etc/fonts/fonts.conf). This file is replaced during fontconfig updates and shouldn't be edited. Fontconfig-aware applications source this file to know available fonts and how they get rendered. This file is a conglomeration of rules from the global configuration (/etc/fonts/local.conf), the configured presets in /etc/fonts/conf.d/, and the user configuration file ($XDG_CONFIG_HOME/fontconfig/fonts.conf). fc-cache can be used to rebuild fontconfig's configuration, although changes will only be visible in newly launched applications.

Note: For some desktop environments (such as GNOME and KDE) using the Font Control Panel will automatically create or overwrite the user font configuration file. For these desktop environments, it is best to match your already defined font configurations to get the expected behavior.

Presets

There are presets installed in the directory /etc/fonts/conf.avail. They can be enabled by creating symbolic links to them, both per-user and globally, as described in /etc/fonts/conf.d/README. These presets will override matching settings in their respective configuration files.

Anti-aliasing

Font rasterization converts vector font data to bitmap data so that it can be displayed. The result can appear jagged due to aliasing. anti-aliasing is enabled by default and increases the apparent resolution of font edges.

Hinting

Font hinting (also known as instructing) is the use of mathematical instructions to adjust the display of an outline font so that it lines up with a rasterized grid, (i.e. the pixel grid of the display). It's intended effect is to make fonts appear more crisp so that they are more readable. Fonts will line up correctly without hinting when displays have around 300 DPI. Two types of hinting are available.

Byte-Code Interpreter (BCI)

Using BCI hinting, instructions in TrueType fonts fonts are rendered according to FreeTypes's interpreter. BCI hinting works well with fonts with good hinting instructions. To enable hinting:

Autohinter

The Autohinter attempts to do automatic hinting and disregards any existing hinting information. Originally it was the default because TrueType2 fonts were patent-protected but now that these patents have expired there's very little reason to use it. It does work better with fonts that have broken or no hinting information but it will be strongly sub-optimal for fonts with good hinting information. Generally common fonts are of the later kind so autohinter will not be useful. To enable auto-hinting:

Hintstyle

Hintstyle is the amount of font reshaping done to line up to the grid. Hinting values are: hintnone, hintslight, hintmedium, and hintfull. hintslight will make the font more fuzzy to line up to the grid but will be better in retaining font shape, while hintfull will be a crisp font that aligns well to the pixel grid but will lose a greater amount of font shape. Preferences vary.

Subpixel rendering

Most monitors manufactured today use the Red, Green, Blue (RGB) specification. Fontconfig will need to know your monitor type to be able to display your fonts correctly. Monitors are either: RGB (most common), BGR, V-RGB (vertical), or V-BGR. A monitor test can be found here).

Note: Subpixel rendering effectively triples the horizontal (or vertical) resolution for fonts by making use of subpixels. The autohinter and subpixel rendering are not designed to work together and should not be used in combination without the Infinality patch set.

LCD filter

When using subpixel rendering, you should enable the LCD filter, which is designed to reduce colour fringing. This is described under LCD filtering in the FreeType 2 API reference. Different options are described under FT_LcdFilter, and are illustrated by this LCD filter test page.

The lcddefault filter will work for most users. Other filters are available that can be used in special situations: lcdlight; a lighter filter ideal for fonts that look too bold or fuzzy, lcdlegacy, the original Cairo filter; and lcdnone to disable it entirely.

Advanced LCD filter specification

If the available, built-in LCD filters are not satisfactory, it is possible to tweak the font rendering very specifically by building a custom freetype2 package and modifying the hardcoded filters. The Arch Build System can be used to build and install packages from source.

First, refresh the freetype2 PKGBUILD as root:

# abs extra/freetype2

This example uses /var/abs/build as the build directory, substitute it according to your personal ABS setup. Download and extract the freetype2 package as a regular user:

Reboot or restart X. The lcddefault filter should now render fonts differently.

Disable auto-hinter for bold fonts

The auto-hinter uses sophisticated methods for font rendering, but often makes bold fonts too wide. Fortunately, a solution can be turning off the autohinter for bold fonts while leaving it on for the rest:

Replace fonts

The most reliable way to do this is to add an XML fragment similar to the one below. Using the "binding" attribute will give you better results, for example, in Firefox where you may not want to change properties of font being replaced. This will cause Ubuntu to be used in place of Georgia:

Disable scaling of bitmap fonts

To disable scaling of bitmap fonts (which often makes them blurry), remove /etc/fonts/conf.d/10-scale-bitmap-fonts.conf.

Create bold and italic styles for incomplete fonts

Freetype has the ability to automatically create italic and bold styles for fonts that do not have them, but only if explicitly required by the application. Given programs rarely send these requests, this section covers manually forcing generation of missing styles.

Start by editing /usr/share/fonts/fonts.cache-1 as explained below. Store a copy of the modifications on another file, because a font update with fc-cache will overwrite /usr/share/fonts/fonts.cache-1.

Tip: Use the value 'embolden' for existing bold fonts in order to make them even bolder.

Change rule overriding

Fontconfig processes files in /etc/fonts/conf.d in numerical order. This enables rules or files to override one another, but often confuses users about what file gets parsed last.

To guarantee that personal settings take precedence over any other rules, change their ordering:

# cd /etc/fonts/conf.d
# mv 50-user.conf 99-user.conf

This change seems however to be unnecessary for the most of the cases, because a user is given enough control by default to set up own font preferences, hinting and antialiasing properties, alias new fonts to generic font families, etc.

Pseudo Gamma Correction: Lighten and darken glyphs at a given value, below a given size. Works on native TT hinter and autohinter.

Embolden Thin Fonts: Embolden thin or light fonts so that they are more visible. Works on autohinter.

Force Slight Hinting: Force slight hinting even when programs want full hinting. If you use the local.conf I provide (included in infinality-settings fedora package) you will notice nice improvements on @font-face fonts.

ChromeOS Style Sharpening: ChromeOS uses a patch to sharpen the look of fonts. This is now included in the infinality patchset.

A number of presets are included and can be used by setting the USE_STYLE variable in /etc/profile.d/infinality-settings.sh.

Installation and configuration

Tip: All AUR packages in this section can also be downloaded from bohoomil's custom repository. See the section below for how to enable this repository.

Note: If you have been using fontconfig-infinality-ultimate < 2.11.0-2, you need to re-install (not upgrade!) fontconfig-infinality-ultimate package:

It is recommended to also install fontconfig-infinalityAUR to enable selection of predefined font substitution styles and antialiasing settings, apart from the rendering settings of the engine itself. After doing so, you can select the font style (win7, winxp, osx, linux, ...) with:

# infctl setstyle

If you set e.g. win7 or osx you need the corresponding fonts installed.

Default infinality settings can cause some programs to display fonts at 72 DPI instead of 96. If you notice a problem open /etc/fonts/infinality/infinality.conf search for the section on DPI and change 72 to 96. This problem can specifically affect conky causing the fonts to appear smaller than they should. Thus not aligning properly with images.

The README for fontconfig-infinalityAUR says that /etc/fonts/local.conf should either not exist, or have no infinality-related configurations in it. The local.conf is now obsolete and completely replaced by this configuration.

Note that the *-ubuntu AUR packages need to be kept up-to-date by the user, and will not be updated by pacman along with other packages. The whole graphical system can become inoperable if the user-installed core graphical libraries become incompatible with the official repository applications.

Reverting to unpatched packages

To restore the unpatched packages, reinstall the originals:

# pacman -S --asdeps freetype2 cairo fontconfig

Applications without fontconfig support

Some applications like URxvt will ignore fontconfig settings. This is very apparent when using the infinality patches which are heavily reliant on proper configuration. You can work around this by using ~/.Xresources, but it is not nearly as flexible as fontconfig. Example (see #Fontconfig configuration for explanations of the options):

Make sure the settings are loaded properly when X starts with xrdb -q (see Xresources for more information).

Troubleshooting

Distorted fonts

Note: 96 DPI is not a standard. You should use your monitor's actual DPI to get proper font rendering, especially when using subpixel rendering.

If fonts are still unexpectedly large or small, poorly proportioned or simply rendering poorly, fontconfig may be using the incorrect DPI.

Fontconfig should be able to detect DPI parameters as discovered by the Xorg server. You can check the automatically discovered DPI with xdpyinfo (provided by the xorg-xdpyinfo package):

$ xdpyinfo | grep dots

resolution: 102x102 dots per inch

If the DPI is detected incorrectly (usually due to an incorrect monitor EDID), you can specify it manually in the Xorg configuration, see Xorg#Display size and DPI. This is the recommended solution, but it may not work with buggy drivers.

Fontconfig will default to the Xft.dpi variable if it is set. Xft.dpi is usually set by desktop environments (usually to Xorg's DPI setting) or manually in ~/.Xdefaults or ~/.Xresources. Use xrdb to query for the value:

$ xrdb -query | grep dpi

Xft.dpi: 102

Those still having problems can fall back to manually setting the DPI used by fontconfig:

Calibri, Cambria, Monaco, etc. not rendering properly

Some scalable fonts have embedded bitmap versions which are rendered instead, mainly at smaller sizes. Force using scalable fonts at all sizes by #Disabling embedded bitmap.

Older GTK and QT applications

Modern GTK apps enable Xft by default but this was not the case before version 2.2. If it is not possible to update these applications, force Xft for old GNOME applications by adding to ~/.bashrc:

export GDK_USE_XFT=1

For older QT applications:

export QT_XFT=true

Applications overriding hinting

Some applications may override default fontconfig hinting and anti-aliasing settings. This may happen with Gnome 3, for example. Use the specific configuration program for the application in such cases. For gnome, try gnome-tweak-tool.