Please sign in to comment.
Subtitles: Allow the theme to customize caption/subtitle formatting.
Subtitle format specification, e.g. the choice of font and background, is moved into the theme's osd_subtitle.xml file, in the osd_subtitle window. Separate controls are given for text, teletext, CEA-608, and the 8 CEA-708 fonts. Subtitle types are named text, teletext, 608, 708_0, 708_1, ..., 708_7. Each subtitle type has a fontdef component for the text and a shape component for the background. By default, the attributes of a subtitle type come from either the provider (e.g. text color, italics) or the system default (e.g. font family). These attributes can be overridden by the xml file. The names of the fontdef and the background shape are both simply the name of the subtitle type. The fontdef and shape should ultimately inherit from the special value "provider", otherwise all provider values will be ignored. The following example forces .srt subtitles to be rendered in yellow text, FreeSans font, black shadow, with a translucent black background. The fontdef and shape names are "text" since the subtitles come from a .srt file. Note that in this example, color formatting controls in the .srt file will be ignored due to the explicit setting of yellow text. <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE mythuitheme SYSTEM "http://www.mythtv.org/schema/mythuitheme.dtd"> <mythuitheme> <window name="osd_subtitle"> <fontdef name="text" face="FreeSans" from="provider"> <color>#FFFF00</color> <shadowoffset>2,2</shadowoffset> <shadowcolor>#000000</shadowcolor> </fontdef> <shape name="text" from="provider"> <fill color="#000000" alpha="100" /> </shape> </window> </mythuitheme> The settings CCBackground and DefaultSubtitleFont are no longer necessary and have been removed. Teletext does not yet use this mechanism, but some temporary code allows the teletext font to be taken from osd_subtitle.xml rather than the DefaultSubtitleFont setting. Note that as before, the frontend must be restarted for teletext font changes to take effect (this will be fixed in the future). All elements/attributes of fontdef and shape can be used. Note however that area and position are explicitly ignored, as these are dictated by the subtitle layout. The default values for the specific fonts are kept unchanged from the original code (except that a proportional font is now used for text subtitles). Note that some of these fonts, particularly many of the CEA-708 fonts, were somewhat arbitrarily chosen and aren't necessarily present on the user's system, so we will need to settle on the precise set of fonts and likely include them in the MythTV fonts directory. These changes are implemented with almost no MythUI modifications (the only such change is to make the new helper class a friend of MythUIShape in order to get access to some protected members). The basic idea is to construct two different "provider" objects; then parse osd_subtitle.xml twice with respect to each provider object; and finally compare the resulting objects, attribute by attribute, to discover which attributes are fixed by the theme and which the provider may control. This is done once to collect the set of attributes, and the results are cached and used for drawing each subtitle.
- Loading branch information...
Showing with 716 additions and 227 deletions.
- +2 −3 mythtv/libs/libmythtv/cc708window.h
- +623 −167 mythtv/libs/libmythtv/subtitlescreen.cpp
- +27 −25 mythtv/libs/libmythtv/subtitlescreen.h
- +6 −1 mythtv/libs/libmythtv/teletextscreen.cpp
- +1 −0 mythtv/libs/libmythui/mythuishape.h
- +0 −31 mythtv/programs/mythfrontend/globalsettings.cpp
- +57 −0 mythtv/themes/default/osd_subtitle.xml
Oops, something went wrong.