When using ChartDirector to create a trend chart that displays Chinese, it can be displayed normally under Windows. However, when placed in a Linux environment, it will be displayed as [square]. The solution is as follows:
Program:
The following is the quoted content: // Create a XYChart object of size 700 x 450 pixels // Set the plotarea at (30, 20) and of size 200 x 200 pixels // Add a line chart layer using the given data // Display 1 out of 3 labels on the x-axis. c.setBackground(0xFFFF80, 0x0, 1); c.addLegend(400, 35, false, "simsun.ttc", 10).setBackground(0xFFFF80); |
Among them [simsun.ttc] is the Chinese font name used in this program.
Cause of the problem:
There is no [simsun.ttc] font file under Linux.
Problem solving:
Copy the [simsun.ttc] file from the Windows system to the JavaSource of the project, repackage it, re-publish it, and restart the server.
Or copy the [simsun.ttc] file from the Windows system to the project's [Project Directory]/WEB-INF/classes, and restart the Server.