# TypefaceEmojiRasterizer

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/emoji2/text/TypefaceEmojiRasterizer "View this page in Java")

<br />

```
@AnyThread
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                                                                               |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [draw](https://developer.android.com/reference/kotlin/androidx/emoji2/text/TypefaceEmojiRasterizer#draw(android.graphics.Canvas,float,float,android.graphics.Paint)) |   |
| [getCodepointAt](https://developer.android.com/reference/kotlin/androidx/emoji2/text/TypefaceEmojiRasterizer#getCodepointAt(int))                                    |   |
| [getTypeface](https://developer.android.com/reference/kotlin/androidx/emoji2/text/TypefaceEmojiRasterizer#getTypeface())                                             |   |

## Summary

|                                ### Public functions                                 |
|-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | [draw](https://developer.android.com/reference/kotlin/androidx/emoji2/text/TypefaceEmojiRasterizer#draw(android.graphics.Canvas,float,float,android.graphics.Paint))`(canvas: `[Canvas](https://developer.android.com/reference/android/graphics/Canvas.html)`, x: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`, y: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`, paint: `[Paint](https://developer.android.com/reference/android/graphics/Paint.html)`)` Draws the emoji onto a canvas with origin at (x,y), using the specified paint. |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)         | [getCodepointAt](https://developer.android.com/reference/kotlin/androidx/emoji2/text/TypefaceEmojiRasterizer#getCodepointAt(int))`(index: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)`                                                                                                                                                                                                                                                                                                                                                                                          |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)         | [getCodepointsLength](https://developer.android.com/reference/kotlin/androidx/emoji2/text/TypefaceEmojiRasterizer#getCodepointsLength())`()`                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)         | [getHeight](https://developer.android.com/reference/kotlin/androidx/emoji2/text/TypefaceEmojiRasterizer#getHeight())`()`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [Typeface](https://developer.android.com/reference/android/graphics/Typeface.html)  | [getTypeface](https://developer.android.com/reference/kotlin/androidx/emoji2/text/TypefaceEmojiRasterizer#getTypeface())`()`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)         | [getWidth](https://developer.android.com/reference/kotlin/androidx/emoji2/text/TypefaceEmojiRasterizer#getWidth())`()`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [isDefaultEmoji](https://developer.android.com/reference/kotlin/androidx/emoji2/text/TypefaceEmojiRasterizer#isDefaultEmoji())`()`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [isPreferredSystemRender](https://developer.android.com/reference/kotlin/androidx/emoji2/text/TypefaceEmojiRasterizer#isPreferredSystemRender())`()` If the platform requested that this emoji not be rendered using emojicompat.                                                                                                                                                                                                                                                                                                                                                                                  |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)   | [toString](https://developer.android.com/reference/kotlin/androidx/emoji2/text/TypefaceEmojiRasterizer#toString())`()`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |

## Public functions

### draw

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

```
fun draw(canvas: Canvas, x: Float, y: Float, paint: Paint): Unit
```

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

|                                        Parameters                                        |
|------------------------------------------------------------------------------------------|-------------------------------------------------------|
| `canvas: `[Canvas](https://developer.android.com/reference/android/graphics/Canvas.html) | Canvas to be drawn                                    |
| `x: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)     | x-coordinate of the origin of the emoji being drawn   |
| `y: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)     | y-coordinate of the baseline of the emoji being drawn |
| `paint: `[Paint](https://developer.android.com/reference/android/graphics/Paint.html)    | 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)  

```
fun getCodepointAt(index: Int): Int
```  

|                                      Parameters                                      |
|--------------------------------------------------------------------------------------|------------------------|
| `index: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | index of the codepoint |

|                                   Returns                                   |
|-----------------------------------------------------------------------------|------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the codepoint at index |

### getCodepointsLength

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

```
fun getCodepointsLength(): Int
```  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|---------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | 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)  

```
fun getHeight(): Int
```  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|---------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | height of the emoji image |

### getTypeface

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

```
fun getTypeface(): Typeface
```  

|                                      Returns                                       |
|------------------------------------------------------------------------------------|--------------------------------------|
| [Typeface](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)  

```
fun getWidth(): Int
```  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|--------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | width of the emoji image |

### isDefaultEmoji

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

```
fun isDefaultEmoji(): Boolean
```  

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | 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)  

```
fun isPreferredSystemRender(): Boolean
```

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

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|---------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | true if this emoji should be drawn by the system instead of this renderer |

### toString

```
fun toString(): String
```