Java and Chinese fonts

Source: Internet
Author: User

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:

  
 
  1. Font font = Font.createFont(Font.TRUETYPE_FONT, File);
  2. GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
  3. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.