How to get system's closed caption font size?

不羁岁月 提交于 2020-06-17 15:47:29

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/62321361/how-to-get-systems-closed-caption-font-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!