In linux, text images are displayed as garbled boxes at the front-end. windows is normal. Img. setFont (newFont (, Font. BOLD, 20); before entering the image, you must set the font, and the font must support Chinese characters. otherwise, garbled characters, boxes, question marks, and so on will appear. BufferedImage images created in memory call services
In linux, text images are displayed as garbled boxes at the front-end. windows is normal.
Img. setFont (new Font ("", Font. BOLD, 20 ));
Before entering the image, you must set a font that supports Chinese characters. otherwise, garbled characters, boxes, question marks, and so on may occur.
The image created by BufferedImage in the memory calls the server-side font, so in the img. drawString (str, x, y); if the server cannot find the corresponding Chinese font, it cannot recognize it, finally, the Chinese characters written into the image become garbled characters, boxes, question marks, and so on.
There are two ways to add Chinese support for the server:
The first method is to add the system Chinese font ():
Root @ dragon-virtual-machine :~ # Cd/usr/share/fonts
Root @ dragon-virtual-machine:/usr/share/fonts # mkdir winFonts
Root @ dragon-virtual-machine:/usr/share/fonts # cp/home/dragon/Desktop/simsun. ttc winFonts
Root @ dragon-virtual-machine:/usr/share/fonts # cd winFonts
Root @ dragon-virtual-machine:/usr/share/fonts/winFonts # mkfontdir
Root @ dragon-virtual-machine:/usr/share/fonts/winFonts # mkfontscale
Method 2: Add the jre Chinese font ():
Root @ dragon-virtual-machine :~ # Cd/usr/lib/jvm/java-6-sun/jre/lib/fonts
Root @ dragon-virtual-machine:/usr/lib/jvm/java-6-sun/jre/lib/fonts # cp/home/dragon/Desktop/simsun. ttc.
The modification takes effect only after the server is restarted.