EmphasisSpan


public final class EmphasisSpan extends 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

static final boolean

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

static final float

The default scale factor for emphasis marks.

Public fields

static final @NonNull EmphasisStyle

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

static final @NonNull AnnotationPosition

Public constructors

EmphasisSpan(
    @NonNull EmphasisStyle style,
    boolean isFilled,
    @NonNull AnnotationPosition position,
    float scale
)

Public methods

void
draw(
    @NonNull Canvas canvas,
    CharSequence text,
    int start,
    int end,
    float x,
    int top,
    int y,
    int bottom,
    @NonNull Paint paint
)
final @NonNull AnnotationPosition

The position of the emphasis mark relative to the text.

final float

The scale factor for the size of the mark.

int
getSize(
    @NonNull Paint paint,
    CharSequence text,
    int start,
    int end,
    Paint.FontMetricsInt fm
)
final @NonNull EmphasisStyle

The style of the emphasis mark.

final boolean

Whether the mark should be filled or outlined.

Constants

DEFAULT_EMPHASIS_FILL

public static final boolean DEFAULT_EMPHASIS_FILL = true

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

DEFAULT_SCALE

public static final float DEFAULT_SCALE = 0.5f

The default scale factor for emphasis marks.

Public fields

DEFAULT_EMPHASIS_STYLE

public static final @NonNull EmphasisStyle DEFAULT_EMPHASIS_STYLE

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

DEFAULT_POSITION

public static final @NonNull AnnotationPosition DEFAULT_POSITION

Public constructors

EmphasisSpan

Added in 1.0.0-alpha04
public EmphasisSpan(
    @NonNull EmphasisStyle style,
    boolean isFilled,
    @NonNull AnnotationPosition position,
    float scale
)
Parameters
@NonNull EmphasisStyle style

The style of the emphasis mark.

boolean isFilled

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.

@NonNull AnnotationPosition position

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

float 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 methods

draw

Added in 1.0.0-alpha04
public void draw(
    @NonNull Canvas canvas,
    CharSequence text,
    int start,
    int end,
    float x,
    int top,
    int y,
    int bottom,
    @NonNull Paint paint
)

getPosition

Added in 1.0.0-alpha04
public final @NonNull AnnotationPosition getPosition()

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

getScale

Added in 1.0.0-alpha04
public final float getScale()

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.

getSize

Added in 1.0.0-alpha04
public int getSize(
    @NonNull Paint paint,
    CharSequence text,
    int start,
    int end,
    Paint.FontMetricsInt fm
)

getStyle

Added in 1.0.0-alpha04
public final @NonNull EmphasisStyle getStyle()

The style of the emphasis mark.

isFilled

Added in 1.0.0-alpha04
public final boolean isFilled()

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.