class RubySpan : ReplacementSpan


A span used to specify ruby text for a portion of the text.

The text covered by this span is known as the "base text", and the ruby text is stored in text.

Ruby text cannot be nested (i.e., ruby text cannot contain further ruby text). Ruby spans also cannot overlap each other.

More information on ruby characters and span styling.

This span is designed for use with VerticalTextLayout, media3-ui library, and a bit more general use cases.

Summary

Constants

const Float

Public constructors

RubySpan(
    text: CharSequence,
    position: AnnotationPosition,
    orientation: TextOrientation,
    textScale: Float
)

Public functions

open Unit
draw(
    canvas: Canvas,
    text: CharSequence?,
    start: Int,
    end: Int,
    x: Float,
    top: Int,
    y: Int,
    bottom: Int,
    paint: Paint
)
open Int
getSize(
    paint: Paint,
    text: CharSequence?,
    start: Int,
    end: Int,
    fm: Paint.FontMetricsInt?
)

Public properties

TextOrientation

The text orientation of the ruby text.

AnnotationPosition

The position of ruby text relative to the base text.

CharSequence

The ruby text to be displayed adjacent to the base text.

Float

The text scale ratio of the ruby text relative to the base text.

Constants

DEFAULT_TEXT_SCALE

const val DEFAULT_TEXT_SCALE = 0.5f: Float

Public companion properties

DEFAULT_ORIENTATION

val DEFAULT_ORIENTATIONTextOrientation

DEFAULT_POSITION

val DEFAULT_POSITIONAnnotationPosition

Public constructors

RubySpan

Added in 1.0.0-alpha04
RubySpan(
    text: CharSequence,
    position: AnnotationPosition = DEFAULT_POSITION,
    orientation: TextOrientation = DEFAULT_ORIENTATION,
    textScale: Float = DEFAULT_TEXT_SCALE
)

Public functions

draw

Added in 1.0.0-alpha04
open fun draw(
    canvas: Canvas,
    text: CharSequence?,
    start: Int,
    end: Int,
    x: Float,
    top: Int,
    y: Int,
    bottom: Int,
    paint: Paint
): Unit

getSize

Added in 1.0.0-alpha04
open fun getSize(
    paint: Paint,
    text: CharSequence?,
    start: Int,
    end: Int,
    fm: Paint.FontMetricsInt?
): Int

Public properties

orientation

Added in 1.0.0-alpha04
val orientationTextOrientation

The text orientation of the ruby text. Defaults to TextOrientation.Mixed.

position

Added in 1.0.0-alpha04
val positionAnnotationPosition

The position of ruby text relative to the base text. Defaults to AnnotationPosition.Before.

text

Added in 1.0.0-alpha04
val textCharSequence

The ruby text to be displayed adjacent to the base text.

textScale

Added in 1.0.0-alpha04
val textScaleFloat

The text scale ratio of the ruby text relative to the base text. Defaults to 0.5f.