アセット/フォントがある場合は、次のように使用します。
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);
例:
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);
}
}