Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/android/graphics/text/TextRunShaper#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/graphics/text/TextRunShaper#inhmethods)

# TextRunShaper

*** ** * ** ***


`
public


class
TextRunShaper
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.graphics.text.TextRunShaper |

<br />

*** ** * ** ***

Provides conversion from a text into glyph array.

Text shaping is a preprocess for drawing text into canvas with glyphs. The glyph is a most
primitive unit of the text drawing, consist of glyph identifier in the font file and its position
and style. You can draw the shape result to Canvas by calling Canvas#drawGlyphs.

For most of the use cases, `https://developer.android.com/reference/android/text/TextShaper` will provide text shaping
functionalities needed. `https://developer.android.com/reference/android/graphics/text/TextRunShaper` is a lower level API that is used by
`https://developer.android.com/reference/android/text/TextShaper`.
**See also:**

- `https://developer.android.com/reference/android/graphics/text/TextRunShaper#shapeTextRun(java.lang.CharSequence,%20int,%20int,%20int,%20int,%20float,%20float,%20boolean,%20android.graphics.Paint)`
- `https://developer.android.com/reference/android/graphics/text/TextRunShaper#shapeTextRun(char[],%20int,%20int,%20int,%20int,%20float,%20float,%20boolean,%20android.graphics.Paint)`
- `https://developer.android.com/reference/android/text/TextShaper#shapeText(java.lang.CharSequence,%20int,%20int,%20android.text.TextDirectionHeuristic,%20android.text.TextPaint,%20android.text.TextShaper.GlyphsConsumer)`

## Summary

| ### Public methods ||
|---|---|
| ` static https://developer.android.com/reference/android/graphics/text/PositionedGlyphs` | ` https://developer.android.com/reference/android/graphics/text/TextRunShaper#shapeTextRun(java.lang.CharSequence,%20int,%20int,%20int,%20int,%20float,%20float,%20boolean,%20android.graphics.Paint)(https://developer.android.com/reference/java/lang/CharSequence text, int start, int count, int contextStart, int contextCount, float xOffset, float yOffset, boolean isRtl, https://developer.android.com/reference/android/graphics/Paint paint) ` Shape non-styled text. |
| ` static https://developer.android.com/reference/android/graphics/text/PositionedGlyphs` | ` https://developer.android.com/reference/android/graphics/text/TextRunShaper#shapeTextRun(char[],%20int,%20int,%20int,%20int,%20float,%20float,%20boolean,%20android.graphics.Paint)(char[] text, int start, int count, int contextStart, int contextCount, float xOffset, float yOffset, boolean isRtl, https://developer.android.com/reference/android/graphics/Paint paint) ` Shape non-styled text. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public methods

### shapeTextRun

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static PositionedGlyphs shapeTextRun (CharSequence text, 
                int start, 
                int count, 
                int contextStart, 
                int contextCount, 
                float xOffset, 
                float yOffset, 
                boolean isRtl, 
                Paint paint)
```

Shape non-styled text.

This function shapes the text of the given range under the context of given context range.
Some script, e.g. Arabic or Devanagari, changes letter shape based on its location or
surrounding characters.

<br />

| Parameters ||
|---|---|
| `text` | `CharSequence`: a text buffer to be shaped. Any styled spans stored in this text are ignored. This value cannot be `null`. <br /> |
| `start` | `int`: a start index of shaping target in the buffer. <br /> |
| `count` | `int`: a length of shaping target in the buffer. <br /> |
| `contextStart` | `int`: a start index of context used for shaping in the buffer. <br /> |
| `contextCount` | `int`: a length of context used for shaping in the buffer. <br /> |
| `xOffset` | `float`: an additional amount of x offset of the result glyphs. <br /> |
| `yOffset` | `float`: an additional amount of y offset of the result glyphs. <br /> |
| `isRtl` | `boolean`: true if this text is shaped for RTL direction, false otherwise. <br /> |
| `paint` | `Paint`: a paint used for shaping text. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/text/PositionedGlyphs` | a shape result. This value cannot be `null`. <br /> |

### shapeTextRun

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static PositionedGlyphs shapeTextRun (char[] text, 
                int start, 
                int count, 
                int contextStart, 
                int contextCount, 
                float xOffset, 
                float yOffset, 
                boolean isRtl, 
                Paint paint)
```

Shape non-styled text.

This function shapes the text of the given range under the context of given context range.
Some script, e.g. Arabic or Devanagari, changes letter shape based on its location or
surrounding characters.

<br />

| Parameters ||
|---|---|
| `text` | `char`: a text buffer to be shaped. This value cannot be `null`. <br /> |
| `start` | `int`: a start index of shaping target in the buffer. <br /> |
| `count` | `int`: a length of shaping target in the buffer. <br /> |
| `contextStart` | `int`: a start index of context used for shaping in the buffer. <br /> |
| `contextCount` | `int`: a length of context used for shaping in the buffer. <br /> |
| `xOffset` | `float`: an additional amount of x offset of the result glyphs. <br /> |
| `yOffset` | `float`: an additional amount of y offset of the result glyphs. <br /> |
| `isRtl` | `boolean`: true if this text is shaped for RTL direction, false otherwise. <br /> |
| `paint` | `Paint`: a paint used for shaping text. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/text/PositionedGlyphs` | a shape result. This value cannot be `null`. <br /> |