「/etc/fonts/local.conf」和「/etc/fonts/conf.d/51-local.conf」
緣起
觀看「/etc/fonts/fonts.conf」的內容,可以看到一段註解
執行
$ cat /etc/fonts/fonts.conf | sed -n '7,9p'
顯示
DO NOT EDIT THIS FILE.
IT WILL BE REPLACED WHEN FONTCONFIG IS UPDATED.
LOCAL CHANGES BELONG IN 'local.conf'.
確認 local.conf 的路徑
執行下面指令,產生「/etc/fonts/local.conf」,填入一行內容「test」。
$ sudo sh -c 'echo test > /etc/fonts/local.conf'
執行下面指令,觀看剛剛產生「/etc/fonts/local.conf」這個檔案的內容。
$ cat /etc/fonts/local.conf
顯示
test
執行下面指令,來確認「/etc/fonts/local.conf」這個檔案是否有被採用。
$ fc-match
第一行顯示
Fontconfig error: "local.conf", line 1: syntax error
/etc/fonts/conf.d/51-local.conf
執行
$ ls /etc/fonts/conf.d/51-local.conf -l
顯示
lrwxrwxrwx 1 root root 27 Aug 17 03:18 /etc/fonts/conf.d/51-local.conf -> ../conf.avail/51-local.conf
或是執行
$ stat /etc/fonts/conf.d/51-local.conf
顯示
File: '/etc/fonts/conf.d/51-local.conf' -> '../conf.avail/51-local.conf'
Size: 27 Blocks: 0 IO Block: 4096 symbolic link
Device: 822h/2082d Inode: 4479723 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2016-11-12 17:44:06.088127060 +0800
Modify: 2016-08-17 03:18:15.000000000 +0800
Change: 2016-11-12 17:44:03.676187423 +0800
Birth: -
可以知道「/etc/fonts/conf.d/51-local.conf」這個檔案是「symbolic link」,
link到「/etc/fonts/conf.avail/51-local.conf」這個檔案。
執行下面指令,觀看「/etc/fonts/conf.d/51-local.conf」的內容
$ cat /etc/fonts/conf.d/51-local.conf
顯示
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!-- Load local system customization file -->
<include ignore_missing="yes">local.conf</include>
</fontconfig>
確認「/etc/fonts/conf.d/51-local.conf」和「/etc/fonts/local.conf」的因果關係
執行下面指令,將「/etc/fonts/conf.d/51-local.conf」移走
$ sudo mv /etc/fonts/conf.d/51-local.conf /etc/fonts/51-local.conf
然後再執行下面指令
$ fc-match
就沒有再顯示剛剛的錯誤訊息了「Fontconfig error: “local.conf”, line 1: syntax error」。
執行下面指令,將剛剛移走「51-local.conf」移回「/etc/fonts/conf.d/51-local.conf」
$ sudo mv /etc/fonts/51-local.conf /etc/fonts/conf.d/51-local.conf
或是執行下面的指令,將「/etc/fonts/conf.d/51-local.conf」恢復原狀
cd /etc/fonts/conf.d/
sudo ln -s ../conf.avail/51-local.conf 51-local.conf
然後再執行下面指令
$ fc-match
第一行就會再出現
Fontconfig error: "local.conf", line 1: syntax error
收尾
實驗完畢
執行下面的指令,把剛剛產生的「/etc/fonts/local.conf」刪除
$ sudo rm /etc/fonts/local.conf