Home > Operation and Maintenance > CentOS > How to solve the garbled graphics interface of centos7

How to solve the garbled graphics interface of centos7

WJ
Release: 2020-06-05 15:44:21
Original
2925 people have browsed it

How to solve the garbled graphics interface of centos7

How to solve the garbled graphics interface of centos7?

It is found that Chinese garbled characters and Chinese fonts are not neat (overlapping) in the report. The first thing to consider is whether the operating system has Chinese fonts. In CentOS 7, it is found that entering the command to view the font list is a prompt command. Invalid:
How to solve the garbled graphics interface of centos7

As you can see from the picture above, not only are there no Chinese fonts, there are not even font libraries. So next, let’s record how to install the font library and Chinese fonts in Linux CentOS 7.

Installing the font library

In CentOS 4.x, fontconfig is used to install the font library, so enter the following command:

yum -y install fontconfig
Copy after login

When viewing When you get the prompt information in the picture below, it means that the installation has been successful:

How to solve the garbled graphics interface of centos7

You can see fonts and fonts in the /usr/shared directory. fontconfig directory (it didn’t exist before):

How to solve the garbled graphics interface of centos7

Next, we can add Chinese fonts to our font library.

Add Chinese fonts

In CentOS, the font library is stored in the fonts directory seen in the picture above, so the first thing we have to do is to find the Chinese The font files are placed in this directory, and the Chinese font files can be found in our windows system. Open the Windows/Fonts directory under the c drive:

As shown above, we only need to Just copy the fonts and upload them to the Linux server. Here I choose Song and Hei (these two fonts are used in the report). You can see that there are two files with the suffix ttf and ttc:

How to solve the garbled graphics interface of centos7

Before this we also need to create a new directory. First create a new directory chinese in the /usr/shared/fonts directory:

How to solve the garbled graphics interface of centos7

How to solve the garbled graphics interface of centos7

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

How to solve the garbled graphics interface of centos7

Next, you need to modify the permissions of the chinese directory:

chmod -R 755 /usr/share/fonts/chinese
Copy after login

Next, you need to install ttmkfdir to search for all font information in the directory, and summarize and generate the fonts.scale file. Enter the command:

yum -y install ttmkfdir
Copy after login

When you see the prompt message below, the installation has been successful:

How to solve the garbled graphics interface of centos7

Then execute the ttmkfdir command:

ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir
Copy after login

The last step is to modify the font configuration file. First open the configuration file through the editor:

vi /etc/fonts/fonts.conf
Copy after login

You can see a Font list, that is, the font list. Here we need to add the Chinese font location Add in:

How to solve the garbled graphics interface of centos7
Then enter: wq to save and exit. Finally, don’t forget to refresh the font cache in the memory, so that you don’t need to reboot:

fc-cache
Copy after login

This way all Even if the steps are completed, finally look at the font list through fc-list again:

How to solve the garbled graphics interface of centos7

You can see that the Chinese font has been successfully installed, and the installation process is complete. At the end, check the report again and you will find that the Chinese style and content can be displayed normally.

Related reference: centOS tutorial

The above is the detailed content of How to solve the garbled graphics interface of centos7. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template