使用自定义字体的画布上的Java的Android画 [英] Using of custom typeface for drawing on canvas Java Android
问题描述
我有我已加载的字样对象Typeface.createFromAsset(...)的自定义字体。我需要从这个字体用在画布上煤焦code 37绘图1 symbom。我用这个code:
的String =将String.valueOf(((char)的37));
涂料粉刷=新的油漆();
paint.setTypeface(mNoteTypeface);
paint.setTextSize(30);
canvas.drawText(S,20,20,油漆);
但结果并不好。我有计划观看字体和一种让我明白了: http://imagepost.ru/?v=qzvcgsbbxkldahdxuptuuvuyyugqlx.jpg
帮助我创造了code,我很不高兴。
code所示是正确的。确保 mNoteTypeface
包含自定义字体。寻找:
- 在字体文件是在
资产\字体
项目的文件夹中。 - 字体文件是大小写敏感的,
字型\ deco.ttf
不会为<$ C $ C>Deco.ttf工作文件:
paint.setTypeface(Typeface.createFromAsset(getAssets(), 字体/ Deco.ttf));
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.drawText(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"));
这篇关于使用自定义字体的画布上的Java的Android画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!