jfreechart set Chinese font

When using jfreechart, I encountered the problem of Chinese garbled characters, and several methods for setting font provided on the Internet were unsuccessful.

PS: It can always be displayed correctly on my local machine, but once it is on the server (linux), it will not work. I use jfreechart to generate pictures and apply them in html.

The final solution was to set a custom font:

Font ft = Font.createFont(Font.TRUETYPE_FONT, new File("仿宋_GB2312.ttf"));

ft = ft.deriveFont(Font.PLAIN,16);

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326640862&siteId=291194637