When I am drawing Text with custom font(basically icon ex: WINGDING.ttf) using drawText is showing simple text as provided.
Steps I followed:
1. Added font file to Assets folder
2. Set paint with the added font
3. drawing text with the paint
To draw text I used the corresponding English character
canvas.drawText("p",0,1, x, y, myPaint);
This displays as p on app
use this way if you have assets/fonts:
private Paint myPaint= new Paint(Paint.ANTI_ALIAS_FLAG);
private Typeface mFace;
mFace = Typeface.createFromAsset(getContext().getAssets(),"fonts/WINGDING.ttf");
myPaint.setTextSize(32);
myPaint.setTypeface(mFace);
canvas.drawText("test test",0,1, x, y, myPaint);
//canvas.drawText("test test", 10, 200, myPaint);
example:
private static class MyView extends View
{
private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Typeface mFace;
public MyView(Context context)
{
super(context);
mFace = Typeface.createFromAsset(getContext().getAssets(),"fonts/WINGDING.ttf");
mPaint.setTextSize(32);
}
@Override protected void onDraw(Canvas canvas)
{
mPaint.setTypeface(mFace);
canvas.drawText("p p p p", 10, 200, mPaint);
}
}
I found this SO post that linked this font converter, http://www.freefontconverter.com.
I took my .ttf font that would not render and converted it to .ttf again (so .ttf to .ttf) and now it works! I hope this helps!