compat/src/main/java/androidx/core/graphics/TypefaceCompatBaseImpl.java
@Nullable
    public Typeface createFromResourcesFontFile(
            Context context, Resources resources, int id, String path, int style) {
        final File tmpFile = TypefaceCompatUtil.getTempFile(context);
        if (tmpFile == null) {
            return null;
        }
        try {
            if (!TypefaceCompatUtil.copyToFile(tmpFile, resources, id)) {
                return null;
            }
            return Typeface.createFromFile(tmpFile.getPath());
        } catch (RuntimeException e) {
            // This was thrown from Typeface.createFromFile when a Typeface could not be loaded.
            // such as due to an invalid ttf or unreadable file. We don't want to throw that
            // exception anymore.
            return null;
        } finally {
            tmpFile.delete();
        }
    }
/**
     * Used by Resources to load a font resource of type font file.
     */
Used by Resources to load a font resource of type font file.
Used by Resources to load a font resource of type font file .
@Nullable
    public Typeface createFromResourcesFontFile(
            Context context, Resources resources, int id, String path, int style) {
        final File tmpFile = TypefaceCompatUtil.getTempFile(context);
        if (tmpFile == null) {
            return null;
        }
        try {
            if (!TypefaceCompatUtil.copyToFile(tmpFile, resources, id)) {
                return null;
            }
            return Typeface.createFromFile(tmpFile.getPath());
        } catch (RuntimeException e) {
            return null;
        } finally {
            tmpFile.delete();
        }
    }
@ Nullable public Typeface createFromResourcesFontFile ( Context context , Resources resources , int id , String path , int style ) { final File tmpFile = TypefaceCompatUtil . getTempFile ( context ) ; if ( tmpFile == null ) { return null ; } try { if ( ! TypefaceCompatUtil . copyToFile ( tmpFile , resources , id ) ) { return null ; } return Typeface . createFromFile ( tmpFile . getPath ( ) ) ; } catch ( RuntimeException e ) { return null ; } finally { tmpFile . delete ( ) ; } }
Used by Resources to load a font resource of type font file.
Used by Resources to load a font resource of type font file .
// This was thrown from Typeface.createFromFile when a Typeface could not be loaded. // such as due to an invalid ttf or unreadable file. We don't want to throw that // exception anymore.