public static Typeface load ( final AssetManager assetManager , final String filePath ) { synchronized ( sCachedFonts ) { try { if ( ! sCachedFonts . containsKey ( filePath ) ) { final Typeface typeface = Typeface . createFromAsset ( assetManager , filePath ) ; sCachedFonts . put ( filePath , typeface ) ; return typeface ; } } catch ( Exception e ) { Log . w ( "Calligraphy" , "Can't create asset from " + filePath + ". Make sure you have passed in the correct path and file name." , e ) ; sCachedFonts . put ( filePath , null ) ; return null ; } return sCachedFonts . get ( filePath ) ; } }
A helper loading a custom font .