Android - How To Set Custom Typeface In Paint Object?
I want to use a Paint to draw something and here is my code : Paint mMonthTitlePaint = new Paint(); mMonthTitlePaint.setFakeBoldText(true); mMonthTitlePaint.setAntiAlia
Solution 1:
try this:
Typefacetf=Typeface.createFromAsset(getAssets(),"fonts/iran_sans_.ttf");
Paintpaint=newPaint();
paint.setTypeface(tf);
canvas.drawText("Sample text",0,0,paint);
you can also use the Textpaint class instead of Paint
TextPainttextPaint=newTextPaint();
textPaint.setTextSize(20);
textPaint.setTextAlign(Paint.Align.LEFT);
textPaint.setColor(Color.WHITE);
Typefacetf=Typeface.createFromAsset(getAssets(),"fonts/iran_sans_.ttf");
textPaint.setTypeface(tf);
see this: https://developer.android.com/reference/android/text/TextPaint.html
Post a Comment for "Android - How To Set Custom Typeface In Paint Object?"