Fontconfig

このエントリコメントされたが、fontconfigに2つ問題があった。

  1. fonts.confの書き方に問題があり、warningがでる。
  2. ホームディレクトリにfontconfigという名前のcacheディレクトリが作成される。

fonts.conf

後藤大地さんが書いたfonts.confを使用していたが、例えばeclipseを起動した時などに次のようなwarningが出る。

Fontconfig warning: "/home/densuke/.config/fontconfig/fonts.conf", line 88: Having multiple values in <test> isn't supported and may not work as expected
Fontconfig warning: "/home/densuke/.config/fontconfig/fonts.conf", line 203: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/home/densuke/.config/fontconfig/fonts.conf", line 217: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/home/densuke/.config/fontconfig/fonts.conf", line 229: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/home/densuke/.config/fontconfig/fonts.conf", line 229: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/home/densuke/.config/fontconfig/fonts.conf", line 240: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/home/densuke/.config/fontconfig/fonts.conf", line 248: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/home/densuke/.config/fontconfig/fonts.conf", line 259: Having multiple <family> in <alias> isn't supported and may not work as expected

1行目は、要するに

    <match target="font">
        <test name="family" compare="contains">
            <string>IPAGothic</string>
            <string>IPAMincho</string>
            <string>IPAMonaGothic</string>
            ...
        </test>
        ...
    </match>

のような書き方は許されず、

    <match target="font">
        <test name="family" compare="contains">
            <string>IPAGothic</string>
        </test>
        <test name="family" compare="contains">
            <string>IPAMincho</string>
        </test>
        <test name="family" compare="contains">
            <string>IPAMonaGothic</string>
        </test>
        <test name="family" compare="contains">
            ...
        </test>
        ...
    </match>

のように、で囲む必要があるようだ。

2行目以降は、

    <alias binding="strong">
        <family>MS PGothic</family>
        <family>MS Pゴシック</family>
        <prefer>
            <family>IPAMonaPGothic</family>
            <family>IPAPGothic</family>
            <family>TakaoPGothic</family>
            <family>Ume P Gothic C4</family>
            <family>Ume P Gothic C5</family>
            <family>Ume P Gothic</family>
            <family>Ume P Gothic O5</family>
        </prefer>
    </alias>

のように、MS PGothicMS Pゴシックに共通の設定をまとめることはできず、

    <alias binding="strong">
        <family>MS PGothic</family>
        <prefer>
            <family>IPAMonaPGothic</family>
            <family>IPAPGothic</family>
            <family>TakaoPGothic</family>
            <family>Ume P Gothic C4</family>
            <family>Ume P Gothic C5</family>
            <family>Ume P Gothic</family>
            <family>Ume P Gothic O5</family>
        </prefer>
    </alias>

    <alias binding="strong">
        <family>MS Pゴシック</family>
        <prefer>
            <family>IPAMonaPGothic</family>
            <family>IPAPGothic</family>
            <family>TakaoPGothic</family>
            <family>Ume P Gothic C4</family>
            <family>Ume P Gothic C5</family>
            <family>Ume P Gothic</family>
            <family>Ume P Gothic O5</family>
        </prefer>
    </alias>

のように、ごとに書きなおすことで正しく設定できるようだ。

ホームディレクトリにfontconfigという名前のcacheディレクトリが作られる

これは、fontconfigのバグのようだ。この情報に従って、/usr/local/etc/fonts/local.confを作成し、内容を次のようにした。

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
        <cachedir prefix="~">.fontconfig</cachedir>
</fontconfig>

これによって、~/.fontconfigがcacheディレクトリとなる。本来は、~/.cache/fontconfigがcacheディレクトリとなるべきなのかもしれない。ただし、$XDG_CACHE_HOMEに~/.cacheをセットしてもうまく行かないようなので、とりあえずfontconfigのcacheディレクトリは~/.fontconfigとする。

まとめ

この2つの設定の修正で、fontconfigのトラブルは解消された。フォントは正しくIPAフォントが使用されているようだ。

これらの修正をしたfreebsdPostInstallを置いておく。これ以外の修正もしているので、もう一度クリーンに説明するエントリを書く予定。
freebsdPostInstall20140818.tar.gz