0

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???

enter image description here

Vincent
  • 3,124
  • 3
  • 21
  • 40

1 Answers1

0

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.

Richard Zhang
  • 7,523
  • 1
  • 7
  • 13
  • 12 seems too small and is't cc's font size. I set default to 50 and looks OK. – Vincent Jun 11 '20 at 10:13
  • I wonder if anyone can view the source code or is there any information about the CC control. Also I can't find cc control in `MediaTransportControls.xaml` – Vincent Jun 11 '20 at 10:27
  • Hello, I'm sorry I didn't explain clearly, I have modified my answer. The font size of Closed Caption is affected by many factors and cannot be expressed with an exact value – Richard Zhang Jun 11 '20 at 11:06
  • Hmm, we want to create a second cc, the same size. It seems now way now... – Vincent Jun 11 '20 at 12:07
  • Currently `MediaPlayerElement` does not support displaying two closed caption at the same time. So you can consider modifying the SRT file to bilingual subtitles, or use `ViewBox` as the container for the second CC control, overlaid on `MediaPlayerPresenter` (need to modify the control template of `MediaPlayerElement`). – Richard Zhang Jun 11 '20 at 12:14
  • Modify srt seems impossible, cause we use srt returned from server. So I will open another question, can you create a sample using viewbox? – Vincent Jun 11 '20 at 12:19
  • I made some attempts and answered it in your another question – Richard Zhang Jun 11 '20 at 13:30