# EmphasisSpan

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/EmphasisSpan.kt+class:androidx.text.vertical.EmphasisSpan) Added in [1.0.0-beta03](https://developer.android.com/jetpack/androidx/releases/text#1.0.0-beta03)

*** ** * ** ***


```
public final class EmphasisSpan extends ReplacementSpan
```

<br />

|---|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.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.EmphasisSpan](https://developer.android.com/reference/androidx/text/vertical/EmphasisSpan) |

*** ** * ** ***

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

This span is designed for use with `https://developer.android.com/reference/androidx/text/vertical/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` | `https://developer.android.com/reference/androidx/text/vertical/EmphasisSpan#DEFAULT_EMPHASIS_FILL() = true` The default value for whether the emphasis mark should be filled. |
| `static final float` | `https://developer.android.com/reference/androidx/text/vertical/EmphasisSpan#DEFAULT_SCALE() = 0.5f` The default scale factor for emphasis marks. |

| ### Public fields |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/text/vertical/EmphasisStyle` | `https://developer.android.com/reference/androidx/text/vertical/EmphasisSpan#DEFAULT_EMPHASIS_STYLE()` The default style used for emphasis marks, typically a dot. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/text/vertical/AnnotationPosition` | `https://developer.android.com/reference/androidx/text/vertical/EmphasisSpan#DEFAULT_POSITION()` The default position of the emphasis mark relative to the text. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/text/vertical/EmphasisSpan#EmphasisSpan(androidx.text.vertical.EmphasisStyle,kotlin.Boolean,androidx.text.vertical.AnnotationPosition,kotlin.Float)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/text/vertical/EmphasisStyle style, boolean isFilled, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/text/vertical/AnnotationPosition position, float scale )` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/text/vertical/EmphasisSpan#draw(android.graphics.Canvas,kotlin.CharSequence,kotlin.Int,kotlin.Int,kotlin.Float,kotlin.Int,kotlin.Int,kotlin.Int,android.graphics.Paint)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Canvas.html canvas, https://developer.android.com/reference/java/lang/CharSequence.html text, int start, int end, float x, int top, int y, int bottom, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Paint.html paint )` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/text/vertical/AnnotationPosition` | `https://developer.android.com/reference/androidx/text/vertical/EmphasisSpan#getPosition()()` The position of the emphasis mark relative to the text. |
| `final float` | `https://developer.android.com/reference/androidx/text/vertical/EmphasisSpan#getScale()()` The scale factor for the size of the mark. |
| `int` | `https://developer.android.com/reference/androidx/text/vertical/EmphasisSpan#getSize(android.graphics.Paint,kotlin.CharSequence,kotlin.Int,kotlin.Int,android.graphics.Paint.FontMetricsInt)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Paint.html paint, https://developer.android.com/reference/java/lang/CharSequence.html text, int start, int end, https://developer.android.com/reference/android/graphics/Paint.FontMetricsInt.html fm )` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/text/vertical/EmphasisStyle` | `https://developer.android.com/reference/androidx/text/vertical/EmphasisSpan#getStyle()()` The style of the emphasis mark. |
| `final boolean` | `https://developer.android.com/reference/androidx/text/vertical/EmphasisSpan#isFilled()()` Whether the mark should be filled or outlined. |

### Inherited methods

From [android.text.style.MetricAffectingSpan](https://developer.android.com/reference/android/text/style/MetricAffectingSpan.html) `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/text/style/MetricAffectingSpan.html` `https://developer.android.com/reference/android/text/style/MetricAffectingSpan.html#getUnderlying()()` From [android.text.style.ReplacementSpan](https://developer.android.com/reference/android/text/style/ReplacementSpan.html) `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/CharSequence.html` `https://developer.android.com/reference/android/text/style/ReplacementSpan.html#getContentDescription()()` `void` `https://developer.android.com/reference/android/text/style/ReplacementSpan.html#setContentDescription(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence.html contentDescription)` `void` `https://developer.android.com/reference/android/text/style/ReplacementSpan.html#updateDrawState(android.text.TextPaint)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/text/TextPaint.html ds)` `void` `https://developer.android.com/reference/android/text/style/ReplacementSpan.html#updateMeasureState(android.text.TextPaint)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/text/TextPaint.html p)`

## 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
```

The default position of the emphasis mark relative to the text.

## Public constructors

### EmphasisSpan

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

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/text/vertical/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. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/text/vertical/AnnotationPosition position` | The position of the emphasis mark relative to the text. `https://developer.android.com/reference/androidx/text/vertical/AnnotationPosition#Before()` puts the mark on the right side in vertical writing mode and above the text in horizontal writing mode. `https://developer.android.com/reference/androidx/text/vertical/AnnotationPosition#After()` puts it on the opposite side. |
| `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-beta03](https://developer.android.com/jetpack/androidx/releases/text#1.0.0-beta03)

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

```
public final @NonNull AnnotationPosition getPosition()
```

The position of the emphasis mark relative to the text. `https://developer.android.com/reference/androidx/text/vertical/AnnotationPosition#Before()` puts the mark on the right side in vertical writing mode and above the text in horizontal writing mode. `https://developer.android.com/reference/androidx/text/vertical/AnnotationPosition#After()` puts it on the opposite side.

### getScale

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

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

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

### getStyle

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

```
public final @NonNull EmphasisStyle getStyle()
```

The style of the emphasis mark.

### isFilled

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

```
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.