By the server to the picture text synthesis, the previous paragraph is good. Server for Linux
This side of the request to use Fangzheng font, decisive garbled, play a slide box.
The most important thing is to troubleshoot the problem. The first thought is because the font name for Chinese characters, the front-end to the server is not garbled. I was sent by post, this should not, and after the backstage, really is not the reason. Search engine for help.
Keywords: "DrawString garbled" a search, there are several posts, locked on the server no font on this clue.
First, a program is written to get the fonts supported by the host.
Import java.awt.GraphicsEnvironment;
public class GetFont {public
static void Main (string[] args) {
string[] fontnames= Graphicsenvironment.getlocalgraphicsenvironment ().
Getavailablefontfamilynames ();
for (String fontname:fontnames) {
System.out.println (fontname);
}
}
}
Upload to the server compiled to perform a bit, only a few logical fonts, no physical fonts. It should be, and then write a test program to upload to the server first
Import Java.awt.Color;
Import Java.awt.Font;
Import Java.awt.Graphics;
Import Java.awt.Graphics2D;
Import Java.awt.Image;
Import java.awt.RenderingHints;
Import Java.awt.image.BufferedImage;
Import Java.io.File;
Import java.io.IOException;
Import Javax.imageio.ImageIO; public class Testfont {public static void main (string[] args) {bufferedimage bi = new BufferedImage (i, Buffere
DIMAGE.TYPE_INT_RGB);
Graphics g = bi.getgraphics ();
Color color = G.getcolor ();
SYSTEM.OUT.PRINTLN (color);
G.fillrect (0, 0, 800, 600);
((GRAPHICS2D) g). Setrenderinghint (renderinghints.key_antialiasing,renderinghints.value_antialias_on);
G.setfont (New Font ("Founder Blackbody Simplified", Font.plain, 30));
G.setcolor (Color.Black);
g.DrawString ("difficult to meet and difficult to do", 200, 50);
G.setfont (New Font ("Microsoft Ya Hei", Font.Bold, 30));
G.setcolor (Color.Black);
g.DrawString ("difficult to meet and difficult to do", 200, 85);
G.setfont (New Font ("Founder Big Black Simplified", Font.plain, 30));
G.setcolor (Color.Black);
g.DrawString ("difficult to meet and difficult to do", 200, 120);
G.dispose (); Bi.flusH ();
New name String fname = "abc";
try {imageio.write (bi, "JPG", New File ("/" + fname + ". jpg"));
catch (IOException e) {//TODO auto-generated catch block E.printstacktrace ();
//Save it in C:/imagesort/targetpic}}
Are founder bold, Microsoft Ya black, founder Big Black. Compiled directly on the server, there is no doubt that the generated picture is still garbled.
Check it out, understand that the JVM support font is under the%java_home%/jvm/lib/font, ftp up. Don't know the path direct echo $JAVA _home look at that.
Note that Windows C:/windows/font folders are installed fonts, can not directly FTP upload, copy out in upload to Linux. This font is only Java support, but there is no need to support Linux as a server, other programs do not have a graphical interface.
Run the test again, this time the print is right
Problem solving