[USER32][WIN32K] Make antialiased disabled font readable. Patch by Katayama Hirofumi...
[reactos.git] / reactos / win32ss / user / user32 / windows / draw.c
index b01984d..3cb9f10 100644 (file)
@@ -6,6 +6,7 @@
  * Copyright 2003 Andrew Greenwood
  * Copyright 2003 Filip Navara
  * Copyright 2009 Matthias Kupfer
+ * Copyright 2017 Katayama Hirofumi MZ
  *
  * Based on Wine code.
  *
@@ -1242,6 +1243,8 @@ IntDrawState(HDC hdc, HBRUSH hbr, DRAWSTATEPROC func, LPARAM lp, WPARAM wp,
     UINT opcode = flags & 0xf;
     INT len = wp;
     BOOL retval, tmp;
+    LOGFONTW lf;
+    HFONT hFontOriginal, hNaaFont = NULL;
 
     if((opcode == DST_TEXT || opcode == DST_PREFIXTEXT) && !len)    /* The string is '\0' terminated */
     {
@@ -1251,6 +1254,15 @@ IntDrawState(HDC hdc, HBRUSH hbr, DRAWSTATEPROC func, LPARAM lp, WPARAM wp,
             len = lstrlenA((LPSTR)lp);
     }
 
+    hFontOriginal = GetCurrentObject(hdc, OBJ_FONT);
+    if (flags & (DSS_MONO | DSS_DISABLED))
+    {
+        /* Create a non-antialiased font */
+        GetObjectW(hFontOriginal, sizeof(lf), &lf);
+        lf.lfQuality = NONANTIALIASED_QUALITY;
+        hNaaFont = CreateFontIndirectW(&lf);
+    }
+
     /* Find out what size the image has if not given by caller */
     if(!cx || !cy)
     {
@@ -1332,7 +1344,10 @@ IntDrawState(HDC hdc, HBRUSH hbr, DRAWSTATEPROC func, LPARAM lp, WPARAM wp,
     if(!FillRect(memdc, &rc, (HBRUSH)GetStockObject(WHITE_BRUSH))) goto cleanup;
     SetBkColor(memdc, RGB(255, 255, 255));
     SetTextColor(memdc, RGB(0, 0, 0));
-    hfsave  = (HFONT)SelectObject(memdc, GetCurrentObject(hdc, OBJ_FONT));
+    if (hNaaFont)
+        hfsave  = (HFONT)SelectObject(memdc, hNaaFont);
+    else
+        hfsave  = (HFONT)SelectObject(memdc, hFontOriginal);
     SetLayout( memdc, GetLayout( hdc ));
 
     /* DST_COMPLEX may draw text as well,
@@ -1341,6 +1356,7 @@ IntDrawState(HDC hdc, HBRUSH hbr, DRAWSTATEPROC func, LPARAM lp, WPARAM wp,
     if(!hfsave && (opcode <= DST_PREFIXTEXT)) goto cleanup;
     tmp = PAINTING_DrawStateJam(memdc, opcode, func, lp, len, &rc, dtflags, unicode);
     if(hfsave) SelectObject(memdc, hfsave);
+    if (hNaaFont) DeleteObject(hNaaFont);
     if(!tmp) goto cleanup;
 
     /* This state cause the image to be dithered */