0

I created an "assets" folder and I created a "fonts" folder inside. The custom font is called "dshift.tff". I have my main screen running in a loop with updates and need to create a display with external font.

public void drawText(Canvas canvas) {
    Paint paint = new Paint();
    //Tell me what to do here please
}

This method is getting called by

public void draw(Canvas canvas)
{
    super.draw(canvas);
    //... rest of my code with no more declarations
}
  • did you check this question? http://stackoverflow.com/questions/6042977/android-set-custom-font-to-a-paint – Rittel Sep 16 '15 at 05:40

1 Answers1

0

Create the typeface elsewhere such that it is accessible in your drawText, as you do not wish to do this every time during rendering -

   Typeface type = Typeface.createFromAsset(getAssets(),"fonts/Kokila.ttf"); 

In your drawText, create a Paint object and set its typeface

   Paint paint = new Paint();
   paint.setTypeface (type);

Then draw text using the paint object.

headuck
  • 2,763
  • 16
  • 19