EmphasisSpan


class EmphasisSpan : ReplacementSpan


A span that applies emphasis marks to text in a vertical layout.

This span is designed for use with VerticalTextLayout and will not have an effect in other contexts. It allows for the application of various emphasis styles, such as dots, circles, or triangles, above or next to characters in vertical text.

The EmphasisSpan takes a style, a boolean indicating whether the mark should be filled, and a scale factor for the size of the mark.

Summary

Constants

const Boolean

The default value for whether the emphasis mark should be filled.

const Float

The default scale factor for emphasis marks.

Public companion properties

EmphasisStyle

The default style used for emphasis marks, typically a dot.

AnnotationPosition

Public constructors

EmphasisSpan(
    style: EmphasisStyle,
    isFilled: Boolean,
    position: AnnotationPosition,
    scale: 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

Boolean

Whether the mark should be filled or outlined.

AnnotationPosition

The position of the emphasis mark relative to the text.

Float

The scale factor for the size of the mark.

EmphasisStyle

The style of the emphasis mark.

Constants

DEFAULT_EMPHASIS_FILL

const val DEFAULT_EMPHASIS_FILL = true: Boolean

The default value for whether the emphasis mark should be filled.

DEFAULT_SCALE

const val DEFAULT_SCALE = 0.5f: Float

The default scale factor for emphasis marks.

Public companion properties

DEFAULT_EMPHASIS_STYLE

val DEFAULT_EMPHASIS_STYLEEmphasisStyle

The default style used for emphasis marks, typically a dot.

DEFAULT_POSITION

val DEFAULT_POSITIONAnnotationPosition

Public constructors

EmphasisSpan

Added in 1.0.0-alpha04
EmphasisSpan(
    style: EmphasisStyle = DEFAULT_EMPHASIS_STYLE,
    isFilled: Boolean = DEFAULT_EMPHASIS_FILL,
    position: AnnotationPosition = AnnotationPosition.Before,
    scale: Float = DEFAULT_SCALE
)
Parameters
style: EmphasisStyle = DEFAULT_EMPHASIS_STYLE

The style of the emphasis mark.

isFilled: Boolean = DEFAULT_EMPHASIS_FILL

Whether the mark should be filled or outlined. When true, the emphasis mark will be drawn as a solid shape. When false, it will be drawn as an outline.

position: AnnotationPosition = AnnotationPosition.Before

The position of the emphasis mark relative to the text. NOTE: this is reserved value, to be implemented (b/495457561).

scale: Float = DEFAULT_SCALE

The scale factor for the size of the mark. This value determines the size of the emphasis mark relative to the font size. A scale of 0.5f means the emphasis mark will be half the size of the text.

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

isFilled

Added in 1.0.0-alpha04
val isFilledBoolean

Whether the mark should be filled or outlined. When true, the emphasis mark will be drawn as a solid shape. When false, it will be drawn as an outline.

position

Added in 1.0.0-alpha04
val positionAnnotationPosition

The position of the emphasis mark relative to the text. NOTE: this is reserved value, to be implemented (b/495457561).

scale

Added in 1.0.0-alpha04
val scaleFloat

The scale factor for the size of the mark. This value determines the size of the emphasis mark relative to the font size. A scale of 0.5f means the emphasis mark will be half the size of the text.

style

Added in 1.0.0-alpha04
val styleEmphasisStyle

The style of the emphasis mark.