compat/src/main/java/androidx/core/graphics/TypefaceCompatBaseImpl.java
protected Typeface createFromInputStream(Context context, InputStream is) {
        final File tmpFile = TypefaceCompatUtil.getTempFile(context);
        if (tmpFile == null) {
            return null;
        }
        try {
            if (!TypefaceCompatUtil.copyToFile(tmpFile, is)) {
                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();
        }
    }
// Caller must close the stream.
Caller must close the stream.
Caller must close the stream .
protected Typeface createFromInputStream(Context context, InputStream is) {
        final File tmpFile = TypefaceCompatUtil.getTempFile(context);
        if (tmpFile == null) {
            return null;
        }
        try {
            if (!TypefaceCompatUtil.copyToFile(tmpFile, is)) {
                return null;
            }
            return Typeface.createFromFile(tmpFile.getPath());
        } catch (RuntimeException e) {
            return null;
        } finally {
            tmpFile.delete();
        }
    }
protected Typeface createFromInputStream ( Context context , InputStream is ) { final File tmpFile = TypefaceCompatUtil . getTempFile ( context ) ; if ( tmpFile == null ) { return null ; } try { if ( ! TypefaceCompatUtil . copyToFile ( tmpFile , is ) ) { return null ; } return Typeface . createFromFile ( tmpFile . getPath ( ) ) ; } catch ( RuntimeException e ) { return null ; } finally { tmpFile . delete ( ) ; } }
Caller must close the stream.
Caller must close the stream .
// 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.