Silverlight - 作为图标呈现的字体过于扭曲/像素化
Silverlight - font as an icon rendering is too distorted / pixelated
我目前将 FontAwesome 集成到我的 silverlight 应用程序中。但是我注意到在 运行 时间它实际上是像素化的
<!-- RadButton (via custom Button) -->
<Style TargetType="controls:Button" x:Key="DefaultRadButtonStyle">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{StaticResource DefaultColorBrush}" />
<Setter Property="MouseOverStyle" Value="{StaticResource DefaultButtonMouseOverBorder}" />
<Setter Property="FocusStyle" Value="{StaticResource DefaultButtonFocusBorder}" />
<Setter Property="BorderBrush" Value="{StaticResource LineColorBrush}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="FontFamily" Value="{StaticResource OpenSans-Regular}" />
<Setter Property="Height" Value="{StaticResource CaptureGridRowHeightNumber}" />
<Setter Property="Padding" Value="8, 0, 8, 1" />
<Setter Property="FontSize" Value="13" />
<Setter Property="Template">
用法:
<controls:Button
Style="{StaticResource IconButtonStyle}"
Command="{Binding RefreshCommand}">
<TextBlock Text="{StaticResource RefreshIcon}" Style="{StaticResource FontAwesomeTextBlockStyle}"/>
</controls:Button>
我建议使用 Path
而不是图像(如果您使用任何类型的图像)。由于它是矢量路径,它应该基于父容器进行缩放并且不会有任何像素化问题(而且它比图像更快并且使用更少的资源)。示例刷新图像,
<Path Stretch="Fill" Fill="#FF000000" Data="F1 M 38,20.5833C 42.9908,20.5833 47.4912,22.6825 50.6667,
26.046L 50.6667,17.4167L 55.4166,22.1667L 55.4167,34.8333L 42.75,34.8333L 38,30.0833L 46.8512,
30.0833C 44.6768,27.6539 41.517,26.125 38,26.125C 31.9785,26.125 27.0037,30.6068 26.2296,
36.4167L 20.6543,36.4167C 21.4543,27.5397 28.9148,20.5833 38,20.5833 Z M 38,49.875C 44.0215,
49.875 48.9963,45.3932 49.7703,39.5833L 55.3457,39.5833C 54.5457,48.4603 47.0852,55.4167 38,
55.4167C 33.0092,55.4167 28.5088,53.3175 25.3333,49.954L 25.3333,58.5833L 20.5833,
53.8333L 20.5833,41.1667L 33.25,41.1667L 38,45.9167L 29.1487,45.9167C 31.3231,48.3461 34.483,
49.875 38,49.875 Z "/>
显然有一个破解这个
<Style x:Key="BaseFontAwesomeTextBlockStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="16"/>
<Setter Property="Foreground" Value="{StaticResource DefaultColorBrush}"/>
<Setter Property="RenderTransform">
<Setter.Value>
<RotateTransform Angle="0.001"/>
</Setter.Value>
</Setter>
</Style>
我目前将 FontAwesome 集成到我的 silverlight 应用程序中。但是我注意到在 运行 时间它实际上是像素化的
<!-- RadButton (via custom Button) -->
<Style TargetType="controls:Button" x:Key="DefaultRadButtonStyle">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{StaticResource DefaultColorBrush}" />
<Setter Property="MouseOverStyle" Value="{StaticResource DefaultButtonMouseOverBorder}" />
<Setter Property="FocusStyle" Value="{StaticResource DefaultButtonFocusBorder}" />
<Setter Property="BorderBrush" Value="{StaticResource LineColorBrush}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="FontFamily" Value="{StaticResource OpenSans-Regular}" />
<Setter Property="Height" Value="{StaticResource CaptureGridRowHeightNumber}" />
<Setter Property="Padding" Value="8, 0, 8, 1" />
<Setter Property="FontSize" Value="13" />
<Setter Property="Template">
用法:
<controls:Button
Style="{StaticResource IconButtonStyle}"
Command="{Binding RefreshCommand}">
<TextBlock Text="{StaticResource RefreshIcon}" Style="{StaticResource FontAwesomeTextBlockStyle}"/>
</controls:Button>
我建议使用 Path
而不是图像(如果您使用任何类型的图像)。由于它是矢量路径,它应该基于父容器进行缩放并且不会有任何像素化问题(而且它比图像更快并且使用更少的资源)。示例刷新图像,
<Path Stretch="Fill" Fill="#FF000000" Data="F1 M 38,20.5833C 42.9908,20.5833 47.4912,22.6825 50.6667,
26.046L 50.6667,17.4167L 55.4166,22.1667L 55.4167,34.8333L 42.75,34.8333L 38,30.0833L 46.8512,
30.0833C 44.6768,27.6539 41.517,26.125 38,26.125C 31.9785,26.125 27.0037,30.6068 26.2296,
36.4167L 20.6543,36.4167C 21.4543,27.5397 28.9148,20.5833 38,20.5833 Z M 38,49.875C 44.0215,
49.875 48.9963,45.3932 49.7703,39.5833L 55.3457,39.5833C 54.5457,48.4603 47.0852,55.4167 38,
55.4167C 33.0092,55.4167 28.5088,53.3175 25.3333,49.954L 25.3333,58.5833L 20.5833,
53.8333L 20.5833,41.1667L 33.25,41.1667L 38,45.9167L 29.1487,45.9167C 31.3231,48.3461 34.483,
49.875 38,49.875 Z "/>
显然有一个破解这个
<Style x:Key="BaseFontAwesomeTextBlockStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="16"/>
<Setter Property="Foreground" Value="{StaticResource DefaultColorBrush}"/>
<Setter Property="RenderTransform">
<Setter.Value>
<RotateTransform Angle="0.001"/>
</Setter.Value>
</Setter>
</Style>