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 authored and Rodolphe Breton committed Jan 27, 2023
1 parent 803a4de commit 7624a34
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 @@ -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 7624a34

Please sign in to comment.