# TypefaceEmojiRasterizer

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

*** ** * ** ***


```
@AnyThread
public class TypefaceEmojiRasterizer
```

<br />

*** ** * ** ***

Information about a single emoji. To draw this emoji on a canvas using use draw. To draw this emoji using custom code, use getCodepointAt and getTypeface to access the underlying emoji font and look up the glyph.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/emoji2/text/TypefaceEmojiRasterizer#draw(android.graphics.Canvas,float,float,android.graphics.Paint)` |   |
| `https://developer.android.com/reference/androidx/emoji2/text/TypefaceEmojiRasterizer#getCodepointAt(int)` |   |
| `https://developer.android.com/reference/androidx/emoji2/text/TypefaceEmojiRasterizer#getTypeface()` |   |

## Summary

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/emoji2/text/TypefaceEmojiRasterizer#draw(android.graphics.Canvas,float,float,android.graphics.Paint)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Canvas.html canvas, float x, float y, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Paint.html paint)` Draws the emoji onto a canvas with origin at (x,y), using the specified paint. |
| `int` | `https://developer.android.com/reference/androidx/emoji2/text/TypefaceEmojiRasterizer#getCodepointAt(int)(int index)` |
| `int` | `https://developer.android.com/reference/androidx/emoji2/text/TypefaceEmojiRasterizer#getCodepointsLength()()` |
| `int` | `https://developer.android.com/reference/androidx/emoji2/text/TypefaceEmojiRasterizer#getHeight()()` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Typeface.html` | `https://developer.android.com/reference/androidx/emoji2/text/TypefaceEmojiRasterizer#getTypeface()()` |
| `int` | `https://developer.android.com/reference/androidx/emoji2/text/TypefaceEmojiRasterizer#getWidth()()` |
| `boolean` | `https://developer.android.com/reference/androidx/emoji2/text/TypefaceEmojiRasterizer#isDefaultEmoji()()` |
| `boolean` | `https://developer.android.com/reference/androidx/emoji2/text/TypefaceEmojiRasterizer#isPreferredSystemRender()()` If the platform requested that this emoji not be rendered using emojicompat. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/emoji2/text/TypefaceEmojiRasterizer#toString()()` |

## Public methods

### draw

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

```
public void draw(@NonNull Canvas canvas, float x, float y, @NonNull Paint paint)
```

Draws the emoji onto a canvas with origin at (x,y), using the specified paint.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Canvas.html canvas` | Canvas to be drawn |
| `float x` | x-coordinate of the origin of the emoji being drawn |
| `float y` | y-coordinate of the baseline of the emoji being drawn |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Paint.html paint` | Paint used for the text (e.g. color, size, style) |

### getCodepointAt

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

```
public int getCodepointAt(int index)
```

| Parameters |
|---|---|
| `int index` | index of the codepoint |

| Returns |
|---|---|
| `int` | the codepoint at index |

### getCodepointsLength

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

```
public int getCodepointsLength()
```

| Returns |
|---|---|
| `int` | the length of the codepoints for this emoji |

### getHeight

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

```
public int getHeight()
```

| Returns |
|---|---|
| `int` | height of the emoji image |

### getTypeface

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

```
public @NonNull Typeface getTypeface()
```

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Typeface.html` | return typeface to be used to render |

### getWidth

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

```
public int getWidth()
```

| Returns |
|---|---|
| `int` | width of the emoji image |

### isDefaultEmoji

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

```
public boolean isDefaultEmoji()
```

| Returns |
|---|---|
| `boolean` | whether the emoji is in Emoji Presentation by default (without emoji style selector 0xFE0F) |

### isPreferredSystemRender

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

```
public boolean isPreferredSystemRender()
```

If the platform requested that this emoji not be rendered using emojicompat.

| Returns |
|---|---|
| `boolean` | true if this emoji should be drawn by the system instead of this renderer |

### toString

```
public @NonNull String toString()
```