jfreechart中文显示成方块
原来,从1.0.14开始,加了个 source\org\jfree\chart\StandardChartTheme.java
里边写死字体都用 Tahoma , 没找到这个字体, 生成的图中,中文就变成方块了。
解决办法:
要么在机器上安装Tahoma字体,要么修改代码,将字体该回去。
将 新采用的Tahoma字体改为原来的 SansSerif
第一处:
source\org\jfree\chart\StandardChartTheme.java
函数 public StandardChartTheme(String name, boolean shadow) { 中
将
this.extraLargeFont = new Font("Tahoma", Font.BOLD, 20);
this.largeFont = new Font("Tahoma", Font.BOLD, 14);
this.regularFont = new Font("Tahoma", Font.PLAIN, 12);
this.smallFont = new Font("Tahoma", Font.PLAIN, 10);
this.extraLargeFont = new Font("SansSerif", Font.BOLD, 20);
this.largeFont = new Font("SansSerif", Font.BOLD, 14);
this.regularFont = new Font("SansSerif", Font.PLAIN, 12);
this.smallFont = new Font("SansSerif", Font.PLAIN, 10);
this.extraLargeFont = new Font("Tahoma", Font.BOLD, 20);
this.largeFont = new Font("Tahoma", Font.BOLD, 14);
this.regularFont = new Font("Tahoma", Font.PLAIN, 12);
this.smallFont = new Font("Tahoma", Font.PLAIN, 10);
改为
this.largeFont = new Font("SansSerif", Font.BOLD, 14);
this.regularFont = new Font("SansSerif", Font.PLAIN, 12);
this.smallFont = new Font("SansSerif", Font.PLAIN, 10);
第二处:source\org\jfree\chart\plot\Crosshair.java 中也用到了Tahoma字体,最好改掉吧。