问题
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