1

I use the following code,

TextView as;
as=(TextView)fragmentView.findViewById(R.id.e1_name);
Typeface font = Typeface.createFromAsset(getActivity().getAssets(),"fonts/wt071.ttf ");
        as.setTypeface(font);

Result Error

01-13 13:45:32.587  22738-22738/cytech.example.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: cytech.example.app, PID: 22738
java.lang.RuntimeException: native typeface cannot be made
        at android.graphics.Typeface.<init>(Typeface.java:175)
        at android.graphics.Typeface.createFromAsset(Typeface.java:149)
        at cytech.example.app.e.fg_e1.onCreateView(fg_e1.java:58)
        at android.app.Fragment.performCreateView(Fragment.java:1700)
        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
        at android.app.BackStackRecord.run(BackStackRecord.java:684)
        at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447)
        at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
        at android.os.Handler.handleCallback(Handler.java:733)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5017)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
        at dalvik.system.NativeStart.main(Native Method)

Is TTF not supported in android?

I tried a lot of Chinese TTF and it is not working.

Is there any way to solve Or Where can I find a list of supported

  • In my case `Typeface font = Typeface.createFromAsset(context.getAssets(), "customfont.ttf");` works. Please post the full error log. It may be a problem like "file/asset not found". And please try another font, e.g. Verdana definitely works. (First make sure it works for English, then see what may be done about Chinese.) And... when resources change, Eclipse requires a clean before a rebuild (it's a bug). – 18446744073709551615 Jan 13 '14 at 06:03
  • Reason for native not support -Check this link i think helpful http://stackoverflow.com/questions/7531856/issue-when-using-a-custom-font-native-typeface-cannot-be-made – Sanket990 Jan 13 '14 at 06:06
  • Hmmm, interesting: `private Typeface(int ni) { if (0 == ni) { throw new RuntimeException("native typeface cannot be made"); } native_instance = ni; }` – 18446744073709551615 Jan 13 '14 at 06:11

1 Answers1

3

Try this.. Your giving space after .ttf like "fonts/wt071.ttf " remove that and try

Typeface font = Typeface.createFromAsset(getActivity().getAssets(),"fonts/wt071.ttf");
as.setTypeface(font);
Hariharan
  • 24,741
  • 6
  • 50
  • 54