For the purpose of automated regression testing, I am capturing some screenshots of a GDI canvas inside our application and compare them against screenshots taken from new builds. The image comparison has to be pixel perfect for the test to pass. This works well on my machine and on a colleague's machine (both Windows 7) but if we compare the images taken on one machine with those from another the comparison always fails. The differencing shows some minor differences in GDI font rendering. I would like to find out which factors could affect the font rendering that cause this difference in appearance and am running out of ideas.

  • We have the same fonts installed as far as we are aware.
  • Font size is set to 100 % on both machines
  • We're running on the same screen resolution
  • I suspected ClearType settings and indeed checking the registry HKCU\Software\Microsoft\Avalon.Graphics\DISPLAY1 showed up with some keys set for level, contrast and text contrast on my machine and these keys missing for my colleague. But I removed the keys from my registry and after a reboot we still don't produce matching images. Is there another way to export clear type settings?
  • I also tried Visual Effects / Smooth Edges of screen fonts to no avail

Are there any other settings that could cause the font rendering coming out differently? Or are there any service packs, in particulr that could affect it?

  • 2
    There is a ClearType tuner which can change how ClearType renders fonts. I'm not sure where the settings are stored. If in doubt, allow some leeway in font rendering when comparing against the screenshots. – Joey Mar 19 '14 at 16:48
  • 1
    If Cleartype is turned on, then it may be tuned differently, and even if tuned similarly it may behave differently if the systems are not 100% identical. Have you tried with Cleartype turned OFF on both machines? – Ƭᴇcʜιᴇ007 Mar 19 '14 at 16:49
  • I thought the results of ClearType tuning would just change the registry keys I mentioned above. See here. But turning it off is a good idea, will try that tomorrow. – themik81 Mar 19 '14 at 20:24

As suspected, ClearType was the Culprit. It was tuned differently on both systems. I found another bunch of registry keys apart from those listed in HKCU\Software\Microsoft\Avalon.Graphics\DISPLAY1 that store ClearType Configuration. They are located in HKCU\Control Panel\Desktop and are called:

  • FontSmoothing
  • FontSmoothingGamma
  • FontSmoothingOrientation
  • FontSmoothingType

It turns out that FontSmoothingGamma was set to different values on our machines (1000 for me, 0 for me colleague). After I set it to 0 and rebooted, font rendering on our machines is now identical.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.