# FontsContractCompat.FontRequestCallback

# FontsContractCompat.FontRequestCallback

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/provider/FontsContractCompat.java+class:androidx.core.provider.FontsContractCompat.FontRequestCallback)  
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/provider/FontsContractCompat.FontRequestCallback "View this page in Java")


```
class FontsContractCompat.FontRequestCallback
```

<br />

*** ** * ** ***

Interface used to receive asynchronously fetched typefaces.

## Summary

|                                    ### Constants                                    |
|-------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [FAIL_REASON_FONT_LOAD_ERROR](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_FONT_LOAD_ERROR())` = -3` Constant returned by [onTypefaceRequestFailed](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)) signaling that the font returned by the provider was not loaded properly.                                            |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [FAIL_REASON_FONT_NOT_FOUND](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_FONT_NOT_FOUND())` = 1` Constant returned by [onTypefaceRequestFailed](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)) signaling that the font provider did not return any results for the given query.                                        |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [FAIL_REASON_FONT_UNAVAILABLE](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_FONT_UNAVAILABLE())` = 2` Constant returned by [onTypefaceRequestFailed](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)) signaling that the font provider found the queried font, but it is currently unavailable.                           |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [FAIL_REASON_MALFORMED_QUERY](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_MALFORMED_QUERY())` = 3` Constant returned by [onTypefaceRequestFailed](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)) signaling that the given query was not supported by the provider.                                                     |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [FAIL_REASON_PROVIDER_NOT_FOUND](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_PROVIDER_NOT_FOUND())` = -1` Constant returned by [onTypefaceRequestFailed](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)) signaling that the given provider was not found on the device.                                                 |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [FAIL_REASON_SECURITY_VIOLATION](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_SECURITY_VIOLATION())` = -4` Constant that signals that the font was not loaded due to security issues.                                                                                                                                                                                                                                |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [FAIL_REASON_WRONG_CERTIFICATES](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_WRONG_CERTIFICATES())` = -2` Constant returned by [onTypefaceRequestFailed](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)) signaling that the given provider must be authenticated and the given certificates do not match its signature. |

|                                                                    ### Public constructors                                                                     |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [FontRequestCallback](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FontRequestCallback())`()` |

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onTypefaceRequestFailed](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int))`(reason: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Called when a Typeface request done via [requestFont](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat#requestFont(android.content.Context,androidx.core.provider.FontRequest,androidx.core.provider.FontsContractCompat.FontRequestCallback,android.os.Handler)) fails.                               |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onTypefaceRetrieved](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRetrieved(android.graphics.Typeface))`(typeface: `[Typeface](https://developer.android.com/reference/android/graphics/Typeface.html)`!)` Called then a Typeface request done via [requestFont](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat#requestFont(android.content.Context,androidx.core.provider.FontRequest,androidx.core.provider.FontsContractCompat.FontRequestCallback,android.os.Handler)) is complete. |

## Constants

### FAIL_REASON_FONT_LOAD_ERROR

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

```
const val FAIL_REASON_FONT_LOAD_ERROR = -3: Int
```

Constant returned by [onTypefaceRequestFailed](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)) signaling that the font returned by the provider was not loaded properly.  

### FAIL_REASON_FONT_NOT_FOUND

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

```
const val FAIL_REASON_FONT_NOT_FOUND = 1: Int
```

Constant returned by [onTypefaceRequestFailed](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)) signaling that the font provider did not return any results for the given query.  

### FAIL_REASON_FONT_UNAVAILABLE

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

```
const val FAIL_REASON_FONT_UNAVAILABLE = 2: Int
```

Constant returned by [onTypefaceRequestFailed](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)) signaling that the font provider found the queried font, but it is currently unavailable.  

### FAIL_REASON_MALFORMED_QUERY

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

```
const val FAIL_REASON_MALFORMED_QUERY = 3: Int
```

Constant returned by [onTypefaceRequestFailed](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)) signaling that the given query was not supported by the provider.  

### FAIL_REASON_PROVIDER_NOT_FOUND

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

```
const val FAIL_REASON_PROVIDER_NOT_FOUND = -1: Int
```

Constant returned by [onTypefaceRequestFailed](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)) signaling that the given provider was not found on the device.  

### FAIL_REASON_SECURITY_VIOLATION

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

```
const val FAIL_REASON_SECURITY_VIOLATION = -4: Int
```

Constant that signals that the font was not loaded due to security issues. This usually means the font was attempted to load on a restricted context.  

### FAIL_REASON_WRONG_CERTIFICATES

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

```
const val FAIL_REASON_WRONG_CERTIFICATES = -2: Int
```

Constant returned by [onTypefaceRequestFailed](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)) signaling that the given provider must be authenticated and the given certificates do not match its signature.  

## Public constructors

### FontRequestCallback

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

```
FontRequestCallback()
```  

## Public functions

### onTypefaceRequestFailed

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

```
fun onTypefaceRequestFailed(reason: Int): Unit
```

Called when a Typeface request done via [requestFont](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat#requestFont(android.content.Context,androidx.core.provider.FontRequest,androidx.core.provider.FontsContractCompat.FontRequestCallback,android.os.Handler)) fails.  

|                                      Parameters                                       |
|---------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `reason: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | May be 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_FONT_NOT_FOUND](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_FONT_NOT_FOUND()), [FAIL_REASON_FONT_LOAD_ERROR](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_FONT_LOAD_ERROR()), [FAIL_REASON_FONT_UNAVAILABLE](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_FONT_UNAVAILABLE()), [FAIL_REASON_MALFORMED_QUERY](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_MALFORMED_QUERY()) or [FAIL_REASON_WRONG_CERTIFICATES](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_WRONG_CERTIFICATES()), or a provider defined positive code number. |

### onTypefaceRetrieved

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

```
fun onTypefaceRetrieved(typeface: Typeface!): Unit
```

Called then a Typeface request done via [requestFont](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat#requestFont(android.content.Context,androidx.core.provider.FontRequest,androidx.core.provider.FontsContractCompat.FontRequestCallback,android.os.Handler)) is complete. Note that this method will not be called if [onTypefaceRequestFailed](https://developer.android.com/reference/kotlin/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)) is called instead.  

|                                            Parameters                                             |
|---------------------------------------------------------------------------------------------------|--------------------------------|
| `typeface: `[Typeface](https://developer.android.com/reference/android/graphics/Typeface.html)`!` | The Typeface object retrieved. |