Skip to content

Commit

Permalink
fix: Fix bitmap-based cue size (#4453)
Browse files Browse the repository at this point in the history
Without an explicit size, some platforms render bitmap-based cues as
0x0.  This effect was seen in Chrome on Mac in particular.  This
started with PR #4412, where we factored out regions into their own
element.

The TTML spec says that background images should fill their associated
region, so this fixes the issue by making the div explicitly the size
of its parent element (100% x 100%).
  • Loading branch information
joeyparrish authored Aug 30, 2022
1 parent 6b56ed7 commit 4a197e1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/text/ui_text_displayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,14 @@ shaka.text.UITextDisplayer = class {
style.backgroundRepeat = 'no-repeat';
style.backgroundSize = 'contain';
style.backgroundPosition = 'center';

// Quoting https://www.w3.org/TR/ttml-imsc1.2/:
// "The width and height (in pixels) of the image resource referenced by
// smpte:backgroundImage SHALL be equal to the width and height expressed
// by the tts:extent attribute of the region in which the div element is
// presented".
style.width = '100%';
style.height = '100%';
} else {
// If we have both text and nested cues, then style everything; otherwise
// place the text in its own <span> so the background doesn't fill the
Expand Down

0 comments on commit 4a197e1

Please sign in to comment.