I have a Win32 GUI application that uses GDI havily. He should draw the text over the bitmap with the given coordinates, and then erase it and replace it with the original bitmap.
I do the following:
- select the font (GetStockObject (DEFAULT_GUI_FONT)), brush, other things in the device context.
- call GetTextExtentPoint32 () to calculate the text size
- Now, having the starting point of the text, I can calculate the expected rectangle of the text and save it
- calling TextOut () for the same device context with the same starting point and the same text
and then restore the bitmap for the storage rectangle.
It works great when ClearType anti-aliasing is disabled. But with ClearType the size returned by GetTextExtentPoint32 () is slightly smaller than the size actually occupied by the text when TextOut () is called. Therefore, when I later restore the original bitmap, some small stripes of text remain in place, and I have artifacts.
Is there any cure for this without turning off ClearType?
source share