6. ソフトウェア別の設定例

6.1. Emacs

~/.Xresources へ記述する.

Emacs.Fontset-0:-*-fixed-medium-r-normal--14-*-*-c-*-*-fontset-defaults,\
    ascii:-monotype-andale mono-medium-r-*-*-14-*-*-*-m-*-iso8859-1,\
    latin-jisx0201:-motoya-cedar1mono-medium-r-*-*-14-*-*-*-m-*-jisx0201.1976-0,\
    katakana-jisx0201:-motoya-cedar1mono-medium-r-*-*-14-*-*-*-m-*-jisx0201.1976-0,\
    japanese-jisx0208:-motoya-cedar1mono-medium-r-*-*-14-*-*-*-m-*-jisx0208.1990-0,\
    japanese-jisx0212:-motoya-cedar1mono-medium-r-*-*-14-*-*-*-m-*-jisx0212.1990-0
Emacs.Font: fontset-defaults
            

変更後,以下のコマンドを実行し反映させる.

$ xrdb -merge ~/.Xresources

6.2. xterm

~/.Xresources へ記述する.

xterm*fontSet: -misc-fixed-medium-r-normal-*-14-*,-misc-fixed-medium-r-normal-*-14-*-iso8859-1
xterm*boldfontset: -misc-fixed-bold-r-normal-*-14-*,-misc-fixed-bold-r-normal-*-14-*-iso8859-1
            

変更後,以下のコマンドを実行し反映させる.

$ xrdb -merge ~/.Xresources

6.3. gtk+ 1.2 を使うソフトウェア

gtk+ 1.2 を使うソフト[10] のメニューなど User Interface に関するフォントは, ~/.gtkrc に以下の様に記述する.

style "gtk-default-ja"
{
    fontset = "-monotype-andale mono-medium-r-*-*-12-*-*-*-m-*-iso8859-1,\
    -motoya-cedar1mono-medium-r-*-*-12-*-*-*-m-*-jisx0201.1976-0,\
    -motoya-cedar1mono-medium-r-*-*-12-*-*-*-m-*-jisx0208.1983-0,\
    -motoya-cedar1mono-medium-r-*-*-12-*-*-*-m-*-jisx0208.1990-0,\
    -motoya-cedar1mono-medium-r-*-*-12-*-*-*-m-*-jisx0212.1990-0"
}
widget "*Text" style "gtk-default-ja"
            

6.4. fontconfigを使うソフトウェア

6.4.1. fontconfigのコンフィグレーション

重要なのは fontconfig の設定がうまくいっているかどうかです.

fontconfig のコンフィグファイル /etc/fonts/local.conf[11] で TrueType フォントがインストールしてあるディレクトリが指定してあるかどうか,また, fc-list で,インストールしてある TrueTypeフォントがリストされるか確認しましょう.リストは UTF-8 で吐き出されるので,フォント名に因っては化けます.

$ fc-list | iconv -f UTF-8 -t EUC-JP | sort

若しくは

$ fc-list | nkf -e | sort

化けて見辛い場合は,上記のように iconvnkf に pipe すると良いでしょう.

/etc/fonts/local.confはシステム全般での設定ファイル,~/.fonts.confは各ユーザ個別の設定ファイルです.

/etc/fonts/fonts.conf/etc/fonts/local.conf~/fonts.conf, は XML[12]で記述され,DTD[13]fonts.dtdというファイル名で /etc/fontsディレクトリ内にありますから編集は簡単です. emacs の psgml-modeで編集すると楽に編集できるでしょう.

6.4.1.1. dir

fontconfig でフォントをインストールしたディレクトリが走査されるように指定するには,/etc/fonts/local.conf ,或いは~/.fonts.confへ以下の様に<dir>〜</dir>タグでフォントのあるディレクトリを囲んで追記します.指定されたディレクトリは再帰的に走査され,フォントのリストが作成されます.

<dir>/usr/X11R6/lib/X11/fonts</dir>
<dir>/usr/share/fonts</dir>
<dir>~/.fonts</dir>
      
6.4.1.2. hintingの制御

フォントサイズによって,また,フォントによってはヒンティングを強く効かせると読み辛くなったり,逆に汚くなったりすることがあるが,それは autohint と hinting によって制御できる.

以下の例では 16pixelより小さいサイズでは autohintを無効にし,16pixel以上では autohintoを有効にしている.

<match target="font">
  <test name="pixelsize" compare="less">
    <double>16</double>
  </test>
  <edit name="hinting" mode="assign">
    <bool>true</bool>
  </edit>
  <edit name="hintstyle" mode="assign">
    <const>hintslight</const>
  </edit>
  <edit name="autohint" mode="assign">
    <bool>false</bool>
  </edit>
</match>

<match target="font">
  <test name="pixelsize" compare="more_eq">
    <double>16</double>
  </test>
  <edit name="hinting" mode="assign">
    <bool>true</bool>
  </edit>
  <edit name="hintstyle" mode="assign">
    <const>hintfull</const>
  </edit>
  <edit name="autohint" mode="assign">
    <bool>true</bool>
  </edit>
</match>

6.4.2. Xft2 + fontconfigサポートが有効なmozilla

6.4.2.1. コンテンツエリア

ビルド時に ./configure のオプションで --enable-xft を指定し Xft2 + fontconfig サポートが有効になっている Mozilla は,メニューの Edit → Preference のフォント設定でフォントを選択するだけです.fontconfigが有効なMozillaでは以下のようなフォントリストが表示されます.

Xft2 + fontconfigが有効なMozillaでのフォント選択リスト

図 5. Xft2 + fontconfigが有効なMozillaでのフォント選択リスト

Xft2 + fontconfigが有効なMozillaでの表示例

拡大図

図 6. Xft2 + fontconfigが有効なMozillaでの表示例

6.4.2.2. User Interface

User Interface 部分のフォント設定は,~/.mozilla/$USER/XXXXXXXX.slt/chrome/userChrome.css に記述します.fc-list で表示されるフォント名で指定しないとならない点に注意が必要です.

以下は私が行なっている設定例です.

@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* set default name space to XUL */
* {
  font-size: 12px;
  font-family: "Anito-L-Mono", monospace !important;
}
6.4.2.3. Mozillaの Xft2 + fontconfig無効化

もしXft2サポートを無効にしたい場合,~/.mozilla/$USER/XXXXXXXX.slt/prefs.js に以下の設定を書いておくと良いでしょう.

user_pref("fonts.xft.enabled", false);


[10] gimp 1.2 や sylpheed など

[11] 使用している OS やそのディストリビューションによって若干場所が異なるか,若しくはfontconfigのバージョンによっては /etc/fonts/fonts.confしか無い場合があるかもしれません

[12] Extensible Markup Language

[13] Document Type Definition