tags:

views:

38

answers:

2

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.

+1  A: 

Never personally encountered that problem and I use Windows 7 at home. However, if it is only on one machine, it is a safe bet that the problem is not software related. The first step I would try is to download the most recent video display drivers and installing them. If it is still giving you a problem, try booting into safe mode and see if it will run.

icemanind
Thanks for your reply. We've already tried installing the latest grahpics drivers (it's an ATI card) but this didn't help... I'll get the customer to try Safe Mode. What would it tell us if it did work in Safe Mode?
Lukasz
If it DOES work in safe mode, then it tells me there is a either a driver or a software application installed that is interfering with the operation of your program. Perhaps a virus scan might be necessary too?
icemanind
A: 

I've had this problem occur due to a corrupt presentation font cache.

Stop the font cache service, delete the file %systemdrive%\Documents and Settings\LocalService\Local Settings\Application Data\FontCache3.0.0.0.dat (xp) and restart.

Details at http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/7cc032c1-5f4d-4518-adc6-f53afd051e6b

LukeN