Ubuntuでfont-family対策
Ubuntuのウェブブラウザーでインターネットを閲覧していると、CSSのfont-family
にHelvetica
(プロポーショナル、サンセリフ体)、Times
(プロポーショナル、セリフ体)又はCourier
(等幅、スラブセリフ体)あたりを記述しているウェブページの表示で、例えば「これHelveticaっぽくなくない?」と悶えることがある。Ubuntuにこれらのフォントをインストールしていないためなのだが、悶えないよう~/.fonts.conf
を以下のとおり弄り、これらのフォントをインストールしてある互換性の高い類似フォント等で代替するようにした。
<match target="pattern">
<test name="family" qual="any">
<string>Helvetica</string>
</test>
<edit mode="prepend" name="family" binding="strong">
<string>Nimbus Sans L</string>
<string>TakaoPGothic</string>
<string>Takao Pゴシック</string>
<string>Symbola</string>
<string>sans-serif</string>
</edit>
</match>
<match target="pattern">
<test name="family" qual="any">
<string>Arial</string>
</test>
<edit mode="assign" name="family" binding="same">
<string>Helvetica</string>
</edit>
</match>
<match target="pattern">
<test name="family" qual="any">
<string>Times</string>
</test>
<edit mode="prepend" name="family" binding="strong">
<string>Nimbus Roman No9 L</string>
<string>TakaoPMincho</string>
<string>Takao P明朝</string>
<string>Symbola</string>
<string>serif</string>
</edit>
</match>
<match target="pattern">
<test name="family" qual="any">
<string>Times New Roman</string>
</test>
<edit mode="assign" name="family" binding="same">
<string>Times</string>
</edit>
</match>
<match target="pattern">
<test name="family" qual="any">
<string>Courier</string>
</test>
<edit mode="prepend" name="family" binding="strong">
<string>TakaoMincho</string>
<string>Takao 明朝</string>
<string>monospace</string>
</edit>
</match>
<match target="pattern">
<test name="family" qual="any">
<string>Courier New</string>
</test>
<edit mode="assign" name="family" binding="same">
<string>Courier</string>
</edit>
</match>
プロポーショナルフォントの英数字など半角文字には古参のNimbusフォントファミリーから類似フォントを設定し、日本語など全角文字には新参でそれっぽいTakaoフォントファミリーにフォールバックしている(プロポーショナルフォントに限り、更に絵文字用にSymbolaフォントにフォールバック)。Windowsで言うところのフォントリンクだ。また、マイクロソフトコアフォントへの対策でHelvetica
とArial
、Times
とTimes New Roman
、Courier
とCourier New
をそれぞれ同義と設定している。既に作成していた~/.fonts.conf
の</fontconfig>
の直上に以上のコードを追加し、font-family: Helvetica;
と設定してあるウェブページを閲覧したところ、期待どおり動作することを確認できた(絵文字は未確認😁)。なお、古参のマイクロソフトコアフォント及び日本語フォントへの更なる対策で、以下のとおり追加しようかとも思ったけど、キリがないのでやめた。
<match target="pattern">
<test name="family" qual="any">
<string>Verdana</string>
</test>
<edit mode="prepend" name="family" binding="strong">
<string>Bitstream Vera Sans</string>
<string>VL PGothic</string>
<string>VL Pゴシック</string>
<string>Symbola</string>
<string>sans-serif</string>
</edit>
</match>
<match target="pattern">
<test name="family" qual="any">
<string>Palatino</string>
</test>
<edit mode="prepend" name="family" binding="strong">
<string>URW Palladio L</string>
<string>TakaoPMincho</string>
<string>Takao P明朝</string>
<string>Symbola</string>
<string>serif</string>
</edit>
</match>
<match target="pattern">
<test name="family" qual="any">
<string>Palatino Linotype</string>
</test>
<edit mode="assign" name="family" binding="same">
<string>Palatino</string>
</edit>
</match>
<match target="pattern">
<test name="family" qual="any">
<string>Georgia</string>
</test>
<edit mode="prepend" name="family" binding="strong">
<string>EB Garamond</string>
<string>TakaoPMincho</string>
<string>Takao P明朝</string>
<string>Symbola</string>
<string>serif</string>
</edit>
</match>
<match target="pattern">
<test name="family" qual="any">
<string>MS PGothic</string>
</test>
<edit mode="prepend" name="family" binding="strong">
<string>IPAMonaPGothic</string>
<string>IPA モナー Pゴシック</string>
<string>Symbola</string>
<string>sans-serif</string>
</edit>
</match>
<match target="pattern">
<test name="family" qual="any">
<string>MS Pゴシック</string>
</test>
<edit mode="assign" name="family" binding="same">
<string>MS PGothic</string>
</edit>
</match>
<match target="pattern">
<test name="family" qual="any">
<string>MS UI Gothic</string>
</test>
<edit mode="prepend" name="family" binding="strong">
<string>IPAMonaUIGothic</string>
<string>IPA モナー UIゴシック</string>
<string>Symbola</string>
<string>sans-serif</string>
</edit>
</match>
<match target="pattern">
<test name="family" qual="any">
<string>MS Gothic</string>
</test>
<edit mode="prepend" name="family" binding="strong">
<string>IPAMonaGothic</string>
<string>IPA モナー ゴシック</string>
<string>monospace</string>
</edit>
</match>
<match target="pattern">
<test name="family" qual="any">
<string>MS ゴシック</string>
</test>
<edit mode="assign" name="family" binding="same">
<string>MS Gothic</string>
</edit>
</match>
<match target="pattern">
<test name="family" qual="any">
<string>MS PMincho</string>
</test>
<edit mode="prepend" name="family" binding="strong">
<string>IPAMonaPMincho</string>
<string>IPA モナー P明朝</string>
<string>Symbola</string>
<string>serif</string>
</edit>
</match>
<match target="pattern">
<test name="family" qual="any">
<string>MS P明朝</string>
</test>
<edit mode="assign" name="family" binding="same">
<string>MS PMincho</string>
</edit>
</match>
<match target="pattern">
<test name="family" qual="any">
<string>MS Mincho</string>
</test>
<edit mode="prepend" name="family" binding="strong">
<string>IPAMonaMincho</string>
<string>IPA モナー 明朝</string>
<string>monospace</string>
</edit>
</match>
<match target="pattern">
<test name="family" qual="any">
<string>MS 明朝</string>
</test>
<edit mode="assign" name="family" binding="same">
<string>MS Mincho</string>
</edit>
</match>
Comments