Bad Font-Measuring Performance under Windows 8.1

删除回忆录丶 提交于 2019-12-24 00:20:03

问题


Why does the following little loop (in c#) perform so bad using current version of WPF (.NET 4.5.2) if i change the font-family from "Segoe UI" to "Arial" (or something else...tried "Times New Roman" and "Courier New" - Same problem)?

var tb = new TextBlock {Text = "Testtext", FontFamily = new FontFamily("Arial")};

for(int i = 0; i < 100000; i++)
{
    tb.InvalidateMeasure();
    tb.Measure(new Size(double.MaxValue, double.MaxValue));
}

With font-family set to Arial this block of code takes about 7.6s on my machine. Font-family set to "Segoe UI" takes about 1.9s. Why do other fonts than Segoe UI perform so bad during measurement? Is there any tweak around, that does avoid this enormous loss in performance?

Edit: As i found found out, "Tahoma", "Lucida Sans" and "Microsoft Sans Serif" are being measured really fast, also. Is this some "System-internal font"-thing?

来源:https://stackoverflow.com/questions/28278842/bad-font-measuring-performance-under-windows-8-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!