The last line above, I try to set font name, but it don't work. (this font has been verified for Chinese charactors, i.e, in the title display)
You may notice that the 'setMonthNames' only act at the first chart, but not every one.
Actually I see the Chinese month name as a small square --- every one for a Chinese charactor.
Thanks for your fast reply.
I noticed the legendbox code in tracking function, but I don't understand the grammar of <*block*><*font*>.... I've tried <*font,name='simhei.ttf *> but has no effect.
In SetTitle function, we can set the font for the chart.
But LegendBox has been set to 'transparent', in this case, anyone have to use the <*font=xxx*> to realize the Chinese display in legendbox of every sub chart?
The LegendBox can be included as part of the chart, just like the candlesticks and axes are part of the chart. The legend items can also be drawn in the dynamic layer. The dynamic layer is used for things that can change when the mouse moves. For your chart, the legend items can change when the mouse moves, so they are drawn in the dynamic layer. To avoid duplication, we need to disable the LegendBox in the chart. This is by setting the LegendBox in the chart to transparent.
// The legend begins with the date label, then the ohlcLegend (if any), and then the
// entries for the indicators.
legendText << "<*block,valign=top,maxWidth=" << (plotArea->getWidth() - 5) << "*><*font=simhei.ttf*>[" << c->xAxis()->getFormattedLabel(xValue, "mmm dd, yyyy") << "]<*/font*>" << ohlcLegend.str();
and the above works normally in my case.
Note that you must set the month names to the object that formats the month labels. In the above code, the month labels are created using the object "c":
At now the children chart work fine.
You need to set month_name for every children chart.
Also the xaxis style: (in drawchart function)
// Create a FinanceChart object of width 640 pixels
FinanceChart *c = new FinanceChart(VIEW_WIDTH);
c->setXAxisStyle("simhei.ttf", 8,0x111111,0 ); //james++
Because the xasix use the default font aria.
But thers is a strange issue: some of the xaxis name (Chinese) goes wrong.
The legendbox of children chart works fine all the time.
In some cases, the axis labels use two different fonts - a regular font and a bold font. The setXAxisStyle can be change one of the font, which is the normal font. So the bold labels are still using the old font.
I think for the purpose of supporting Chinese, it is better to use BaseChart.setDefaultFonts on the last subchart (the x-axis labels are on the last chart) to set the default fonts. It is like:
// Assume this is the last indicator
XYChart* lastChart = addIndicator(....);
// Set the default regular font to simhei.ttf, and the default bold font to artificially boldened simhei.ttf
lastChart->setDefaultFont("simhei.ttf", "simhei.ttf bold");