# ResourcesCompat.FontCallback

# ResourcesCompat.FontCallback

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/content/res/ResourcesCompat.java+class:androidx.core.content.res.ResourcesCompat.FontCallback)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/content/res/ResourcesCompat.FontCallback "View this page in Java")

<br />

```
abstract class ResourcesCompat.FontCallback
```

<br />

*** ** * ** ***

Interface used to receive asynchronous font fetching events.

## Summary

|                                                         ### Public constructors                                                          |
|------------------------------------------------------------------------------------------------------------------------------------------|
| [FontCallback](https://developer.android.com/reference/kotlin/androidx/core/content/res/ResourcesCompat.FontCallback#FontCallback())`()` |

|                                   ### Public functions                                   |
|------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `abstract `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onFontRetrievalFailed](https://developer.android.com/reference/kotlin/androidx/core/content/res/ResourcesCompat.FontCallback#onFontRetrievalFailed(int))`(reason: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Called when an asynchronous font failed to load.                          |
| `abstract `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onFontRetrieved](https://developer.android.com/reference/kotlin/androidx/core/content/res/ResourcesCompat.FontCallback#onFontRetrieved(android.graphics.Typeface))`(typeface: `[Typeface](https://developer.android.com/reference/android/graphics/Typeface.html)`)` Called when an asynchronous font was finished loading. |

## Public constructors

### FontCallback

Added in 1.1.0  

```
FontCallback()
```  

## Public functions

### onFontRetrievalFailed

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
abstract fun onFontRetrievalFailed(reason: Int): Unit
```

Called when an asynchronous font failed to load.  

|                                      Parameters                                       |
|---------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `reason: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The reason the font failed to load. One of[FAIL_REASON_PROVIDER_NOT_FOUND](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_PROVIDER_NOT_FOUND()),[FAIL_REASON_WRONG_CERTIFICATES](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_WRONG_CERTIFICATES()),[FAIL_REASON_FONT_LOAD_ERROR](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_FONT_LOAD_ERROR()),[FAIL_REASON_SECURITY_VIOLATION](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_SECURITY_VIOLATION()),[FAIL_REASON_FONT_NOT_FOUND](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_FONT_NOT_FOUND()),[FAIL_REASON_FONT_UNAVAILABLE](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_FONT_UNAVAILABLE())or[FAIL_REASON_MALFORMED_QUERY](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_MALFORMED_QUERY()). |

### onFontRetrieved

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
abstract fun onFontRetrieved(typeface: Typeface): Unit
```

Called when an asynchronous font was finished loading.  

|                                           Parameters                                           |
|------------------------------------------------------------------------------------------------|---------------------------|
| `typeface: `[Typeface](https://developer.android.com/reference/android/graphics/Typeface.html) | The font that was loaded. |