Java Web program Linux Environment, how to do not modify the JDK/JRE configuration to perform Chinese?
You can register fonts in the running environment, if there is only one place to use, can be used in the place to register once, if there are multiple places in the system to use, you can customize a
ServletContextListener, which is loaded after the container initializes the app.
Load code:
Font font = Font.createFont(Font.TRUETYPE_FONT, File);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.registerFont(font);
What about Java support for fonts?
Java6 previously only supported TYPE1 font and TTF font. The OTF format is supported later. But my environment is JDK8, loading the source blackbody the font of the OTF format is normal, but the java2d drawing is blank.
Using the tool to convert OTF to TTF font will display normally.
What are the considerations for Java Chinese fonts?
new FontBe sure to specify the correct name, for example, our program uses the source Blackbody SC Bold, then the correct name is Source Han Sans SC Bold . If the font is incorrectly written, it is rolled back to a Dialog logical font named. In support of the Chinese operating system (OSX, Windows) shows no problem, to the Linux environment, shown as Tofu block, pit dead.
From for notes (Wiz)
Java and Chinese fonts