开发者

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:

  1. font file is in assets\fonts folder of project.
  2. font files are case sensitive, "fonts\deco.ttf" will not work for "Deco.ttf" file:

paint.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/Deco.ttf"));

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜