@ Override public Typeface resolveFont ( String fontFamily , int fontWeight , String fontStyle ) { Log . i ( TAG , "resolveFont(" + fontFamily + "," + fontWeight + "," + fontStyle + ")" ) ; // Try font name with suffix ".ttf" try { return Typeface . createFromAsset ( assetManager , fontFamily + ".ttf" ) ; } catch ( RuntimeException ignored ) { } // That failed, so try ".otf" try { return Typeface . createFromAsset ( assetManager , fontFamily + ".otf" ) ; } catch ( RuntimeException e ) { return null ; } }
Attempt to find the specified font in the assets folder and return a Typeface object . For the font name Foo first the file Foo . ttf will be tried and if that fails Foo . otf .