# FontsContractCompat.FontRequestCallback

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1  
Summary:[Constants](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontRequestCallback#constants)\|[Ctors](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontRequestCallback#pubctors)\|[Methods](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontRequestCallback#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontRequestCallback#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontRequestCallback#)  

# FontsContractCompat.FontRequestCallback

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public
static


class
FontsContractCompat.FontRequestCallback
`  
`

extends Object


``


`

|---|---------------------------------------------------------------------|
| java.lang.Object                                                       ||
| ↳ | android.support.v4.provider.FontsContractCompat.FontRequestCallback |

<br />

*** ** * ** ***

Interface used to receive asynchronously fetched typefaces.

## Summary

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

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

|                                                                                                                                                                                                                                                                                                                                  ### Public methods                                                                                                                                                                                                                                                                                                                                  ||
|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void` | ` `[onTypefaceRequestFailed](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int))`(int reason) ` Called when a Typeface request done via[requestFont(Context, FontRequest, FontRequestCallback, Handler)](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat#requestFont(android.content.Context, android.support.v4.provider.FontRequest, android.support.v4.provider.FontsContractCompat.FontRequestCallback, android.os.Handler))fails.                                                                                                        |
| ` void` | ` `[onTypefaceRetrieved](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontRequestCallback#onTypefaceRetrieved(android.graphics.Typeface))`(`[Typeface](https://developer.android.com/reference/android/graphics/Typeface.html)` typeface) ` Called then a Typeface request done via[requestFont(Context, FontRequest, FontRequestCallback, Handler)](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat#requestFont(android.content.Context, android.support.v4.provider.FontRequest, android.support.v4.provider.FontsContractCompat.FontRequestCallback, android.os.Handler))is complete. |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontRequestCallback#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Constants

### FAIL_REASON_FONT_LOAD_ERROR

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int FAIL_REASON_FONT_LOAD_ERROR
```

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

<br />

Constant Value: -3 (0xfffffffd)  

### FAIL_REASON_FONT_NOT_FOUND

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int FAIL_REASON_FONT_NOT_FOUND
```

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

<br />

Constant Value: 1 (0x00000001)  

### FAIL_REASON_FONT_UNAVAILABLE

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int FAIL_REASON_FONT_UNAVAILABLE
```

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

<br />

Constant Value: 2 (0x00000002)  

### FAIL_REASON_MALFORMED_QUERY

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int FAIL_REASON_MALFORMED_QUERY
```

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

<br />

Constant Value: 3 (0x00000003)  

### FAIL_REASON_PROVIDER_NOT_FOUND

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int FAIL_REASON_PROVIDER_NOT_FOUND
```

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

<br />

Constant Value: -1 (0xffffffff)  

### FAIL_REASON_SECURITY_VIOLATION

added in[version 27.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int FAIL_REASON_SECURITY_VIOLATION
```

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.

<br />

Constant Value: -4 (0xfffffffc)  

### FAIL_REASON_WRONG_CERTIFICATES

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int FAIL_REASON_WRONG_CERTIFICATES
```

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

<br />

Constant Value: -2 (0xfffffffe)

## Public constructors

### FontsContractCompat.FontRequestCallback

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
FontsContractCompat.FontRequestCallback ()
```

<br />

<br />

## Public methods

### onTypefaceRequestFailed

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onTypefaceRequestFailed (int reason)
```

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

<br />

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `reason` | `int`: May be one of[FAIL_REASON_PROVIDER_NOT_FOUND](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_PROVIDER_NOT_FOUND),[FAIL_REASON_FONT_NOT_FOUND](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_FONT_NOT_FOUND),[FAIL_REASON_FONT_LOAD_ERROR](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_FONT_LOAD_ERROR),[FAIL_REASON_FONT_UNAVAILABLE](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_FONT_UNAVAILABLE),[FAIL_REASON_MALFORMED_QUERY](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_MALFORMED_QUERY)or[FAIL_REASON_WRONG_CERTIFICATES](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_WRONG_CERTIFICATES), or a provider defined positive code number. <br /> |

### onTypefaceRetrieved

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onTypefaceRetrieved (Typeface typeface)
```

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

<br />

|                          Parameters                           ||
|------------|---------------------------------------------------|
| `typeface` | `Typeface`: The Typeface object retrieved. <br /> |

-

  ## Classes

  - [DocumentFile](https://developer.android.com/reference/android/support/v4/provider/DocumentFile)
  - [FontRequest](https://developer.android.com/reference/android/support/v4/provider/FontRequest)
  - [FontsContractCompat](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat)
  - [FontsContractCompat.Columns](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.Columns)
  - [FontsContractCompat.FontFamilyResult](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontFamilyResult)
  - [FontsContractCompat.FontInfo](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontInfo)
  - [FontsContractCompat.FontRequestCallback](https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.FontRequestCallback)