How to change custom view font?

0

I have prepared one custom view, in custom view I have displayed alphabets. It is working fine, but in case of "g" it is displaying like this,

preview

I want to change like this "g". How to change it? Please help me. I used the following code for painting,

Paint mPaint=new Paint();
mPaint.setDither(true);
mPaint.setColor(0xFFFFFFFF);
mPaint.setTextSize(350);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStrokeWidth(10);


Typeface typeArial;
typeArial = Typeface.create("arial", Typeface.BOLD);
mPaint.setTypeface(typeArial);

In onDraw(),

 bmpCanvas.drawText("g",50, 230,mPaint);

Please help me...

android
android-canvas
asked on Stack Overflow Jan 24, 2012 by SuReSh PaTi • edited Mar 6, 2019 by appersiano

1 Answer

1

You can achieve it by setting programatically by down loading the text style and place in assets folder,for example to set custom font typeface as follows,try the same in you case for paint object.

 TextView txt = (TextView) findViewById(R.id.custom_font);
  Typeface font = Typeface.createFromAsset(getAssets(), "Helv Neue 67 Med Cond.ttf");
  txt.setTypeface(font);
answered on Stack Overflow Jan 24, 2012 by Senthil Mg

User contributions licensed under CC BY-SA 3.0