google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.7k stars 6.01k forks source link

Allow Cue to specify monospace font, size of character grid etc #4173

Open goffioul opened 6 years ago

goffioul commented 6 years ago

I'm implementing a teletext decoder in ExoPlayer and I'm looking for advises about font/line sizing. Teletext uses a matrix of characters, 24 lines, 40 columns. But it doesn't seem that this size information can be conveyed through Cue objects for correct rendering. SubtitleView uses a default font size of 5.33% of the viewport height, but the actual line height (including font ascent and descent) is larger than that, and only 13 lines of text can actually fit on screen (I'm using monospace font; the screen height is 768px, the computed font size is ~40px and the actual line height is 56px). The decoder does not seem to have any way to let the SubtitleView know about the size of the expected character grid. What would be the recommended approach to address this problem?

ojw28 commented 6 years ago

To check I've understood the problem: Am I correct to summarize your issue as being that Cue does not have a way to specify line height? I think you're right for text cues (i.e. there is no way of doing this). I'm not particularly keen on allowing sources to be very prescriptive about exactly how text cues should be rendered. It conflicts with other requirements such as allowing the user to specify their own text size, font etc (e.g. for accessibility). If you need to be very prescriptive, then I'd suggest one of two solutions:

The latter is probably more effort, but also more efficient.

goffioul commented 6 years ago

Yes, the problem is about Cue's line height. I don't particularly like the second option, as it moves the problem at the application level: the app now needs to be aware of the specifications for the selected subtitle track (teletext = 24 lines, CEA608 = 15 lines, ...) and size the font accordingly. I don't think that's something the application should be doing.

As you said, the only other option is to do the rendering in the decoder instead.

Note that in the process, I ran into other limitations of text-based Cue's, which also affect the CEA608 decoder: