ExoPlayer
ExoPlayer copied to clipboard
TTML: Support tts:fontSize in Cell Size format
[REQUIRED] Use case description
ExoPlayer should support the specification of fontSize in cell dimension format. This format is specified in the corresponding W3C standard: https://www.w3.org/TR/2018/REC-ttml1-20181108/#style-attribute-fontSize
This format is used in the market. Currently it is not possible to decode these subtitles with ExoPlayer. The following log is output when a subtitle track is selected which uses this format:
W/TtmlDecoder: Failed parsing fontSize value: 0.80c
Currently ExoPlayer supports fontSize only in the following formats: px, em, %
Proposed solution
Implement cell dimension format in TtmlDecoder.java
Thanks for the feature request.
I just scanned through the spec and, given ExoPlayer generally uses proportional fonts (and so doesn't really have a concept of 'columns' as used in the Computed Cell Size definition), I'm wondering if we can treat the c suffix basically identical to em (since both are proportions of some 'normal' font size).
Does that sound like it would work?
Do you have some sample data along with a screenshot showing how you expect it to be rendered? That would help us to experiment with this.
@icbaker using em instead of c would very likely give strange results unless you set em based on the height of the cell unit somewhere (but if you do, it would be fine for this, but wrong for other reasons). Somehow the code already resolves % units, and they should be based on the height of the cell already, somewhere up the inheritance tree.
tt element sets number of rows as second component of ttp:cellResolution
region element sets computed font size for inheritance purposes: by default it is 100% of the cell height. E.g. if cell resolution says there are 20 rows, then the 100% font size would be 1/20 = 5% of the rendering area height.
body -> div -> p -> span can use % or em units to get a size relative to the parent element's computed font size, or absolute units such as c to specify in terms of number of cells.
Hello,
I'm reopening an old ticket. We implemented a hack on our side by treating "c" as "em":
private static final Pattern FONT_SIZE = Pattern.compile("^(([0-9]*.)?[0-9]+)(px|em|%|c)$");
// Around line 792
case "em":
case "c":
It works well for our use case. Perhaps this could serve as a quick fix, with a TODO added for further improvements, or the ticket could remain open.