UWP 中的系统字体大小?
system font size in UWP?
我有一个跨平台应用程序。该应用程序在内部计算出其所有字体大小相对于系统提供的基本大小。在 iOS 我通过调用
得到了这个
return UIFont.SystemFontSize;
在Mac,我通过调用
得到它
return NSFont.SystemFontSize;
在 Android 上,我必须使用屏幕 dpi 捏造一些东西。
uwp 是否提供系统字体大小?或者我也需要在上面捏造一些东西吗?
UWP 没有所有内容都基于的单一预定义字体大小,而是 generic.xaml 中定义的字体大小列表(所有默认控件都在其中)。
从该文件中获取一些尺寸:
<x:Double x:Key="ControlContentThemeFontSize">15</x:Double>
<x:Double x:Key="ContentControlFontSize">15</x:Double>
<x:Double x:Key="TextStyleLargeFontSize">18.14</x:Double>
<x:Double x:Key="TextStyleExtraLargeFontSize">25.5</x:Double>
如果您查看控件,您会注意到 ControlContentThemeFontSize
是用于大多数控件的常规文本大小。
<Style TargetType="Button">
...
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
...
<Style TargetType="TextBox">
...
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
您可以使用以下代码简单地从默认资源中检索任何密钥,这是 page/control/...:[=15=]
this.Resources["ControlContentThemeFontSize"]
我有一个跨平台应用程序。该应用程序在内部计算出其所有字体大小相对于系统提供的基本大小。在 iOS 我通过调用
得到了这个return UIFont.SystemFontSize;
在Mac,我通过调用
得到它return NSFont.SystemFontSize;
在 Android 上,我必须使用屏幕 dpi 捏造一些东西。
uwp 是否提供系统字体大小?或者我也需要在上面捏造一些东西吗?
UWP 没有所有内容都基于的单一预定义字体大小,而是 generic.xaml 中定义的字体大小列表(所有默认控件都在其中)。
从该文件中获取一些尺寸:
<x:Double x:Key="ControlContentThemeFontSize">15</x:Double>
<x:Double x:Key="ContentControlFontSize">15</x:Double>
<x:Double x:Key="TextStyleLargeFontSize">18.14</x:Double>
<x:Double x:Key="TextStyleExtraLargeFontSize">25.5</x:Double>
如果您查看控件,您会注意到 ControlContentThemeFontSize
是用于大多数控件的常规文本大小。
<Style TargetType="Button">
...
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
...
<Style TargetType="TextBox">
...
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
您可以使用以下代码简单地从默认资源中检索任何密钥,这是 page/control/...:[=15=]
this.Resources["ControlContentThemeFontSize"]