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
  • Loading branch information
tykus160 committed Feb 26, 2024
1 parent b88303d commit d0e64d7
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
Expand Up @@ -661,6 +661,8 @@ 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
Expand All @@ -669,7 +671,6 @@ shaka.text.VttTextParser = class {
cue.opacity = refCue.opacity;
cue.rubyTag = refCue.rubyTag;
cue.textCombineUpright = refCue.textCombineUpright;
cue.textShadow = refCue.textShadow;
cue.wrapLine = refCue.wrapLine;
}

Expand Down
31 changes: 31 additions & 0 deletions test/text/vtt_text_parser_unit.js
Expand Up @@ -1148,6 +1148,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 d0e64d7

Please sign in to comment.