From 57780dd449e31da83c37badb65b0d3e71cf8524c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Thu, 8 Dec 2022 20:09:27 +0100 Subject: [PATCH] fix(TTML): Add font-family mapping (#4801) Closes https://github.com/shaka-project/shaka-player/issues/4749 --- lib/text/ttml_text_parser.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/text/ttml_text_parser.js b/lib/text/ttml_text_parser.js index 7bb70fe92c..ac07d6cfd8 100644 --- a/lib/text/ttml_text_parser.js +++ b/lib/text/ttml_text_parser.js @@ -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_(