# 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
public final 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/androidx/annotation/IntDef(value = ) public annotation https://developer.android.com/reference/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/androidx/annotation/IntDef(flag = true, value = ) public annotation https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle.StyleFlags` Style flag enum. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#FONT_SIZE_UNIT_EM() = 2` |
| `static final int` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#FONT_SIZE_UNIT_PERCENT() = 3` |
| `static final int` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#FONT_SIZE_UNIT_PIXEL() = 1` |
| `static final int` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#STYLE_BOLD() = 1` |
| `static final int` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#STYLE_BOLD_ITALIC() = 3` |
| `static final int` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#STYLE_ITALIC() = 2` |
| `static final int` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#STYLE_NORMAL() = 0` |
| `static final int` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#UNSPECIFIED() = -1` |

| ### Public fields |
|---|---|
| `int` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#backgroundColor()` |
| `boolean` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#combineUpright()` |
| `@https://developer.android.com/reference/androidx/annotation/ColorInt int` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#fontColor()` |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#fontFamily()` |
| `float` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#fontSize()` |
| `int` | `@https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle.FontSizeUnit https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#fontSizeUnit()` |
| `int` | `@https://developer.android.com/reference/androidx/media3/common/text/TextAnnotation.Position https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#rubyPosition()` |

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

| ### Public methods |
|---|---|
| `int` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#getBackgroundColor()()` |
| `boolean` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#getCombineUpright()()` |
| `int` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#getFontColor()()` |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#getFontFamily()()` |
| `float` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#getFontSize()()` |
| `int` | `@https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle.FontSizeUnit https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#getFontSizeUnit()()` |
| `int` | `@https://developer.android.com/reference/androidx/media3/common/text/TextAnnotation.Position https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#getRubyPosition()()` |
| `int` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#getSpecificityScore(java.lang.String,java.lang.String,java.util.Set<java.lang.String>,java.lang.String)( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html id, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html tag, https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/java/lang/String.html> classes, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html voice )` Returns a value in a score system compliant with the CSS Specificity rules. |
| `int` | `@https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle.StyleFlags https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#getStyle()()` Returns the style or `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#UNSPECIFIED()` when no style information is given. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#hasBackgroundColor()()` |
| `boolean` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#hasFontColor()()` |
| `boolean` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#isLinethrough()()` |
| `boolean` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#isUnderline()()` |
| `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setBackgroundColor(int)(int backgroundColor)` |
| `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setBold(boolean)(boolean bold)` |
| `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setCombineUpright(boolean)(boolean enabled)` |
| `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setFontColor(int)(int color)` |
| `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setFontFamily(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html fontFamily)` |
| `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setFontSize(float)(float fontSize)` |
| `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setFontSizeUnit(int)(@https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle.FontSizeUnit int unit)` |
| `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setItalic(boolean)(boolean italic)` |
| `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setLinethrough(boolean)(boolean linethrough)` |
| `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setRubyPosition(int)(@https://developer.android.com/reference/androidx/media3/common/text/TextAnnotation.Position int rubyPosition)` |
| `void` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setTargetClasses(java.lang.String[])(String[] targetClasses)` |
| `void` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setTargetId(java.lang.String)(https://developer.android.com/reference/java/lang/String.html targetId)` |
| `void` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setTargetTagName(java.lang.String)(https://developer.android.com/reference/java/lang/String.html targetTag)` |
| `void` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setTargetVoice(java.lang.String)(https://developer.android.com/reference/java/lang/String.html targetVoice)` |
| `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#setUnderline(boolean)(boolean underline)` |

## Constants

### FONT_SIZE_UNIT_EM

```
public static final int FONT_SIZE_UNIT_EM = 2
```

### FONT_SIZE_UNIT_PERCENT

```
public static final int FONT_SIZE_UNIT_PERCENT = 3
```

### FONT_SIZE_UNIT_PIXEL

```
public static final int FONT_SIZE_UNIT_PIXEL = 1
```

### STYLE_BOLD

```
public static final int STYLE_BOLD = 1
```

### STYLE_BOLD_ITALIC

```
public static final int STYLE_BOLD_ITALIC = 3
```

### STYLE_ITALIC

```
public static final int STYLE_ITALIC = 2
```

### STYLE_NORMAL

```
public static final int STYLE_NORMAL = 0
```

### UNSPECIFIED

```
public static final int UNSPECIFIED = -1
```

## Public fields

### backgroundColor

```
public int backgroundColor
```

### combineUpright

```
public boolean combineUpright
```

### fontColor

```
public @ColorInt int fontColor
```

### fontFamily

```
public @Nullable String fontFamily
```

### fontSize

```
public float fontSize
```

### fontSizeUnit

```
@WebvttCssStyle.FontSizeUnit
public int fontSizeUnit
```

### rubyPosition

```
@TextAnnotation.Position
public int rubyPosition
```

## Public constructors

### WebvttCssStyle

```
public WebvttCssStyle()
```

## Public methods

### getBackgroundColor

```
public int getBackgroundColor()
```

### getCombineUpright

```
public boolean getCombineUpright()
```

### getFontColor

```
public int getFontColor()
```

### getFontFamily

```
public @Nullable String getFontFamily()
```

### getFontSize

```
public float getFontSize()
```

### getFontSizeUnit

```
@WebvttCssStyle.FontSizeUnit
public int getFontSizeUnit()
```

### getRubyPosition

```
@TextAnnotation.Position
public int getRubyPosition()
```

### getSpecificityScore

```
public int getSpecificityScore(
    @Nullable String id,
    @Nullable String tag,
    Set<String> classes,
    @Nullable String voice
)
```

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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html id` | The id of the cue if present, `null` otherwise. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html tag` | Name of the tag, `null` if it refers to the entire cue. |
| `https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/java/lang/String.html> classes` | An array containing the classes the tag belongs to. Must not be null. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html voice` | Annotated voice if present, `null` otherwise. |

| Returns |
|---|---|
| `int` | The score of the match, zero if there is no match. |

### getStyle

```
@WebvttCssStyle.StyleFlags
public int getStyle()
```

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

| Returns |
|---|---|
| `int` | `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#UNSPECIFIED()`, `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#STYLE_NORMAL()`, `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#STYLE_BOLD()`, `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#STYLE_BOLD()` or `https://developer.android.com/reference/androidx/media3/extractor/text/webvtt/WebvttCssStyle#STYLE_BOLD_ITALIC()`. |

### hasBackgroundColor

```
public boolean hasBackgroundColor()
```

### hasFontColor

```
public boolean hasFontColor()
```

### isLinethrough

```
public boolean isLinethrough()
```

### isUnderline

```
public boolean isUnderline()
```

### setBackgroundColor

```
@CanIgnoreReturnValue
public WebvttCssStyle setBackgroundColor(int backgroundColor)
```

### setBold

```
@CanIgnoreReturnValue
public WebvttCssStyle setBold(boolean bold)
```

### setCombineUpright

```
@CanIgnoreReturnValue
public WebvttCssStyle setCombineUpright(boolean enabled)
```

### setFontColor

```
@CanIgnoreReturnValue
public WebvttCssStyle setFontColor(int color)
```

### setFontFamily

```
@CanIgnoreReturnValue
public WebvttCssStyle setFontFamily(@Nullable String fontFamily)
```

### setFontSize

```
@CanIgnoreReturnValue
public WebvttCssStyle setFontSize(float fontSize)
```

### setFontSizeUnit

```
@CanIgnoreReturnValue
public WebvttCssStyle setFontSizeUnit(@WebvttCssStyle.FontSizeUnit int unit)
```

### setItalic

```
@CanIgnoreReturnValue
public WebvttCssStyle setItalic(boolean italic)
```

### setLinethrough

```
@CanIgnoreReturnValue
public WebvttCssStyle setLinethrough(boolean linethrough)
```

### setRubyPosition

```
@CanIgnoreReturnValue
public WebvttCssStyle setRubyPosition(@TextAnnotation.Position int rubyPosition)
```

### setTargetClasses

```
public void setTargetClasses(String[] targetClasses)
```

### setTargetId

```
public void setTargetId(String targetId)
```

### setTargetTagName

```
public void setTargetTagName(String targetTag)
```

### setTargetVoice

```
public void setTargetVoice(String targetVoice)
```

### setUnderline

```
@CanIgnoreReturnValue
public WebvttCssStyle setUnderline(boolean underline)
```