Skip to content

Commit

Permalink
fix(TTML): Add font-family mapping (#4801)
Browse files Browse the repository at this point in the history
Closes #4749
  • Loading branch information
avelad authored and joeyparrish committed Dec 8, 2022
1 parent be98ae3 commit 7e93455
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lib/text/ttml_text_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,28 @@ shaka.text.TtmlTextParser = class {

const fontFamily = TtmlTextParser.getStyleAttribute_(
cueElement, region, styles, 'fontFamily', shouldInheritRegionStyles);
// See https://github.com/sandflow/imscJS/blob/1.1.3/src/main/js/html.js#L1384
if (fontFamily) {
cue.fontFamily = fontFamily;
switch (fontFamily) {
case 'monospaceSerif':
cue.fontFamily = 'Courier New,Liberation Mono,Courier,monospace';
break;
case 'proportionalSansSerif':
cue.fontFamily = 'Arial,Helvetica,Liberation Sans,sans-serif';
break;
case 'sansSerif':
cue.fontFamily = 'sans-serif';
break;
case 'monospaceSansSerif':
cue.fontFamily = 'Consolas,monospace';
break;
case 'proportionalSerif':
cue.fontFamily = 'serif';
break;
default:
cue.fontFamily = fontFamily;
break;
}
}

const fontWeight = TtmlTextParser.getStyleAttribute_(
Expand Down

0 comments on commit 7e93455

Please sign in to comment.