Question

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

Was it helpful?

Solution

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top