# 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)

*** ** * ** ***


```
public class FontsContractCompat.FontRequestCallback
```

<br />

*** ** * ** ***

Interface used to receive asynchronously fetched typefaces.

## Summary

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_FONT_LOAD_ERROR() = -3` Constant returned by `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)` signaling that the font returned by the provider was not loaded properly. |
| `static final int` | `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_FONT_NOT_FOUND() = 1` Constant returned by `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)` signaling that the font provider did not return any results for the given query. |
| `static final int` | `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_FONT_UNAVAILABLE() = 2` Constant returned by `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)` signaling that the font provider found the queried font, but it is currently unavailable. |
| `static final int` | `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_MALFORMED_QUERY() = 3` Constant returned by `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)` signaling that the given query was not supported by the provider. |
| `static final int` | `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_PROVIDER_NOT_FOUND() = -1` Constant returned by `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)` signaling that the given provider was not found on the device. |
| `static final int` | `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_SECURITY_VIOLATION() = -4` Constant that signals that the font was not loaded due to security issues. |
| `static final int` | `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_WRONG_CERTIFICATES() = -2` Constant returned by `https://developer.android.com/reference/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 |
|---|
| `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#FontRequestCallback()()` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)(int reason)` Called when a Typeface request done via `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat#requestFont(android.content.Context,androidx.core.provider.FontRequest,androidx.core.provider.FontsContractCompat.FontRequestCallback,android.os.Handler)` fails. |
| `void` | `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRetrieved(android.graphics.Typeface)(https://developer.android.com/reference/android/graphics/Typeface.html typeface)` Called then a Typeface request done via `https://developer.android.com/reference/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)

```
public static final int FAIL_REASON_FONT_LOAD_ERROR = -3
```

Constant returned by `https://developer.android.com/reference/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)

```
public static final int FAIL_REASON_FONT_NOT_FOUND = 1
```

Constant returned by `https://developer.android.com/reference/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)

```
public static final int FAIL_REASON_FONT_UNAVAILABLE = 2
```

Constant returned by `https://developer.android.com/reference/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)

```
public static final int FAIL_REASON_MALFORMED_QUERY = 3
```

Constant returned by `https://developer.android.com/reference/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)

```
public static final int FAIL_REASON_PROVIDER_NOT_FOUND = -1
```

Constant returned by `https://developer.android.com/reference/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)

```
public static final int FAIL_REASON_SECURITY_VIOLATION = -4
```

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)

```
public static final int FAIL_REASON_WRONG_CERTIFICATES = -2
```

Constant returned by `https://developer.android.com/reference/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)

```
public FontRequestCallback()
```

## Public methods

### onTypefaceRequestFailed

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

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

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

| Parameters |
|---|---|
| `int reason` | May be one of `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_PROVIDER_NOT_FOUND()`, `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_FONT_NOT_FOUND()`, `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_FONT_LOAD_ERROR()`, `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_FONT_UNAVAILABLE()`, `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#FAIL_REASON_MALFORMED_QUERY()` or `https://developer.android.com/reference/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)

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

Called then a Typeface request done via `https://developer.android.com/reference/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 `https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback#onTypefaceRequestFailed(int)` is called instead.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/graphics/Typeface.html typeface` | The Typeface object retrieved. |