0

I've Read a lot of articles and stack Questions for over 4 hours, when i use this method to define a custom font i don't get any error but the font doesn't change?

My mainactivity.java is listed below

public class MyActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my);
        TextView textView=(TextView)findViewById(R.id.myid);
        Typeface typeface=Typeface.createFromAsset(getAssets(),"assets/fonts/Face Your  Fears.ttf");
        textView.setTypeface(typeface,Typeface.BOLD);
    }
rds
  • 26,253
  • 19
  • 107
  • 134
Sainath S.R
  • 3,074
  • 9
  • 41
  • 72

1 Answers1

0

getAssets() gives path for your assets folder,so no need to write assets again

in "assets/fonts/Face Your Fears.ttf" Try changing

Typeface typeface=Typeface.createFromAsset(getAssets(),"assets/fonts/Face Your  Fears.ttf");

to

Typeface typeface=Typeface.createFromAsset(getAssets(),"fonts/Face Your  Fears.ttf");

The complete example for same ttf file implementation is here Android Using External Fonts

Giru Bhai
  • 14,370
  • 5
  • 46
  • 74