VerticalTextScope

@VerticalTextDsl
interface VerticalTextScope


Receiver for the buildVerticalText DSL. Provides operations for appending plain and styled text, wrapping regions in ruby or orientation spans, and applying style modifications while constructing a vertical-text Spanned.

Instances are not intended to be implemented by library consumers.

Summary

Public functions

Unit

Appends text and wraps it in a TextOrientationSpan.CombineUpright span: all of the appended characters are combined horizontally and laid out within a single vertical slot (tate-chu-yoko).

Unit

Appends text and wraps it in a TextOrientationSpan.Sideways span: every glyph is rotated 90° clockwise regardless of its script.

Unit
text(text: CharSequence, rubyMap: Map<StringString>)

Appends text.

Unit

Appends text and wraps it in a TextOrientationSpan.Upright span: every glyph is drawn upright regardless of its script.

R
<R : Any> withEmphasis(
    style: EmphasisStyle,
    filled: Boolean,
    scale: Float,
    block: VerticalTextScope.() -> R
)

Runs block and wraps the range it appends with an EmphasisSpan that renders emphasis marks (傍点) alongside each character.

R
<R : Any> withRuby(
    ruby: CharSequence,
    position: AnnotationPosition,
    orientation: TextOrientation,
    textScale: Float,
    block: VerticalTextScope.() -> R
)

Runs block and wraps the range it appends with a RubySpan annotating it with withRuby, with the given position, orientation and textScale.

R
<R : Any> withStyle(
    fontSize: TextUnit,
    textColor: Color,
    backgroundColor: Color,
    fontShear: Float,
    block: VerticalTextScope.() -> R
)

Runs block and wraps the range it appends with a MetricAffectingSpan applying the given fontSize, textColor, and/or backgroundColor to the paint used for that range.

Public functions

combineUpright

Added in 1.0.0-alpha06
fun combineUpright(text: CharSequence): Unit

Appends text and wraps it in a TextOrientationSpan.CombineUpright span: all of the appended characters are combined horizontally and laid out within a single vertical slot (tate-chu-yoko).

sideways

Added in 1.0.0-alpha06
fun sideways(text: CharSequence): Unit

Appends text and wraps it in a TextOrientationSpan.Sideways span: every glyph is rotated 90° clockwise regardless of its script.

text

Added in 1.0.0-alpha06
fun text(text: CharSequence, rubyMap: Map<StringString> = emptyMap()): Unit

Appends text. For each (key, reading) in rubyMap, every occurrence of key inside the just-appended text is annotated with a RubySpan carrying reading.

upright

Added in 1.0.0-alpha06
fun upright(text: CharSequence): Unit

Appends text and wraps it in a TextOrientationSpan.Upright span: every glyph is drawn upright regardless of its script.

withEmphasis

Added in 1.0.0-alpha06
fun <R : Any> withEmphasis(
    style: EmphasisStyle = EmphasisStyle.Dot,
    filled: Boolean = true,
    scale: Float = 0.5f,
    block: VerticalTextScope.() -> R
): R

Runs block and wraps the range it appends with an EmphasisSpan that renders emphasis marks (傍点) alongside each character.

Returns
R

the value returned by block.

withRuby

Added in 1.0.0-alpha06
fun <R : Any> withRuby(
    ruby: CharSequence,
    position: AnnotationPosition = RubySpan.DEFAULT_POSITION,
    orientation: TextOrientation = RubySpan.DEFAULT_ORIENTATION,
    textScale: Float = RubySpan.DEFAULT_TEXT_SCALE,
    block: VerticalTextScope.() -> R
): R

Runs block and wraps the range it appends with a RubySpan annotating it with withRuby, with the given position, orientation and textScale.

Ruby text is small annotation text (such as furigana) placed alongside the base text, commonly used to indicate pronunciation or provide a brief description.

Returns
R

the value returned by block.

withStyle

fun <R : Any> withStyle(
    fontSize: TextUnit = TextUnit.Unspecified,
    textColor: Color = Color.Unspecified,
    backgroundColor: Color = Color.Unspecified,
    fontShear: Float = Float.NaN,
    block: VerticalTextScope.() -> R
): R

Runs block and wraps the range it appends with a MetricAffectingSpan applying the given fontSize, textColor, and/or backgroundColor to the paint used for that range. If fontShear is provided, it also wraps the range in a FontShearSpan.

Sp values in fontSize are resolved using Density; em values scale the inherited paint size.

Returns
R

the value returned by block.