A customer has reported that our software hangs when he runs it on one of his computers. We narrowed down the problem to rendering text with FormattedText and put together a simple application for him to try, which just renders some text with different font parameters - this would hang too.
Here's the bit of code which does the actual text drawing:
Typeface typeface = new Typeface(m_Font, m_FontStyle, m_FontWeight, FontStretches.Normal);
FormattedText ftext = new FormattedText(m_Text, new CultureInfo("en-US"), FlowDirection.LeftToRight, typeface, m_FontSize, m_FontColor);
ftext.TextAlignment = CenterText ? TextAlignment.Center : TextAlignment.Left;
if (m_DrawOutline)
{
Geometry geom = ftext.BuildGeometry(CenterText ? new Point(ftext.Width, 0) : new Point());
dc.DrawGeometry(m_FontColor, DrawOutline ? new Pen(m_OutlineColor, m_OutlineWidth) : null, geom);
}
else
dc.DrawText(ftext, CenterText ? new Point(ftext.Width, 0) : new Point());
The program simply stops responding whenever the ftext.BuildGeometry, dx.DrawText methods or the ftext.Width property is called, regardless of font and text parameters used. This only happens on one computer, which is a touchscreen laptop (not sure this is relevant) running Windows 7. We already tried reinstalling the .NET Framework but this didn't help.
Has anyone encountered a similar problem? Any ideas how to fix, work around or at least find out more about what the reason for this problem is?
Thanks.