欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

WPF字體或內(nèi)容模糊的解決方法

 更新時(shí)間:2016年12月04日 08:44:04   作者:王旭  
WPF下開發(fā)的程序字體模糊,這個(gè)問題或許大家都有遇到過,為了解決WPF字體模糊,查閱了各種資料,結(jié)果偶然發(fā)現(xiàn)是自己疏忽了一些細(xì)節(jié)造成的,具體是什么細(xì)節(jié)呢,通過下面的這篇文章來一起看看吧,有需要的朋友們可以參考借鑒。

本文會(huì)給大家介紹嘗試過的一些方法,大家可以一起看看。

1、用WPF4.0中的新字體渲染方法,沒有改善

<Setter Property="TextOptions.TextFormattingMode" Value="Display" />
<Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />

2、給控件加上SnapsToDevicePixels屬性,沒有改善

其作用傳說是給整個(gè) UI 上啟用像素對齊呈現(xiàn)。 對于運(yùn)行在大于 96 dots per inch (dpi) 的設(shè)備,像素對齊呈現(xiàn)可以最小化在單一實(shí)線附近出現(xiàn)的抗鋸齒視覺瑕疵。

3、使用Times New Roman字體或微軟雅黑字體,好一點(diǎn),但是字體比較丑,也不能完全避免虛糊,另外解決不了動(dòng)畫后,文字繼續(xù)虛邊現(xiàn)象。

4、最終解決

其實(shí)是自己的編寫的Border設(shè)置了DropShadowEffect(陰影效果)引起的。

因?yàn)?code>DropShadowEffect使得元素/子元素先渲染為位圖,從而導(dǎo)致的位圖柵格對齊導(dǎo)致的模糊。

解決方法有幾個(gè):

  1. 是使用UseLayoutRounding,它使得控件布局的時(shí)候?qū)R柵格(見效果2)。
  2. 是讓Text元素不作為DropShadowEffect的子元素,讓ShadowEffect不會(huì)影響Button(見效果3)。
  3. 效果如下(0:基準(zhǔn)      1:虛糊        2:UseLayoutRounding      3:平行元素)

效果4是試驗(yàn)SystemDropShadowChrome,可以注釋掉。

<Window x:Class="WpfApplication1.MainWindow"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:luna="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Luna"
 Title="MainWindow" Height="350" Width="525" SnapsToDevicePixels="True">
 <Window.Resources>
  <Style TargetType="Button">
   <Setter Property="Width" Value="80" />
   <Setter Property="Height" Value="40" />
   <Setter Property="Margin" Value="0,5,0,5" />
  </Style>
 </Window.Resources>
 <StackPanel>
  <Button Content="基本設(shè)置 0" />
  <Button Content="基本設(shè)置 1" >
   <Button.Effect><DropShadowEffect/></Button.Effect>
  </Button>
  <Button Content="基本設(shè)置 2" UseLayoutRounding="True">
   <Button.Effect>
    <DropShadowEffect/>
   </Button.Effect>
  </Button>
  <Grid Width="80" Height="40" Margin="0,5,0,5">
   <Border Background="Black" Margin="1,0,0,0" CornerRadius="2">
    <Border.Effect><DropShadowEffect /></Border.Effect>
   </Border>
   <Button Content="基本設(shè)置 3" Margin="0"/>
  </Grid>
  <luna:SystemDropShadowChrome Width="80" Height="40" Margin="0,5,0,0">
   <Button Content="基本設(shè)置 4" Margin="0" />
  </luna:SystemDropShadowChrome>
 </StackPanel>
</Window>

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流。

相關(guān)文章

最新評論