Install the Font Library & Chinese font in CentOS 7

Source: Internet
Author: User

Install the font library and Chinese font in CentOS 7
Preface

When Chinese garbled characters and Chinese fonts are found in the report, the first consideration is whether the operating system has Chinese fonts, in CentOS 7, it is found that the command is invalid when you enter the command to view the font list:

As you can see, there are not only no Chinese fonts, but not even the library. Next we will record how to install the library and Chinese fonts in CentOS 7.

Install the library

Run the following command to install the fontconfig library in CentOS 4.x:

yum -y install fontconfig

When the prompt message is displayed, it indicates that the installation is successful:

In this case, you can see the fonts and fontconfig directories in the/usr/shared directory (which was previously unavailable ):

Next we can add Chinese fonts to our library.

Add Chinese font

In CentOS, the storage location of the fonts library is exactly the fonts directory, so the first thing we need to do is to find the Chinese font file and put it under this directory, the Chinese font file can be found in our windows system. Open the Windows/Fonts directory on drive C:

For example, we only need to copy the font we need and upload it to the linux server. Here I select and (these fonts are used in the report ), we can see two files with the suffix ttf and ttc: before that, we need to create a new directory. First, create a directory in the/usr/shared/fonts directory. chinese:

Then, upload the two fonts above to the/usr/shared/fonts/chinese directory:

Then you need to modify the permissions of the chinese directory:

chmod -R 755 /usr/share/fonts/chinese

Next, you need to install ttmkfdir to search for all the font information in the directory, generate a Summary of the fonts. scale file, and enter the command:

yum -y install ttmkfdir

When the prompt message is displayed, it indicates that the installation is successful:

Then run the ttmkfdir command:

ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir

The last step is to modify the font configuration file. First, open the configuration file in the Editor:

vi /etc/fonts/fonts.conf

We can see a Font list, that is, the Font list. here we need to add the Chinese Font position we added: Then input: wq to save and exit. Finally, don't forget to refresh the Font cache in the memory, in this way, you do not need to restart reboot:

fc-cache

After all these steps are completed, you can use fc-list to view the font list again:

You can see that the Chinese font has been successfully installed. Now the installation process is complete. You can view the report again and find that the Chinese style and content are properly displayed.

Summary

Briefly record The problem of installing The font library and Chinese fonts in CentOS 7, and hope to help The End users who encounter The same problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.