# FontsContract.FontRequestCallback

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Deprecated in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# FontRequestCallback

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback "View this page in Java")  

```
open class FontRequestCallback
```

|---|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                           ||
| ↳ | [android.provider.FontsContract.FontRequestCallback](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#) |

*** ** * ** ***

| **This class was deprecated in API level 31.**
|
| Use the androidx.core.provider.FontsContractCompat.FontRequestCallback for consistent behavior across all devices

Interface used to receive asynchronously fetched typefaces.

## Summary

|                                                                                                                                                                                                                                                                                Constants                                                                                                                                                                                                                                                                                ||
|----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [FAIL_REASON_FONT_LOAD_ERROR](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_FONT_LOAD_ERROR:kotlin.Int) Constant returned by[onTypefaceRequestFailed(int)](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(kotlin.Int))signaling that the font returned by the provider was not loaded properly.                                            |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [FAIL_REASON_FONT_NOT_FOUND](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_FONT_NOT_FOUND:kotlin.Int) Constant returned by[onTypefaceRequestFailed(int)](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(kotlin.Int))signaling that the font provider did not return any results for the given query.                                       |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [FAIL_REASON_FONT_UNAVAILABLE](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_FONT_UNAVAILABLE:kotlin.Int) Constant returned by[onTypefaceRequestFailed(int)](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(kotlin.Int))signaling that the font provider found the queried font, but it is currently unavailable.                          |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [FAIL_REASON_MALFORMED_QUERY](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_MALFORMED_QUERY:kotlin.Int) Constant returned by[onTypefaceRequestFailed(int)](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(kotlin.Int))signaling that the given query was not supported by the provider.                                                    |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [FAIL_REASON_PROVIDER_NOT_FOUND](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_PROVIDER_NOT_FOUND:kotlin.Int) Constant returned by[onTypefaceRequestFailed(int)](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(kotlin.Int))signaling that the given provider was not found on the device.                                                 |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [FAIL_REASON_WRONG_CERTIFICATES](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_WRONG_CERTIFICATES:kotlin.Int) Constant returned by[onTypefaceRequestFailed(int)](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(kotlin.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/android/provider/FontsContract.FontRequestCallback#FontRequestCallback())`()` <br /> |

|                                                                                                                                                                                                                                                                                                                                               Public methods                                                                                                                                                                                                                                                                                                                                               ||
|----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onTypefaceRequestFailed](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(kotlin.Int))`(`reason:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called when a Typeface request done via[requestFonts](https://developer.android.com/reference/kotlin/android/provider/FontsContract#requestFonts(android.content.Context,%20android.provider.FontRequest,%20android.os.Handler,%20android.os.CancellationSignal,%20android.provider.FontsContract.FontRequestCallback))} fails.                               |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onTypefaceRetrieved](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#onTypefaceRetrieved(android.graphics.Typeface))`(`typeface:` `[Typeface](https://developer.android.com/reference/kotlin/android/graphics/Typeface.html#)!`)` Called then a Typeface request done via[requestFonts](https://developer.android.com/reference/kotlin/android/provider/FontsContract#requestFonts(android.content.Context,%20android.provider.FontRequest,%20android.os.Handler,%20android.os.CancellationSignal,%20android.provider.FontsContract.FontRequestCallback))is complete. |

## Constants

### FAIL_REASON_FONT_LOAD_ERROR

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val FAIL_REASON_FONT_LOAD_ERROR: Int
```

**Deprecated:** *Deprecated in Java.*

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

    Value: -3

### FAIL_REASON_FONT_NOT_FOUND

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val FAIL_REASON_FONT_NOT_FOUND: Int
```

**Deprecated:** *Deprecated in Java.*

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

    Value: 1

### FAIL_REASON_FONT_UNAVAILABLE

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val FAIL_REASON_FONT_UNAVAILABLE: Int
```

**Deprecated:** *Deprecated in Java.*

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

    Value: 2

### FAIL_REASON_MALFORMED_QUERY

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val FAIL_REASON_MALFORMED_QUERY: Int
```

**Deprecated:** *Deprecated in Java.*

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

    Value: 3

### FAIL_REASON_PROVIDER_NOT_FOUND

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val FAIL_REASON_PROVIDER_NOT_FOUND: Int
```

**Deprecated:** *Deprecated in Java.*

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

    Value: -1

### FAIL_REASON_WRONG_CERTIFICATES

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val FAIL_REASON_WRONG_CERTIFICATES: Int
```

**Deprecated:** *Deprecated in Java.*

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

    Value: -2

## Public constructors

### FontRequestCallback

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
FontRequestCallback()
```

## Public methods

### onTypefaceRequestFailed

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

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

**Deprecated:** *Deprecated in Java.*

Called when a Typeface request done via[requestFonts](https://developer.android.com/reference/kotlin/android/provider/FontsContract#requestFonts(android.content.Context,%20android.provider.FontRequest,%20android.os.Handler,%20android.os.CancellationSignal,%20android.provider.FontsContract.FontRequestCallback))} fails.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ||
|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `reason` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):One of[FAIL_REASON_PROVIDER_NOT_FOUND](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_PROVIDER_NOT_FOUND:kotlin.Int),[FAIL_REASON_FONT_NOT_FOUND](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_FONT_NOT_FOUND:kotlin.Int),[FAIL_REASON_FONT_LOAD_ERROR](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_FONT_LOAD_ERROR:kotlin.Int),[FAIL_REASON_FONT_UNAVAILABLE](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_FONT_UNAVAILABLE:kotlin.Int)or[FAIL_REASON_MALFORMED_QUERY](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_MALFORMED_QUERY:kotlin.Int)if returned by the system. May also be a positive value greater than 0 defined by the font provider as an additional error code. Refer to the provider's documentation for more information on possible returned error codes. Value is[android.provider.FontsContract.FontRequestCallback#FAIL_REASON_PROVIDER_NOT_FOUND](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_PROVIDER_NOT_FOUND:kotlin.Int),[android.provider.FontsContract.FontRequestCallback#FAIL_REASON_FONT_LOAD_ERROR](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_FONT_LOAD_ERROR:kotlin.Int),[android.provider.FontsContract.FontRequestCallback#FAIL_REASON_FONT_NOT_FOUND](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_FONT_NOT_FOUND:kotlin.Int),[android.provider.FontsContract.FontRequestCallback#FAIL_REASON_FONT_UNAVAILABLE](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_FONT_UNAVAILABLE:kotlin.Int), or[android.provider.FontsContract.FontRequestCallback#FAIL_REASON_MALFORMED_QUERY](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_MALFORMED_QUERY:kotlin.Int) |

### onTypefaceRetrieved

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

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

**Deprecated:** *Deprecated in Java.*

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

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