如何获取系统的隐藏字幕字体大小? [英] How to get system's closed caption font size?
问题描述
我想获取系统的隐藏字幕字体样式,参考了
枚举不给出具体值,而是给出一个百分比.显然你也注意到了这一点.
百分比取决于参考值.一般来说,UWP 最常见的默认字体大小是 14,但在 MediaTransportControls 中,默认字体大小通常是 12.
所以 Windows.Media.ClosedCaptioning.ClosedCaptionSize.OneHundredFiftyPercent
应该是 12*1.5=18.
更新
抱歉,我需要进一步说明 CC 的字体大小.
CC的大小受多种因素影响:
1.字幕文件本身的设置.
例如,SRT 文件支持字体设置.{\fs25}
表示一行字幕,FontSize
为 25,Foreground
为红色.
2.受当前窗口大小的影响
显示字幕的控件集成在TimedTextSourcePresenter
(MediaPlayerElement 内的网格)中.对于TimedTextSourcePresenter
,您可以将其视为一个ViewBox
.它将根据当前控件的大小缩放内部元素.
总而言之,MediaPlayerElement
中的 Closed Caption 有一个基本字体大小,但这个字体大小不一定等于最终呈现的字体大小.
谢谢.
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.
这篇关于如何获取系统的隐藏字幕字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!