I want to use a Paint
to draw something and here is my code :
Paint mMonthTitlePaint = new Paint();
mMonthTitlePaint.setFakeBoldText(true);
try this:
Typeface tf =Typeface.createFromAsset(getAssets(),"fonts/iran_sans_.ttf");
Paint paint = new Paint();
paint.setTypeface(tf);
canvas.drawText("Sample text",0,0,paint);
you can also use the Textpaint
class instead of Paint
TextPaint textPaint = new TextPaint();
textPaint.setTextSize(20);
textPaint.setTextAlign(Paint.Align.LEFT);
textPaint.setColor(Color.WHITE);
Typeface tf =Typeface.createFromAsset(getAssets(),"fonts/iran_sans_.ttf");
textPaint.setTypeface(tf);
see this: https://developer.android.com/reference/android/text/TextPaint.html