@UnstableApi
public final class WebvttCssStyle


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

See the Apply CSS properties section of the W3C specification

Summary

Nested types

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = TYPE_USE)
@IntDef(value = )
public annotation WebvttCssStyle.FontSizeUnit

Font size unit enum.

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = TYPE_USE)
@IntDef(flag = true, value = )
public annotation WebvttCssStyle.StyleFlags

Style flag enum.

Constants

static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int

Public constructors

Public methods

int
boolean
int
@Nullable String
float
int
int
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.

int

Returns the style or UNSPECIFIED when no style information is given.

boolean
boolean
boolean
boolean
WebvttCssStyle
WebvttCssStyle
WebvttCssStyle
WebvttCssStyle
WebvttCssStyle
WebvttCssStyle
WebvttCssStyle
WebvttCssStyle
WebvttCssStyle
@CanIgnoreReturnValue
setLinethrough(boolean linethrough)
WebvttCssStyle
void
setTargetClasses(String[] targetClasses)
void
setTargetId(String targetId)
void
void
setTargetVoice(String targetVoice)
WebvttCssStyle

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.

Parameters
@Nullable String id

The id of the cue if present, null otherwise.

@Nullable String tag

Name of the tag, null if it refers to the entire cue.

Set<String> classes

An array containing the classes the tag belongs to. Must not be null.

@Nullable String 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 UNSPECIFIED when no style information is given.

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)

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)