InstallFontsByHand
出自DebianWiki
目錄 |
[編輯] 所需套件
- x-ttcidfont-conf libft-perl libttf2 defoma
- libfreetype6 fontconfig libxft2
[編輯] 前言
所有的 Debian GNU/Linux 所提供的字型,只要使用 apt-get 指令就可以裝好了,什麼設定都不用去理它... 但是我們也可能會想自行安裝一些字型呀!那該怎麼做?
由於大多的應用程式使用 Defoma 和 FontConfig 來管理字型,所以字型新增的方式也因而分成兩個步驟:
[編輯] Defoma(用於 XTT、Truetype、PS 字型。)
- 把字型檔複製到 /usr/share/fonts/truetype 下,(最好自行新建立子目錄以利分類)。
- 注意一下新的目錄(建議為 755)及字型檔的權限(建議為 644)。
- 使用 defoma-hints --no-question truetype FontFileName > FontName.hints 建立字型資訊檔。
例:
defoma-hints --no-question truetype /usr/share/fonts/truetype/hanwang/wt024.ttf > /etc/defoma/hints/ttf-HanWang-FangSong.hints
- 如果有需要,請自行修改 FontName.hints 的內容以符合您的需求。
或者,在執行 defoma-hints 時不要加上 --no-question 參數,它會出現設定介面來讓我們自訂 FontName.hints 的內容。
例:
category truetype begin /usr/share/fonts/truetype/hangwang/wt024.ttf Family = HanWangFangSongMedium FontName = HanWangFangSongMedium-Regular Encoding = Unicode Location = English Chinese-Taiwan Charset = ISO10646-1 BIG5 CNS11643-1 CNS11643-2 CNS11643-3 CNS11643-4 CNS11643-5 CNS11643-6 CNS11643-7 ISO8859-1 UniCharset = BIG5 ISO8859-1 GeneralFamily = Roman Weight = Medium Width = Variable Shape = Normal Upright Foundry = HanWang Priority = 20 TTCap = halfwidth-bw=0.5 italic-angle=0.167 no-roblique no-oblique no-ritalic end
- 如果發現字形的中、英文字型竟然同寬,則在 FontName.hints 裡加入這麼一行來修正這個問題:
TTCap = halfwidth-bw=0.5 italic-angle=0.167 no-roblique no-oblique no-ritalic
- 使用 defoma-font -vt reregister-all /PatchToFile/FontName.hints 來註冊字型。
例:defoma-font -vt reregister-all /etc/defoma/hints/ttf-HanWang-FangSong.hints
- 重新啟動 X,或是執行 xset fp rehash,即可讓新增的字型生效。
- 若要移去該字型,使用 defoma-font -vt unregister-all /PatchToFile/FontName.hints 來反註冊字型。
例:defoma-font -vt unregister-all /etc/defoma/hints/ttf-HanWang-FangSong.hints
然後直接刪除該字型檔即可。
PS. 新的 defoma 安裝新字型後可以給 FontConfig 使用
[編輯] FontConfig(用於 libXft 的字型)
- 把字型檔複製到 /usr/share/fonts/truetype 下,(最好自行新建立子目錄以利分類)。
- 注意一下新的目錄(建議為 755)及字型檔的權限(建議為 644)。
- 下達 fc-cache -f -v 來安裝字型。
- 重新啟動 X。
- 若要移去該字型,在刪除該字型檔後,再執行一次 fc-cache -f -v 即可。
註:
在自行安裝了字型之後,可以藉由修改 /etc/fonts/fonts.conf 來修改字型的順序。 Gtk2+ 是修改 Sans-serif faces 區段,而 QT 則是修改 Serif faces 區段。
其實以上的動作也沒有比 MS Windows 新增字型的動作困難多少。
- 上述方法僅可由管理者(root)操作,若是一般使用者要自行新增字型,可替而將字型檔複製到 $HOME/.fonts 目錄下,使用者也可自行定義 $HOME/.fonts.conf 來修改字型順序。
![[Main Page]](/upload/4/49/Debian_taiwan_out.png)