使用WPF4,您可以通过向您的xaml添加TextOptions.TextFormattingMode ="Display"和TextOptions.TextRenderingMode ="Aliased"来获得非模糊文本:
<Window
   TextOptions.TextFormattingMode="Display"
   TextOptions.TextRenderingMode="Aliased">
除了当我使用DrawingContext.DrawText绘制文本时,这对我来说很好用:
void DrawText(DrawingContext dc)
{
  FormattedText ft = new FormattedText("Hello World",
    System.Globalization.CultureInfo.CurrentCulture,
    System.Windows.FlowDirection.LeftToRight,
    new Typeface(FontFamily, FontStyle, FontWeight, FontStretch),
    FontSize,
    brush);
  dc.DrawText(ft, new Point(rect.Left, rect.Top));
}
如何使用FormattedText绘制非模糊文本?即我想要使用TextOptions.TextFormattingMode ="Display"和TextOptions.TextRenderingMode ="Aliased".
wil*_*mvn 13
有一个重载的构造函数FormattedText允许指定TextFormattingMode:http://msdn.microsoft.com/en-us/library/ee474866.aspx
void DrawText(DrawingContext dc)
{
  FormattedText ft = new FormattedText("Hello World",
    System.Globalization.CultureInfo.CurrentCulture,
    System.Windows.FlowDirection.LeftToRight,
    new Typeface(FontFamily, FontStyle, FontWeight, FontStretch),
    FontSize,
    brush,
    null,
    TextFormattingMode.Display);
  dc.DrawText(ft, new Point(rect.Left, rect.Top));
}
| 归档时间: | 
 | 
| 查看次数: | 4512 次 | 
| 最近记录: |