Skip to content

Commit

Permalink
fix(VTT): fix setting textShadow when multiple CSS classes provided (#…
Browse files Browse the repository at this point in the history
…6287)

Backported to v4.3.x
  • Loading branch information
tykus160 authored and joeyparrish committed Feb 27, 2024
1 parent e4d488d commit f96895b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/text/vtt_text_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,13 +673,14 @@ shaka.text.VttTextParser = class {
refCue.fontFamily, cue.fontFamily);
cue.fontSize = VttTextParser.getOrDefault_(
refCue.fontSize, cue.fontSize);
cue.textShadow = VttTextParser.getOrDefault_(
refCue.textShadow, cue.textShadow);

// Overwrite with new values as unable to determine
// if new value is set or not
cue.fontWeight = refCue.fontWeight;
cue.fontStyle = refCue.fontStyle;
cue.opacity = refCue.opacity;
cue.textShadow = refCue.textShadow;
cue.wrapLine = refCue.wrapLine;
}

Expand Down
31 changes: 31 additions & 0 deletions test/text/vtt_text_parser_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,37 @@ describe('VttTextParser', () => {
{periodStart: 0, segmentStart: 0, segmentEnd: 0, vttOffset: 0});
});

it('passes text-shadow when multiple classes included', () => {
verifyHelper(
[
{
startTime: 20,
endTime: 40,
payload: '',
nestedCues: [
{
startTime: 20,
endTime: 40,
payload: 'Test',
fontStyle: Cue.fontStyle.ITALIC,
textShadow: 'black 5%',
},
],
},
],
'WEBVTT\n\n' +
'STYLE\n' +
'::cue(.shadow) {\n' +
' text-shadow: black 5%;\n' +
'}\n' +
'::cue(.italic) {\n' +
' font-style: italic;\n' +
'}\n\n' +
'00:00:20.000 --> 00:00:40.000\n' +
'<c.shadow.italic>Test</c>',
{periodStart: 0, segmentStart: 0, segmentEnd: 0, vttOffset: 0});
});

it('supports karaoke style text', () => {
verifyHelper(
[
Expand Down

0 comments on commit f96895b

Please sign in to comment.