Using of custom typeface for drawing on canvas Java Android
I have a custom typeface which I have loaded in Typeface object with Typeface.createFromAsset(...). I need to drawing 1 symbom from this typeface with char-code 37 on canvas. I use this code:
String s=String.valueOf(((char)37));
Paint paint=new Paint();
paint.setTypeface(mNoteTypeface);
paint.setTextSize(30);
canvas.draw开发者_JAVA百科Text(s, 20, 20, paint);
But result doesn't be good. I have the program for viewing fonts and one showed me that: http://imagepost.ru/?v=qzvcgsbbxkldahdxuptuuvuyyugqlx.jpg
Help me to create a code, I'm very upset.
code shown is correct. Make sure mNoteTypeface
contains custom font. Look for:
- font file is in
assets\fonts
folder of project. - font files are case sensitive,
"fonts\deco.ttf"
will not work for"Deco.ttf"
file:
paint.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/Deco.ttf"));
精彩评论