Fontconfig/ja

fontconfig ライブラリは、全ての GUI アプリケーションに対して、フォントの選択と設定を単一にすることを企図したものです. さまざまなデスクトップ環境がありそれぞれが固有の設定を優先させることが一般的ですがそれでもなお、fontconfig が基盤的なライブラリです.

一般論
fontconfig uses XML files in the directory to generate its internal configuration. By default it parses (users should not edit this file!) which sets some sane defaults and usually contains code to also parse  content. In addition there is the directory that contains various possible configuration files that each cover some aspect of fontconfig. It's customary to symlink necessary files to. These files are executed in order they are named; for this reason their names start with a two digit number with the first digit (tens) indicating what the file affects (called the class).

Gentoo 特有の部分
Gentoo ships an eselect module (eselect fontconfig) that does exactly what was described in generic way - it manages symlinks of files in by adding or removing them from the  directory. For obvious reasons changing system wide configuration requires appropriate permissions.

The following subsections explain how to deal with the fontconfig eselect module.

利用可能なファイルのリスト表示
The list command shows the available fontconfig files, and marks the enabled ones with an asterisk.

特定のファイルの有効化
Files can be enabled either by filename or by the number in brackets. These two do the same thing:

特定のファイルの無効化
以下のようにすると、ファイルの無効化が可能です:

システム全体の設定をカスタマイズ
To create a custom, system-wide fontconfig</tt> file, enable and create  (this is an XML file).

ユーザー単位での設定
To create per-user fontconfig</tt> files, enable (which might be enabled by default), and have the end users use  (which has the same XML format as ).

設定の確認
Check the default font replacement, for example for Arial, by typing:

アンチエイリアス、ヒンティング、サブピクセルレンダリング
Rendering aspects can be tuned as well. In the following sections the Anti-aliasing, Hinting and Sub-pixel rendering features are tuned.

ヒンティングの強制
The default fontconfig</tt> behavior regarding hinting is rather undocumented, but it can be made deterministically sub-optimal by making a system wide default.


 * 1) First enable
 * 2) Edit the  file to include full hinting by default

This snippet enables full hinting:

サブピクセルレンダリングの使用
It's important to determine the sub-pixel layout of the LCD matrix. It's usually RGB but the only way to be sure is to either consult display specification or use this sub-pixel layout test to determine it.

Once determined, enable the appropriate file.

It's strongly advised that lcdfilter</tt>, if available, is used with sub-pixel rendering. It comes in different varieties but the default should be appropriate for all common fonts.

Regarding autohinter
Autohinter attempts to do automatic hinting disregarding any existing hinting information. Until recently it was the default because TrueType2 was covered by patents but now that they have expired there's very little reason to use it. From technical point of view it does better than broken or no hinting information but it will be strongly sub-optimal for fonts with good hinting information. Generally system fonts are of the second kind so autohinter should not be used.

Infinality
Infinality is a (somewhat controversial) set of patches for FreeType and accompanying fontconfig</tt> files. The goal of Infinality is to provide higher quality font rendering including emulation of other OS font rendering styles.

Infinality の有効化
を直接に編集するか、 euse ツールを利用して、'infinality' USE フラグを有効にします.

次に、影響を受けるプログラムを再ビルドします.

再ビルド後に表示されるメッセージの内容にかかわらず、 を有効にします.

Infinality の設定
Infinality can be configured in various ways including custom configurations, but easiest is to use pre-made profiles shipped in that along with eselect modules should have been installed as dependencies of the   USE flag.

簡単で合理的な設定
It's also recommended to disable all fontconfig</tt> settings except for as they interfere with the rendering of infinality styles:

Certain fontconfig</tt> settings do not interfere with how the fonts are rendered, but rather determine the default fonts for font-types (such as Monospace, sans-serif, etc.). Such settings (for example the configurations) can be left enabled.

解説
Infinality provides FreeType environment variables that can be used to configure features introduced with its patches as well as fontconfig</tt> files to be used with these changes. fontconfig</tt> file sets are administrated on Gentoo via eselect infinality</tt> while the FreeType behaviour is set using eselect lcdfilter</tt>.

These eselect modules function as usual:


 * Listing available fontconfig</tt> file sets.


 * Listing available FreeType variable sets.


 * Both sets should match of course except when there are multiple matches possible such as shown below.

フォントの選択
Choosing the right font can be trickier than deciding on the right hinting type. For one reason or another fonts will not be perfect but it's certainly doable to make that same fonts look better than, say, Windows 7 default font configuration.

外部の情報

 * In-depth articles from Arch Linux wiki on:
 * Font configuration
 * Infinality
 * Official fontconfig</tt> documentation for users
 * Wikipedia article on font hinting