# EmojiSpan

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

*** ** * ** ***


```
public abstract class EmojiSpan extends ReplacementSpan
```

<br />

|---|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||||
| ↳ | [android.text.style.CharacterStyle](https://developer.android.com/reference/android/text/style/CharacterStyle.html) ||||
|   | ↳ | [android.text.style.MetricAffectingSpan](https://developer.android.com/reference/android/text/style/MetricAffectingSpan.html) |||
|   |   | ↳ | [android.text.style.ReplacementSpan](https://developer.android.com/reference/android/text/style/ReplacementSpan.html) ||
|   |   |   | ↳ | [androidx.emoji2.text.EmojiSpan](https://developer.android.com/reference/androidx/emoji2/text/EmojiSpan) |

*** ** * ** ***

Base span class for the emoji replacement. When an emoji is found and needs to be replaced in a CharSequence, an instance of this class is added to the CharSequence.

## Summary

| ### Public methods |
|---|---|
| `int` | `https://developer.android.com/reference/androidx/emoji2/text/EmojiSpan#getSize(android.graphics.Paint,java.lang.CharSequence,int,int,android.graphics.Paint.FontMetricsInt)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Paint.html paint, https://developer.android.com/reference/java/lang/CharSequence.html text, int start, int end, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/Paint.FontMetricsInt.html fm )` |
| `final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/TypefaceEmojiRasterizer` | `https://developer.android.com/reference/androidx/emoji2/text/EmojiSpan#getTypefaceRasterizer()()` Get the rasterizer that draws this emoji. |

| ### Inherited methods |
|---|
| From [android.text.style.CharacterStyle](https://developer.android.com/reference/android/text/style/CharacterStyle.html) |---|---| | `https://developer.android.com/reference/android/text/style/CharacterStyle.html` | `https://developer.android.com/reference/android/text/style/CharacterStyle.html#getUnderlying()()` | | `static https://developer.android.com/reference/android/text/style/CharacterStyle.html` | `https://developer.android.com/reference/android/text/style/CharacterStyle.html#wrap(android.text.style.CharacterStyle)(https://developer.android.com/reference/android/text/style/CharacterStyle.html cs)` | |
| From [android.text.style.MetricAffectingSpan](https://developer.android.com/reference/android/text/style/MetricAffectingSpan.html) |---|---| | `https://developer.android.com/reference/android/text/style/MetricAffectingSpan.html` | `https://developer.android.com/reference/android/text/style/MetricAffectingSpan.html#getUnderlying()()` | |
| From [android.text.style.ReplacementSpan](https://developer.android.com/reference/android/text/style/ReplacementSpan.html) |---|---| | `abstract void` | `https://developer.android.com/reference/android/text/style/ReplacementSpan.html#draw(android.graphics.Canvas, java.lang.CharSequence, int, int, float, int, int, int, android.graphics.Paint)( https://developer.android.com/reference/android/graphics/Canvas.html p, https://developer.android.com/reference/java/lang/CharSequence.html p1, int p2, int p3, float p4, int p5, int p6, int p7, https://developer.android.com/reference/android/graphics/Paint.html p8 )` | | `https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/android/text/style/ReplacementSpan.html#getContentDescription()()` | | `void` | `https://developer.android.com/reference/android/text/style/ReplacementSpan.html#setContentDescription(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence.html contentDescription)` | | `void` | `https://developer.android.com/reference/android/text/style/ReplacementSpan.html#updateDrawState(android.text.TextPaint)(https://developer.android.com/reference/android/text/TextPaint.html ds)` | | `void` | `https://developer.android.com/reference/android/text/style/ReplacementSpan.html#updateMeasureState(android.text.TextPaint)(https://developer.android.com/reference/android/text/TextPaint.html p)` | |

## Public methods

### getSize

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

```
public int getSize(
    @NonNull Paint paint,
    CharSequence text,
    int start,
    int end,
    @Nullable Paint.FontMetricsInt fm
)
```

### getTypefaceRasterizer

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

```
public final @NonNull TypefaceEmojiRasterizer getTypefaceRasterizer()
```

Get the rasterizer that draws this emoji.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/TypefaceEmojiRasterizer` | rasterizer to draw emoji |