Japanese Font appears garbled on IBM AIX

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
YI
Posts: 3
Joined: Thu Jul 31, 2008 7:17 am

Japanese Font appears garbled on IBM AIX

Post by YI » Thu Jul 31, 2008 7:29 am

HI,

We are using jar version jfreechart-1.0.0-rc1.jar on IBM AIX . But the font is appearing garbled in japanese session . Pls let us know how to solve the issue.
Is this a font issue on AIX , because its working fine on windows setup . We are using the method createTimeSeriesChart to generate chart.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu Jul 31, 2008 3:15 pm

I'd suggest trying to write a small test application that doesn't use JFreeChart, to draw some text using Java2D in the font that is giving you the trouble. You might find it is a bug in your Java2D implementation.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

YI
Posts: 3
Joined: Thu Jul 31, 2008 7:17 am

Post by YI » Fri Aug 01, 2008 8:04 am

Hi David,
Thanks for your reply.

Actually I am not specifying any particular font in my code. Below is the Jfree chart code I am using.

Code: Select all

private JFreeChart createTimeSeriesChart ( )
	{
		TimeSeries series1 = new TimeSeries("日興・ラサール・グローバル ファンド (毎月分配型)", Day.class);
		TimeSeries series2 = new TimeSeries("プロフェッショナル・ステージ", Day.class);
		TimeSeries series3 = new TimeSeries("アライアンス バーンスタイン ヨーロピアン グロース ポートフォリオ", Day.class);

		

		TimeSeriesCollection dataset1 = new TimeSeriesCollection();
		dataset1.addSeries(series1);
		dataset1.addSeries(series2);
		dataset1.addSeries(series3);
		
		XYDataset data = dataset1;
		JFreeChart chart = ChartFactory.createTimeSeriesChart("", "騰落率", "騰落率", data, false, false, false);
		
		return chart;

	}

	public JFreeChart renderChart ( JFreeChart chart )
	{

		chart.setBackgroundPaint(PaintUtilities.stringToColor("white"));
		chart.getXYPlot().setBackgroundPaint(Color.lightGray);
		chart.getXYPlot().setDomainGridlinePaint(Color.white);
		chart.getXYPlot().setRangeGridlinePaint(Color.white);
		chart.getXYPlot().setDomainGridlinesVisible(true);
		chart.getXYPlot().setDomainCrosshairVisible(true);
		final DateAxis axis = (DateAxis) chart.getXYPlot().getDomainAxis();

		axis.setVerticalTickLabels(true);
		axis.setDateFormatOverride(new SimpleDateFormat("dd'/'MMM'/'yyyy"));
		chart.getLegend().setBorder(3.0, 3.0, 3.0, 3.0);
		chart.getLegend().setWidth(50);
		SimpleDateFormat sdf = new SimpleDateFormat("dd'/'MMM'/'yyyy");

		StandardXYToolTipGenerator ttg = new StandardXYToolTipGenerator("{2}({1})", sdf, NumberFormat.getNumberInstance());

		XYLineAndShapeRenderer lineRenderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer();

		lineRenderer.setStroke(new BasicStroke(1.0f));

		lineRenderer.setToolTipGenerator(ttg);

		chart.getXYPlot().setRenderer(lineRenderer);

		return chart;
	}
]

The japanese text given in constructor TimeSeries() is not being displayed properly as Legend Text and the japanese text in createTimeSeriesChart() is not being displayed as Axis label. This code is working fine on Windows machine. But we are facing this problem on AIX machine and WebSphere Server. If it is a Java2D problem then it should not work on Windows machine also as per my knowledge. Please suggest.

Taqua
JFreeReport Project Leader
Posts: 698
Joined: Fri Mar 14, 2003 3:34 pm
Contact:

Post by Taqua » Fri Aug 01, 2008 9:08 am

If you define no font explicitly, then the Chart will use one of the logical fonts. JDK contains a mapping between logical font names and physical font names, so for rendering text, the JDK then looks up the appropriate physical to be used.

Therefore the text-display heavily depends on whether your *physical fonts* support the characters you want to display. Unless you install a international version of the JDK/JRE, you will have no guarantee that non-western characters display correctly. (You know, from a western point of view, there are only western people living in the modern world and some billions of minorities with funny script-systems who better learn English ;) )

So if you can, install a international JDK/JRE. Otherwise, you will have to install your own fonts and/or edit the fonts.properties file of your JDK as outlined in the JDK readme file:
http://java.sun.com/j2se/1.3/docs/guide ... tml#adding

If you only add fonts, without editing the properties-file, you have to tell JFreeChart to use the new fonts instead of the default ones.

BTW: The AWT/Java2D is just a thin layer above the native system. Java2D does a lot to hide the differences in the graphic systems from you, but at some point, these differences do shine through.

YI
Posts: 3
Joined: Thu Jul 31, 2008 7:17 am

Post by YI » Mon Aug 04, 2008 6:41 am

Hi,
Thanks for reply.
I can't edit the font properties file.But I can add a new font that supports japanese text. Can you please tell me how can i add the font on AIX machine and how to tell JFree Chart to use new fonts instead of the default ones?

Thanks a lot in advance.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Mon Aug 04, 2008 3:57 pm

There's no single place to specify the font used by JFreeChart. You need to look for all the setXXXFont() methods throughout the API. In the future this may change, since it would be nice to be able to specify one font and have it propogate through the chart structure...but that's in the future, not now.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked