我想在项目中使用我的字体并在android studio中编写此代码:
Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/behzadd.ttf");
text.setTypeface(tf);
text.setText("بهزاد");
我将behzadd.ttf
字体文件复制到此路径中:
res/fonts/behzadd.ttf
但是当我运行项目时,我收到了这个错误:
Caused by: java.lang.RuntimeException: native typeface cannot be made
at android.graphics.Typeface.<init>(Typeface.java:147)
我该怎么解决?
答案 0 :(得分:1)
将您的字体放在assets
文件夹中,路径为:assets/fonts/behzadd.ttf