Ray*_*rns 26
要以不支持FontStretch的字体获得与FontStretch类似的效果,可以在TextBlock上使用LayoutTransform:
<Application.Resources>
<ScaleTransform x:Key="FontStretchCondensed" ScaleX="0.8" />
<ScaleTransform x:Key="FontStretchExpanded" ScaleX="1.2" />
</Application.Resources>
...
<TextBlock Text="This is my text"
LayoutTransform="{StaticResource FontStretchCondensed}" />
Run Code Online (Sandbox Code Playgroud)
如果要使TextBlocks中的所有文本都显示为浓缩,也可以在样式中设置:
<Style TargetType="TextBlock">
<Style.Setters>
<Setter Property="LayoutTransform" Value="{StaticResource FontStretchCondensed}" />
</Style.Setters>
</Style>
Run Code Online (Sandbox Code Playgroud)
与粗体或斜体等字体属性不同,WPF不会模拟拉伸或小型字体等字体属性.使用的字体必须支持这个.
要查看哪些字体支持FontStretch,您需要查找具有单独字体文件的字体,例如Condensed或Expanded.然后只有正确链接的TrueType/OpenType字体才能工作.某些字体供应商没有正确地将其字体的拉伸或压缩变体链接到常规版本,因此WPF不知道这些字体变体是相关的.
| 归档时间: |
|
| 查看次数: |
14578 次 |
| 最近记录: |