I want to get system's closed caption font style, and I referd doc. So far everything is good, except the font size.
According to doc, ClosedCaptionProperties.FontSize
returns enum ClosedCaptionSize
, see code
switch (Windows.Media.ClosedCaptioning.ClosedCaptionProperties.FontSize)
{
case Windows.Media.ClosedCaptioning.ClosedCaptionSize.FiftyPercent:
richtextblock.FontSize = 50;
break;
case Windows.Media.ClosedCaptioning.ClosedCaptionSize.OneHundredPercent:
richtextblock.FontSize = 100;
break;
case Windows.Media.ClosedCaptioning.ClosedCaptionSize.OneHundredFiftyPercent:
richtextblock.FontSize = 150;
break;
case Windows.Media.ClosedCaptioning.ClosedCaptionSize.TwoHundredPercent:
richtextblock.FontSize = 200;
break;
default:
richtextblock.FontSize = 100;
break;
}
I set FontSize
to the corresponding number, although I know it's a percentage.
The final reslut is different from system.
So what's the exact FontSize
of these enums???
The enumeration does not give a specific value, but a percentage. Obviously you also noticed this.
The percentage depends on a reference value. Generally speaking, the most common default font size of UWP is 14, but in MediaTransportControls, the default font size is usually 12.
So Windows.Media.ClosedCaptioning.ClosedCaptionSize.OneHundredFiftyPercent
should be 12*1.5=18.
Update
Sorry, I need to explain further about the font size of the CC.
The size of CC is affected by many factors:
1. The settings of the subtitle file itself.
For example, SRT file support font setting. <font color="red">{\fs25}
means a line of subtitles with a FontSize
of 25 and a Foreground
of red.
2. Affected by the size of the current window
The controls for displaying subtitles are integrated in TimedTextSourcePresenter
(a Grid inside MediaPlayerElement). For TimedTextSourcePresenter
, you can think of it as a ViewBox
. It will scale the internal elements according to the size of the current control.
In summary, the Closed Caption in MediaPlayerElement
has a base font size, but this font size is not necessarily equal to the font size finally rendered.
Thanks.