# WebvttCssStyle

Artifact: [androidx.media3:media3-extractor](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/extractor/text/webvtt/WebvttCssStyle.java+class:androidx.media3.extractor.text.webvtt.WebvttCssStyle)

*** ** * ** ***


```
@UnstableApi
class WebvttCssStyle
```

<br />

*** ** * ** ***

Style object of a CSS style block in a WebVTT file.

See the [Apply CSS properties section of the W3C specification](https://w3c.github.io/webvtt/#applying-css-properties)

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/kotlin/androidx/annotation/IntDef(value = ) annotation https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle.FontSizeUnit` Font size unit enum. |
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/kotlin/androidx/annotation/IntDef(flag = true, value = ) annotation https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle.StyleFlags` Style flag enum. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#FONT_SIZE_UNIT_EM() = 2` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#FONT_SIZE_UNIT_PERCENT() = 3` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#FONT_SIZE_UNIT_PIXEL() = 1` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#STYLE_BOLD() = 1` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#STYLE_BOLD_ITALIC() = 3` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#STYLE_ITALIC() = 2` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#STYLE_NORMAL() = 0` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#UNSPECIFIED() = -1` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#WebvttCssStyle()()` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#getSpecificityScore(java.lang.String,java.lang.String,java.util.Set<java.lang.String>,java.lang.String)( id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?, tag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?, classes: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!, voice: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html? )` Returns a value in a score system compliant with the CSS Specificity rules. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle.StyleFlags https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#getStyle()()` Returns the style or `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#UNSPECIFIED()` when no style information is given. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#hasBackgroundColor()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#hasFontColor()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#isLinethrough()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#isUnderline()()` |
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setBold(boolean)(bold: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` |
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setItalic(boolean)(italic: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` |
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setLinethrough(boolean)(linethrough: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setTargetClasses(java.lang.String[])(targetClasses: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setTargetId(java.lang.String)(targetId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setTargetTagName(java.lang.String)(targetTag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setTargetVoice(java.lang.String)(targetVoice: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` |
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setUnderline(boolean)(underline: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#backgroundColor()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#combineUpright()` |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#fontColor()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#fontFamily()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#fontSize()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle.FontSizeUnit https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#fontSizeUnit()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/text/TextAnnotation.Position https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#rubyPosition()` |

## Constants

### FONT_SIZE_UNIT_EM

```
const val FONT_SIZE_UNIT_EM = 2: Int
```

### FONT_SIZE_UNIT_PERCENT

```
const val FONT_SIZE_UNIT_PERCENT = 3: Int
```

### FONT_SIZE_UNIT_PIXEL

```
const val FONT_SIZE_UNIT_PIXEL = 1: Int
```

### STYLE_BOLD

```
const val STYLE_BOLD = 1: Int
```

### STYLE_BOLD_ITALIC

```
const val STYLE_BOLD_ITALIC = 3: Int
```

### STYLE_ITALIC

```
const val STYLE_ITALIC = 2: Int
```

### STYLE_NORMAL

```
const val STYLE_NORMAL = 0: Int
```

### UNSPECIFIED

```
const val UNSPECIFIED = -1: Int
```

## Public constructors

### WebvttCssStyle

```
WebvttCssStyle()
```

## Public functions

### getSpecificityScore

```
fun getSpecificityScore(
    id: String?,
    tag: String?,
    classes: (Mutable)Set<String!>!,
    voice: String?
): Int
```

Returns a value in a score system compliant with the CSS Specificity rules.

The score works as follows:

- Id match adds 0x40000000 to the score.
- Each class and voice match adds 4 to the score.
- Tag matching adds 2 to the score.
- Universal selector matching scores 1.

See also [CSS Cascading](https://www.w3.org/TR/CSS2/cascade.html).

| Parameters |
|---|---|
| `id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | The id of the cue if present, `null` otherwise. |
| `tag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | Name of the tag, `null` if it refers to the entire cue. |
| `classes: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!` | An array containing the classes the tag belongs to. Must not be null. |
| `voice: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | Annotated voice if present, `null` otherwise. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The score of the match, zero if there is no match. |

### getStyle

```
@WebvttCssStyle.StyleFlags
fun getStyle(): Int
```

Returns the style or `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#UNSPECIFIED()` when no style information is given.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#UNSPECIFIED()`, `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#STYLE_NORMAL()`, `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#STYLE_BOLD()`, `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#STYLE_BOLD()` or `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/webvtt/WebvttCssStyle#STYLE_BOLD_ITALIC()`. |

### hasBackgroundColor

```
fun hasBackgroundColor(): Boolean
```

### hasFontColor

```
fun hasFontColor(): Boolean
```

### isLinethrough

```
fun isLinethrough(): Boolean
```

### isUnderline

```
fun isUnderline(): Boolean
```

### setBold

```
@CanIgnoreReturnValue
fun setBold(bold: Boolean): WebvttCssStyle!
```

### setItalic

```
@CanIgnoreReturnValue
fun setItalic(italic: Boolean): WebvttCssStyle!
```

### setLinethrough

```
@CanIgnoreReturnValue
fun setLinethrough(linethrough: Boolean): WebvttCssStyle!
```

### setTargetClasses

```
fun setTargetClasses(targetClasses: Array<String!>!): Unit
```

### setTargetId

```
fun setTargetId(targetId: String!): Unit
```

### setTargetTagName

```
fun setTargetTagName(targetTag: String!): Unit
```

### setTargetVoice

```
fun setTargetVoice(targetVoice: String!): Unit
```

### setUnderline

```
@CanIgnoreReturnValue
fun setUnderline(underline: Boolean): WebvttCssStyle!
```

## Public properties

### backgroundColor

```
var backgroundColor: Int
```

### combineUpright

```
var combineUpright: Boolean
```

### fontColor

```
var fontColor: @ColorInt Int
```

### fontFamily

```
var fontFamily: String?
```

### fontSize

```
var fontSize: Float
```

### fontSizeUnit

```
@WebvttCssStyle.FontSizeUnit
var fontSizeUnit: Int
```

### rubyPosition

```
@TextAnnotation.Position
var rubyPosition: Int
```