XdeTT XでTrueTypeFontを使おう

ソフトウェア別の設定例

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

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

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

gtk+ 1.2 を使うソフト (gimp1.2 や sylpheed など) のメニューなど UI に関するフォントは, ~/.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"

fontconfigを使うソフトウェア

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

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

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

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

若しくは

$ fc-list | nkf -e | sort

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

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

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

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>
hintingの制御

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

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


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

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

コンテンツエリア

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

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

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

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;
}
Mozillaの Xft2 + fontconfig無効化

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

user_pref("fonts.xft.enabled", false);
ビルド時のオプションを調べる

Mozilla 1.6以降では,URLバーに about:buildconfigと入力しReturnすると,ビルド時の環境を知る事が出来ます.

webmaster Shigeyuki Yamashita (@). This server is sickhack.homelinux.org.

LastModified: 2004-02-11T01:39:46+0900