There is a need to generate a two-dimensional code, and there is a text description, but the use of awt.font into Chinese, there has been garbled problem. There are several solutions on the Web, but the following are the methods that are useful for testing on CentOS.
The Java code is as follows: New Java.awt.Font ("Song Body", font.bold,13);
1, copy SIMSUN.TTC from windows (some say suffix ttf, no test), copy to/usr/share/fonts, you can create a new folder, such as I created a Chinese, that is, the path is/user/share/ Fonts/chinese
2, upload SIMSUN.TTC to/usr/share/fonts/chinese, execute chmod 777 SIMSUN.TTC (Modify Execute permission)
3, execute FC-CACHE-FV under/usr/share/fonts/chinese path, install font to System
4, execution fc-list can see the fonts that have been installed, and can see the fonts installed.
5, restart Tomcat.
The previous idea has been to use the Java.awt.Font public static Font createfont (int fontformat,file fontfile) method to do, That is, the introduction of a TTF file (renamed SIMSUN.TTC to Simsun.ttf, this place must be a TTF suffix or error), because this is the API code level implementation, without altering the server environment, but has been unsuccessful
1. Download the font file (*.ttf file) you want to install from your native C:\Windows\Fonts copy or network to the/usr/share/fonts/chinese/truetype directory (if you do not have this directory on your system, you mkdir create it yourself , or rename it to the folder name you like)
2, modify the permissions of the font file, so that users other than the root user can also use
# Cd/usr/share/fonts/chinese/truetype
# chmod 755 *.ttf
3. Create Font Cache
# Mkfontscale (if prompted Mkfontscale:command not found, you need to install it yourself # Yum install Mkfontscale)
# Mkfontdir
# FC-CACHE-FV (if prompted Fc-cache:command not found, you need to install # Yum installs Fontconfig)
4. Restart the computer
# reboot
Java Jdk-awt.font in CentOS on the problem of Chinese characters, install Chinese fonts