Skip to content

Commit

Permalink
fix(TTML): Add font-family mapping (shaka-project#4801)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed Dec 8, 2022
1 parent bd75032 commit db8987d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lib/text/ttml_text_parser.js
Expand Up @@ -574,8 +574,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 db8987d

Please sign in to comment.