# FontRequestEmojiCompatConfig

Artifact: [androidx.emoji2:emoji2](https://developer.android.com/jetpack/androidx/releases/emoji2) [View Source](https://cs.android.com/search?q=file:androidx/emoji2/text/FontRequestEmojiCompatConfig.java+class:androidx.emoji2.text.FontRequestEmojiCompatConfig) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji2#1.0.0)

*** ** * ** ***


```
public class FontRequestEmojiCompatConfig extends EmojiCompat.Config
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.emoji2.text.EmojiCompat.Config](https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config) ||
|   | ↳ | [androidx.emoji2.text.FontRequestEmojiCompatConfig](https://developer.android.com/reference/androidx/emoji2/text/FontRequestEmojiCompatConfig) |

*** ** * ** ***

`https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` implementation that asynchronously fetches the required font and the metadata using a `https://developer.android.com/reference/androidx/core/provider/FontRequest`. FontRequest should be constructed to fetch an EmojiCompat compatible emoji font.

## Summary

| ### Nested types |
|---|
| `public class https://developer.android.com/reference/androidx/emoji2/text/FontRequestEmojiCompatConfig.ExponentialBackoffRetryPolicy extends https://developer.android.com/reference/androidx/emoji2/text/FontRequestEmojiCompatConfig.RetryPolicy` A retry policy implementation that doubles the amount of time in between retries. |
| `public abstract class https://developer.android.com/reference/androidx/emoji2/text/FontRequestEmojiCompatConfig.RetryPolicy` Retry policy used when the font provider is not ready to give the font file. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/emoji2/text/FontRequestEmojiCompatConfig#FontRequestEmojiCompatConfig(android.content.Context,androidx.core.provider.FontRequest)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/provider/FontRequest request )` |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/FontRequestEmojiCompatConfig` | `[setHandler](https://developer.android.com/reference/androidx/emoji2/text/FontRequestEmojiCompatConfig#setHandler(android.os.Handler))(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Handler.html handler)` **This method is deprecated.** please call setLoadingExecutor instead <br /> |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/FontRequestEmojiCompatConfig` | `https://developer.android.com/reference/androidx/emoji2/text/FontRequestEmojiCompatConfig#setLoadingExecutor(java.util.concurrent.Executor)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html executor)` Sets the custom executor to be used for initialization. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/FontRequestEmojiCompatConfig` | `https://developer.android.com/reference/androidx/emoji2/text/FontRequestEmojiCompatConfig#setRetryPolicy(androidx.emoji2.text.FontRequestEmojiCompatConfig.RetryPolicy)( @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/emoji2/text/FontRequestEmojiCompatConfig.RetryPolicy policy )` Sets the retry policy. |

### Inherited methods

From [androidx.emoji2.text.EmojiCompat.Config](https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config) `final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.MetadataRepoLoader` `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#getMetadataRepoLoader()()`

Returns the `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.MetadataRepoLoader`.
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#registerInitCallback(androidx.emoji2.text.EmojiCompat.InitCallback)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.InitCallback initCallback)`

Registers an initialization callback.
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#registerInitCallback(java.util.concurrent.Executor,androidx.emoji2.text.EmojiCompat.InitCallback)(
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html executor,
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.InitCallback initCallback
)`

Registers an initialization callback.
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setEmojiSpanIndicatorColor(int)(@https://developer.android.com/reference/androidx/annotation/ColorInt int color)`

Sets the color used as emoji span indicator.
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setEmojiSpanIndicatorEnabled(boolean)(boolean emojiSpanIndicatorEnabled)`

Determines whether a background will be drawn for the emojis that are found and replaced by EmojiCompat.
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setGlyphChecker(androidx.emoji2.text.EmojiCompat.GlyphChecker)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.GlyphChecker glyphChecker)`

The interface that is used by EmojiCompat in order to check if a given emoji can be rendered by the system.
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setMetadataLoadStrategy(int)(int strategy)`

Determines the strategy to start loading the metadata.
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setReplaceAll(boolean)(boolean replaceAll)`

Determines whether EmojiCompat should replace all the emojis it finds with the EmojiSpans.
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setSpanFactory(androidx.emoji2.text.EmojiCompat.SpanFactory)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.SpanFactory factory)`

Set the span factory used to actually draw emoji replacements.
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setUseAfterUpdatableSystemFonts(boolean)(boolean useAfter)`

Configure whether EmojiCompat should continue to process emojis and load metadata on devices that support Updatable System Fonts (API 35 and above).
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setUseEmojiAsDefaultStyle(boolean)(boolean useEmojiAsDefaultStyle)`

Determines whether EmojiCompat should use the emoji presentation style for emojis that have text style as default.
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setUseEmojiAsDefaultStyle(boolean,java.util.List<java.lang.Integer>)(
boolean useEmojiAsDefaultStyle,
@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/Integer.html> emojiAsDefaultStyleExceptions
)` `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#unregisterInitCallback(androidx.emoji2.text.EmojiCompat.InitCallback)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.InitCallback initCallback)`

Unregisters a callback that was added before.

## Public constructors

### FontRequestEmojiCompatConfig

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

```
public FontRequestEmojiCompatConfig(
    @NonNull Context context,
    @NonNull FontRequest request
)
```

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | Context instance, cannot be `null` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/provider/FontRequest request` | `https://developer.android.com/reference/androidx/core/provider/FontRequest` to fetch the font asynchronously, cannot be `null` |

## Public methods

### setHandler

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji2#1.0.0) Deprecated in [1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji2#1.0.0)

```
public @NonNull FontRequestEmojiCompatConfig [setHandler](https://developer.android.com/reference/androidx/emoji2/text/FontRequestEmojiCompatConfig#setHandler(android.os.Handler))(@Nullable Handler handler)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> please call setLoadingExecutor instead

Please us `https://developer.android.com/reference/androidx/emoji2/text/FontRequestEmojiCompatConfig#setLoadingExecutor(java.util.concurrent.Executor)` instead to set background loading thread. This was deprecated in emoji2 1.0.0-alpha04. If migrating from androidx.emoji please prefer to use an existing background executor for setLoadingExecutor. Note: This method will no longer have any effect if passed null, which is a breaking change from androidx.emoji.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Handler.html handler` | background thread handler to wrap in an Executor, if null this method will do nothing |

### setLoadingExecutor

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

```
public @NonNull FontRequestEmojiCompatConfig setLoadingExecutor(@NonNull Executor executor)
```

Sets the custom executor to be used for initialization. Since font loading is too slow for the main thread, the metadata loader will fetch the fonts on a background thread. By default, FontRequestEmojiCompatConfig will create its own single threaded Executor, which causes a thread to be created. You can pass your own executor to control which thread the font is loaded on, and avoid an extra thread creation.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | background executor for performing font load |

### setRetryPolicy

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

```
public @NonNull FontRequestEmojiCompatConfig setRetryPolicy(
    @Nullable FontRequestEmojiCompatConfig.RetryPolicy policy
)
```

Sets the retry policy. {@see RetryPolicy}

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/emoji2/text/FontRequestEmojiCompatConfig.RetryPolicy policy` | The policy to be used when the font provider is not ready to give the font file. Can be `null`. In case of `null`, the metadata loader never retries. |