Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set my own typeface in AChartEngine renderer?

As you might know, you can use your own font in your specific android UI like following:

    myNewFace = Typeface.createFromAsset(getAssets(), "fonts/myown.ttf");
    TextView label = (TextView) row.findViewById(R.id.tvTitleFunc);
    label.setTypeface(myNewFace);

Now, I need to apply this font to AChartEngine but can't figure out how.

I can see DefaultRenderer has a method

 setTextTypeface(java.lang.String typefaceName, int style) 

But this method can't be used with custom font. Does anybody have an idea how to do this?

UPDATE

To answer my own question, there is simply no way to set custom font in achartengine without changing source code. So I added simple methods setTypeface and getTypeface to DefaultRenderer and changed a couple of lines of code in XYChart accordingly. Voila, it's now working.

like image 453
Tae-Sung Shin Avatar asked Nov 14 '22 14:11

Tae-Sung Shin


1 Answers

Maybe you can contribute the code to the AChartEngine community by creating a patch and adding it as an issue?

Update: There is a setTextTypeface() method that was recently added to DefaultRenderer that you can use for this.

like image 73
Dan D. Avatar answered Nov 16 '22 02:11

Dan D.