# RubySpan

Artifact: [androidx.text:text-vertical](https://developer.android.com/jetpack/androidx/releases/text) [View Source](https://cs.android.com/search?q=file:androidx/text/vertical/RubySpan.kt+class:androidx.text.vertical.RubySpan) Added in [1.0.0-beta03](https://developer.android.com/jetpack/androidx/releases/text#1.0.0-beta03)

*** ** * ** ***


```
class RubySpan : ReplacementSpan
```

<br />

|---|---|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||||
| ↳ | [android.text.style.CharacterStyle](https://developer.android.com/reference/android/text/style/CharacterStyle.html) ||||
|   | ↳ | [android.text.style.MetricAffectingSpan](https://developer.android.com/reference/android/text/style/MetricAffectingSpan.html) |||
|   |   | ↳ | [android.text.style.ReplacementSpan](https://developer.android.com/reference/android/text/style/ReplacementSpan.html) ||
|   |   |   | ↳ | [androidx.text.vertical.RubySpan](https://developer.android.com/reference/kotlin/androidx/text/vertical/RubySpan) |

*** ** * ** ***

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 `https://developer.android.com/reference/kotlin/androidx/text/vertical/RubySpan#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](https://en.wikipedia.org/wiki/Ruby_character) and [span styling](https://developer.android.com/guide/topics/text/spans).

This span is designed for use with `https://developer.android.com/reference/kotlin/androidx/text/vertical/VerticalTextLayout` and also other general use cases.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/text/vertical/RubySpan#DEFAULT_TEXT_SCALE() = 0.5f` |

| ### Public companion properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/text/vertical/TextOrientation` | `https://developer.android.com/reference/kotlin/androidx/text/vertical/RubySpan#DEFAULT_ORIENTATION()` |
| `https://developer.android.com/reference/kotlin/androidx/text/vertical/AnnotationPosition` | `https://developer.android.com/reference/kotlin/androidx/text/vertical/RubySpan#DEFAULT_POSITION()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/text/vertical/RubySpan#RubySpan(kotlin.CharSequence,androidx.text.vertical.AnnotationPosition,androidx.text.vertical.TextOrientation,kotlin.Float)( text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html, position: https://developer.android.com/reference/kotlin/androidx/text/vertical/AnnotationPosition, orientation: https://developer.android.com/reference/kotlin/androidx/text/vertical/TextOrientation, textScale: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` |

| ### Public functions |
|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/text/vertical/RubySpan#draw(android.graphics.Canvas,kotlin.CharSequence,kotlin.Int,kotlin.Int,kotlin.Float,kotlin.Int,kotlin.Int,kotlin.Int,android.graphics.Paint)( canvas: https://developer.android.com/reference/android/graphics/Canvas.html, text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?, start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, x: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, top: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, y: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, bottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, paint: https://developer.android.com/reference/android/graphics/Paint.html )` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/text/vertical/RubySpan#getSize(android.graphics.Paint,kotlin.CharSequence,kotlin.Int,kotlin.Int,android.graphics.Paint.FontMetricsInt)( paint: https://developer.android.com/reference/android/graphics/Paint.html, text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?, start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, fm: https://developer.android.com/reference/android/graphics/Paint.FontMetricsInt.html? )` |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/text/vertical/TextOrientation` | `https://developer.android.com/reference/kotlin/androidx/text/vertical/RubySpan#orientation()` The text orientation of the ruby text. |
| `https://developer.android.com/reference/kotlin/androidx/text/vertical/AnnotationPosition` | `https://developer.android.com/reference/kotlin/androidx/text/vertical/RubySpan#position()` The position of ruby text relative to the base text. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html` | `https://developer.android.com/reference/kotlin/androidx/text/vertical/RubySpan#text()` The ruby text to be displayed adjacent to the base text. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/text/vertical/RubySpan#textScale()` The text scale ratio of the ruby text relative to the base text. |

### Inherited functions

From [android.text.style.ReplacementSpan](https://developer.android.com/reference/android/text/style/ReplacementSpan.html) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/text/style/ReplacementSpan.html#updateDrawState(android.text.TextPaint)(ds: https://developer.android.com/reference/android/text/TextPaint.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/text/style/ReplacementSpan.html#updateMeasureState(android.text.TextPaint)(p: https://developer.android.com/reference/android/text/TextPaint.html)`

### Inherited properties

From [android.text.style.MetricAffectingSpan](https://developer.android.com/reference/android/text/style/MetricAffectingSpan.html) `open https://developer.android.com/reference/android/text/style/MetricAffectingSpan.html` `https://developer.android.com/reference/android/text/style/MetricAffectingSpan.html#underlying` From [android.text.style.ReplacementSpan](https://developer.android.com/reference/android/text/style/ReplacementSpan.html) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` `https://developer.android.com/reference/android/text/style/ReplacementSpan.html#contentDescription`

## Constants

### DEFAULT_TEXT_SCALE

```
const val DEFAULT_TEXT_SCALE = 0.5f: Float
```

## Public companion properties

### DEFAULT_ORIENTATION

```
val DEFAULT_ORIENTATION: TextOrientation
```

### DEFAULT_POSITION

```
val DEFAULT_POSITION: AnnotationPosition
```

## Public constructors

### RubySpan

Added in [1.0.0-beta03](https://developer.android.com/jetpack/androidx/releases/text#1.0.0-beta03)

```
RubySpan(
    text: CharSequence,
    position: AnnotationPosition = DEFAULT_POSITION,
    orientation: TextOrientation = DEFAULT_ORIENTATION,
    textScale: Float = DEFAULT_TEXT_SCALE
)
```

## Public functions

### draw

Added in [1.0.0-beta03](https://developer.android.com/jetpack/androidx/releases/text#1.0.0-beta03)

```
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-beta03](https://developer.android.com/jetpack/androidx/releases/text#1.0.0-beta03)

```
open fun getSize(
    paint: Paint,
    text: CharSequence?,
    start: Int,
    end: Int,
    fm: Paint.FontMetricsInt?
): Int
```

## Public properties

### orientation

Added in [1.0.0-beta03](https://developer.android.com/jetpack/androidx/releases/text#1.0.0-beta03)

```
val orientation: TextOrientation
```

The text orientation of the ruby text. Defaults to `https://developer.android.com/reference/kotlin/androidx/text/vertical/TextOrientation#Mixed`.

### position

Added in [1.0.0-beta03](https://developer.android.com/jetpack/androidx/releases/text#1.0.0-beta03)

```
val position: AnnotationPosition
```

The position of ruby text relative to the base text. Defaults to `https://developer.android.com/reference/kotlin/androidx/text/vertical/AnnotationPosition#Before()`.

### text

Added in [1.0.0-beta03](https://developer.android.com/jetpack/androidx/releases/text#1.0.0-beta03)

```
val text: CharSequence
```

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

### textScale

Added in [1.0.0-beta03](https://developer.android.com/jetpack/androidx/releases/text#1.0.0-beta03)

```
val textScale: Float
```

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