Added in API level 31

TextRunShaper

open class TextRunShaper
kotlin.Any
   ↳ android.graphics.text.TextRunShaper

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, android.text.TextShaper will provide text shaping functionalities needed. TextRunShaper is a lower level API that is used by android.text.TextShaper.

Summary

Public methods
open static PositionedGlyphs
shapeTextRun(text: CharArray, start: Int, count: Int, contextStart: Int, contextCount: Int, xOffset: Float, yOffset: Float, isRtl: Boolean, paint: Paint)

Shape non-styled text.

open static PositionedGlyphs
shapeTextRun(text: CharSequence, start: Int, count: Int, contextStart: Int, contextCount: Int, xOffset: Float, yOffset: Float, isRtl: Boolean, paint: Paint)

Shape non-styled text.

Public methods

shapeTextRun

Added in API level 31
open static fun shapeTextRun(
    text: CharArray,
    start: Int,
    count: Int,
    contextStart: Int,
    contextCount: Int,
    xOffset: Float,
    yOffset: Float,
    isRtl: Boolean,
    paint: Paint
): PositionedGlyphs

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.

Parameters
text CharArray: a text buffer to be shaped This value cannot be null.
start Int: a start index of shaping target in the buffer.
count Int: a length of shaping target in the buffer.
contextStart Int: a start index of context used for shaping in the buffer.
contextCount Int: a length of context used for shaping in the buffer.
xOffset Float: an additional amount of x offset of the result glyphs.
yOffset Float: an additional amount of y offset of the result glyphs.
isRtl Boolean: true if this text is shaped for RTL direction, false otherwise.
paint Paint: a paint used for shaping text. This value cannot be null.
Return
PositionedGlyphs a shape result. This value cannot be null.

shapeTextRun

Added in API level 31
open static fun shapeTextRun(
    text: CharSequence,
    start: Int,
    count: Int,
    contextStart: Int,
    contextCount: Int,
    xOffset: Float,
    yOffset: Float,
    isRtl: Boolean,
    paint: Paint
): PositionedGlyphs

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.

Parameters
text CharSequence: a text buffer to be shaped. Any styled spans stored in this text are ignored. This value cannot be null.
start Int: a start index of shaping target in the buffer.
count Int: a length of shaping target in the buffer.
contextStart Int: a start index of context used for shaping in the buffer.
contextCount Int: a length of context used for shaping in the buffer.
xOffset Float: an additional amount of x offset of the result glyphs.
yOffset Float: an additional amount of y offset of the result glyphs.
isRtl Boolean: true if this text is shaped for RTL direction, false otherwise.
paint Paint: a paint used for shaping text. This value cannot be null.
Return
PositionedGlyphs a shape result This value cannot be null.