1. 程式人生 > >鳥哥的Linux私房菜讀書筆記--配置檔案解析與設定

鳥哥的Linux私房菜讀書筆記--配置檔案解析與設定

X server的配置檔案預設放置在/etc/X11下,相關的顯示模組或總模組主要放置在/usr/lib64/xorg/modules,提供螢幕大的字型/usr/share/X11/fonts/,顯示介面卡的晶片組/usr/lib64/xorg/modules/drivers/。標準配置規範檔案/etc/X11/xorg.conf

1、解析X server的設定

檢視X server的版本:$  X -version

如果想要自行加入或者修改部分設定,在/etc/X11/xorg.ocnf.d這個目錄下建置檔名為.conf的檔案,將額外的專案加進去。在修改之前請備份。該檔案的內容是分為數個段落的,每個段落以section開始,以嗯對section結束,裡面還有section的相關設定

Section "section name"
…… <== 與這個 section name 有關的設定專案
……
EndSection

至於常見的 section name 主要有: 1. Module: 被載入到 X Server 當中的模組 (某些功能的驅動程式); 2. InputDevice: 包括輸入的 1. 鍵盤的格式 2. 滑鼠的格式,以及其他相關輸入裝置; 3. Files: 設定字型所在的目錄位置等; 4. Monitor: 監視器的格式, 主要是設定水平、垂直的更新頻率,與硬體有關; 5. Device: 這個重要,就是顯示介面卡晶片組的相關設定了; 6. Screen: 這個是在螢幕上顯示的相關解析度與顏色深度的設定專案,與顯示的行為有關; 7. ServerLayout: 上述的每個專案都可以重複設定,這裡則是此一 X server 要取用的哪個專案值的設定囉

2、字形管理

xorg所使用的字形大部分都是放在/usr/share/X11/fonts/   &  /usr/share/fonts  &  /etc/X11/fontpath.d/(預設載入的字形位置)

CentOS 7 針對中文字型 (chinese) 來說,有楷書與明體,明體預設安裝了,不過楷書卻沒有安裝耶~ 那我們能不能安裝了楷書之後,將楷書也列為預設的字型之一呢?來瞧一瞧我們怎麼作的好了:

# 1. 檢查中文字型,並且安裝中文字型與檢驗有沒有放置到 fontpath.d 目錄中!
[[email protected] ~]# ll -d /usr/share/fonts/cjk*
drwxr-xr-x. 2 root root 22 May 4 17:54 /usr/share/fonts/cjkuni-uming
[
[email protected]
 ~]# yum install cjkuni-ukai-fonts [[email protected] ~]# ll -d /usr/share/fonts/cjk* drwxr-xr-x. 2 root root 21 Sep 16 11:48 /usr/share/fonts/cjkuni-ukai # 這就是楷書! drwxr-xr-x. 2 root root 22 May 4 17:54 /usr/share/fonts/cjkuni-uming [[email protected] ~]# ll /etc/X11/fontpath.d/ lrwxrwxrwx. 1 root root 29 Sep 16 11:48 cjkuni-ukai-fonts -> /usr/share/fonts/cjkuni-ukai/ lrwxrwxrwx. 1 root root 30 May 4 17:54 cjkuni-uming-fonts -> /usr/share/fonts/cjkuni-uming/ lrwxrwxrwx. 1 root root 36 May 4 17:52 default-ghostscript -> /usr/share/fonts/default/ghostscript lrwxrwxrwx. 1 root root 30 May 4 17:52 fonts-default -> /usr/share/fonts/default/Type1 lrwxrwxrwx. 1 root root 27 May 4 17:51 liberation-fonts -> /usr/share/fonts/liberation lrwxrwxrwx. 1 root root 27 Sep 15 17:10 xorg-x11-fonts-100dpi:unscaled:pri=30 -> /usr/share/X11/fonts/100dpi lrwxrwxrwx. 1 root root 26 Sep 15 17:10 xorg-x11-fonts-75dpi:unscaled:pri=20 -> /usr/share/X11/fonts/75dpi lrwxrwxrwx. 1 root root 26 May 4 17:52 xorg-x11-fonts-Type1 -> /usr/share/X11/fonts/Type1 # 竟然會自動的將該字型加入到 fontpath.d 當中!太好了! ^_^ 2. 建立該字型的字型快取資料,並檢查是否真的取用了? [[email protected] ~]# fc-cache -v | grep ukai /usr/share/fonts/cjkuni-ukai: skipping, existing cache is valid: 4 fonts, 0 dirs [[email protected] ~]# fc-list | grep ukai /usr/share/fonts/cjkuni-ukai/ukai.ttc: AR PL UKai TW:style=Book /usr/share/fonts/cjkuni-ukai/ukai.ttc: AR PL UKai HK:style=Book /usr/share/fonts/cjkuni-ukai/ukai.ttc: AR PL UKai CN:style=Book /usr/share/fonts/cjkuni-ukai/ukai.ttc: AR PL UKai TW MBE:style=Book # 3. 重新啟動 Xorg,或者是強制重新進入 graphical.target [[email protected] ~]# systemctl isolate multi-user.target; systemctl isolate graphical.target

如果上述的動作沒有問題的話,現在你可以在圖形介面底下,透過『應用程式』 --> 『公用程式』 --> 『字型檢視程式』當中找到一個名為 『AR PL UKai CN, Book』字樣的字型,點下去就會看到,對於某些程式可能還得要額外的加工

<1>讓視窗管理員可以使用額外的字形

1. 將字型檔案放置到系統設定目錄,亦即底下的目錄中:
[[email protected] ~]# cd /usr/share/fonts/
[[email protected] ~]# mkdir windows
[[email protected] ~]# cp /root/font/*.ttf /usr/share/fonts/windows/
# 2. 使用 fc-cache 將上述的檔案加入字型的支援中:
[[email protected] ~]# fc-cache -f -v
....(前面省略)....
/usr/share/fonts/windows: caching, new cache contents: 6 fonts, 0 dirs
....(後面省略)....
# -v 僅是列出目前的字型資料, -f 則是強制重新建立字型快取!
# 3. 透過 fc-list 列出已經被使用的檔案看看:
[[email protected] ~]# fc-list : file | grep window <==找出被快取住的檔名
/usr/share/fonts/windows/timesbi.ttf:
/usr/share/fonts/windows/timesi.ttf:
/usr/share/fonts/windows/msjh.ttf:
/usr/share/fonts/windows/times.ttf:
/usr/share/fonts/windows/msjhbd.ttf:
/usr/share/fonts/windows/timesbd.ttf:

之後在字型檢視器裡面就會發現有多了『Microsoft JhengHei, Times New Roman』等等的字型可以用