WPF 的 TextBlock 在 Windows 7 和 Windows 8 之间的区别区别、WPF、TextBlock、Windows

由网友(我知道和不知道的你知道)分享简介:While investigating some unit tests which fail only on my machine, I noticed that TextBlock presents text differently on Windows 7 and Windows 8 machines.To in...

While investigating some unit tests which fail only on my machine, I noticed that TextBlock presents text differently on Windows 7 and Windows 8 machines. To inspect the issue, I created sample application containing just one TextBlock:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <TextBlock Text="yo" FontSize="100" FontFamily="Verdana" />
    </Grid>
</Window>

You can see (or at least I hope so) that the text on Windows 7 is 1px longer - actually the kerning between the "y" and "o" is 1px thicker:

对wpf 的入门记录总结 基础控件textblock label TextBox CheckBox RadioButton PasswordBox Image

I inspected the Verdana.ttf font files on both machines with a font reader software, and the kerning between "y" and "o" listed there is one and the same: -18. Also checked the versions of the .NET Framework, which are also identical: 4.5.50709. ...and I am still wondering what causes this difference?

解决方案

I'd rather think it is something to do with ClearType or Anti-Aliasing, Microsoft is constantly changing that code between every Windows release. Don't think there is anything you can do about that, just have to factor in those differences to your unit tests.

阅读全文

相关推荐

最新文章