在CentOS 4.x開始用fontconfig來安裝字體庫,linux
因此輸入如下命令便可:vim
[root@VM_16_4_centos ~]# yum -y install fontconfig Loaded plugins: fastestmirror, langpacks Determining fastest mirrors epel | 3.2 kB 00:00:00 extras | 3.4 kB 00:00:00 os | 3.6 kB 00:00:00 percona-release-noarch | 2.9 kB 00:00:00 percona-release-x86_64 | 2.9 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/7): epel/7/x86_64/group_gz | 88 kB 00:00:00 (2/7): epel/7/x86_64/updateinfo | 931 kB 00:00:00 (3/7): extras/7/x86_64/primary_db | 205 kB 00:00:00 (4/7): epel/7/x86_64/primary | 3.6 MB 00:00:00 (5/7): percona-release-x86_64/7/x86_64/primary_db | 836 kB 00:00:01 (6/7): percona-release-noarch/7/primary_db | 18 kB 00:00:02 (7/7): updates/7/x86_64/primary_db | 6.0 MB 00:00:02 epel 12696/12696 Resolving Dependencies --> Running transaction check ---> Package fontconfig.x86_64 0:2.10.95-11.el7 will be installed --> Processing Dependency: fontpackages-filesystem for package: fontconfig-2.10.95-11.el7.x86_64 --> Processing Dependency: font(:lang=en) for package: fontconfig-2.10.95-11.el7.x86_64 --> Running transaction check ---> Package fontpackages-filesystem.noarch 0:1.44-8.el7 will be installed ---> Package lyx-fonts.noarch 0:2.2.3-1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================================================================================================================================================================================= Package Arch Version Repository Size ========================================================================================================================================================================================================================================= Installing: fontconfig x86_64 2.10.95-11.el7 os 229 k Installing for dependencies: fontpackages-filesystem noarch 1.44-8.el7 os 9.9 k lyx-fonts noarch 2.2.3-1.el7 epel 159 k Transaction Summary ========================================================================================================================================================================================================================================= Install 1 Package (+2 Dependent packages) Total download size: 398 k Installed size: 832 k Downloading packages: (1/3): lyx-fonts-2.2.3-1.el7.noarch.rpm | 159 kB 00:00:00 (2/3): fontpackages-filesystem-1.44-8.el7.noarch.rpm | 9.9 kB 00:00:00 (3/3): fontconfig-2.10.95-11.el7.x86_64.rpm | 229 kB 00:00:00 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 809 kB/s | 398 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : fontpackages-filesystem-1.44-8.el7.noarch 1/3 Installing : lyx-fonts-2.2.3-1.el7.noarch 2/3 Installing : fontconfig-2.10.95-11.el7.x86_64 3/3 Verifying : fontpackages-filesystem-1.44-8.el7.noarch 1/3 Verifying : lyx-fonts-2.2.3-1.el7.noarch 2/3 Verifying : fontconfig-2.10.95-11.el7.x86_64 3/3 Installed: fontconfig.x86_64 0:2.10.95-11.el7 Dependency Installed: fontpackages-filesystem.noarch 0:1.44-8.el7 lyx-fonts.noarch 0:2.2.3-1.el7 Complete!
在CentOS中,字體庫的存放位置正是上圖中看到的fonts目錄,因此咱們首先要作的就是找到中文字體文件放到該目錄下,而中文字體文件在咱們的windows系統中就能夠找到,打開c盤下Windows/Fonts目錄:windows
如上圖,咱們只須要將咱們須要的字體拷貝出來並上傳至linux服務器便可centos
在這以前咱們還須要新建目錄,首先在/usr/share/fonts目錄下新建一個目錄chinese:緩存
# mkdir -p /usr/share/fonts/chinese # cd /usr/share/fonts/chinese
緊接着須要修改chinese目錄的權限:服務器
# chmod -R 755 /usr/share/fonts/chinese
接下來須要安裝ttmkfdir來搜索目錄中全部的字體信息,並彙總生成fonts.scale文件,編輯器
輸入命令:字體
[root@VM_16_4_centos chinese]# yum -y install ttmkfdir Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package ttmkfdir.x86_64 0:3.0.9-42.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================================================================================================================================================================================= Package Arch Version Repository Size ========================================================================================================================================================================================================================================= Installing: ttmkfdir x86_64 3.0.9-42.el7 os 48 k Transaction Summary ========================================================================================================================================================================================================================================= Install 1 Package Total download size: 48 k Installed size: 103 k Downloading packages: ttmkfdir-3.0.9-42.el7.x86_64.rpm | 48 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : ttmkfdir-3.0.9-42.el7.x86_64 1/1 Verifying : ttmkfdir-3.0.9-42.el7.x86_64 1/1 Installed: ttmkfdir.x86_64 0:3.0.9-42.el7 Complete!
而後執行ttmkfdir命令便可:3d
# ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir
最後一步就是修改字體配置文件了,首先經過編輯器打開配置文件:code
vim /etc/fonts/fonts.conf
能夠看到一個Font list,即字體列表,
在這裏須要把咱們添加的中文字體位置加進去:
<dir>/usr/share/fonts/chinese</dir>
而後輸入:wq保存退出,
最後別忘了刷新內存中的字體緩存,這樣就不用reboot重啓了:
# fc-cache
這樣全部的步驟就算完成了,最後再次經過 fc-list 看一下字體列表。
能夠看到已經成功安裝上了中文字體,至此安裝過程就所有結束