Search code examples
androidfontsandroid-fonts

Android - How to use custom font file containing multiple fonts


I am not very experienced with fonts, so this issue might be due to my ignorance.

I have a font file, Futura.tcc. In code I have the following:

Typeface face=Typeface.createFromAsset(am, "fonts/Futura.ttc");
editText.setTypeface(face);

This works for the basic Futura font. But, the file my client sent contains multiple font sub-types (if that is the proper term). I know setTypeFace() accepts a second parameter of type int that is the style. But, passing in various values does nothing.

If this file contains a font called 'Futura Light', how would I tell it to use that font, rather than just the regular Futura font?

Thanks!


Solution

  • You need to find the ttc/ttf for "Futura Light" and drop it in the assets folder. Usually each "sub font" have their own separate file.

    Then you just do:

    Typeface face = Typeface.createFromAsset(getAssets(), "futura_light.ttf");
    editText.setTypeface(face);
    

    EDIT:

    I actually had it on my computer so I uploaded it for you: Download Here