Index: reactos/win32ss/gdi/ntgdi/font.h =================================================================== --- reactos/win32ss/gdi/ntgdi/font.h (revision 75391) +++ reactos/win32ss/gdi/ntgdi/font.h (working copy) @@ -29,6 +29,7 @@ FT_Face Face; FT_BitmapGlyph BitmapGlyph; int Height; + FT_Render_Mode RenderMode; MATRIX mxWorldToDevice; } FONT_CACHE_ENTRY, *PFONT_CACHE_ENTRY; Index: reactos/win32ss/gdi/ntgdi/freetype.c =================================================================== --- reactos/win32ss/gdi/ntgdi/freetype.c (revision 75391) +++ reactos/win32ss/gdi/ntgdi/freetype.c (working copy) @@ -1392,6 +1392,7 @@ switch (logfont->lfQuality) { case ANTIALIASED_QUALITY: + break; case NONANTIALIASED_QUALITY: return FT_RENDER_MODE_MONO; case DRAFT_QUALITY: @@ -2577,6 +2578,7 @@ FT_Face Face, INT GlyphIndex, INT Height, + FT_Render_Mode RenderMode, PMATRIX pmx) { PLIST_ENTRY CurrentEntry; @@ -2591,6 +2593,7 @@ if ((FontEntry->Face == Face) && (FontEntry->GlyphIndex == GlyphIndex) && (FontEntry->Height == Height) && + (FontEntry->RenderMode == RenderMode) && (SameScaleMatrix(&FontEntry->mxWorldToDevice, pmx))) break; CurrentEntry = CurrentEntry->Flink; @@ -2706,6 +2709,7 @@ NewEntry->Face = Face; NewEntry->BitmapGlyph = BitmapGlyph; NewEntry->Height = Height; + NewEntry->RenderMode = RenderMode; NewEntry->mxWorldToDevice = *pmx; InsertHeadList(&FontCacheListHead, &NewEntry->ListEntry); @@ -3558,7 +3562,6 @@ else RenderMode = FT_RENDER_MODE_MONO; - /* Get the DC's world-to-device transformation matrix */ pmxWorldToDevice = DC_pmxWorldToDevice(dc); FtSetCoordinateTransform(face, pmxWorldToDevice); @@ -3577,7 +3580,8 @@ realglyph = NULL; else realglyph = ftGdiGlyphCacheGet(face, glyph_index, - plf->lfHeight, pmxWorldToDevice); + plf->lfHeight, + RenderMode, pmxWorldToDevice); if (EmuBold || EmuItalic || !realglyph) { @@ -5071,6 +5075,7 @@ LOGFONTW *plf; BOOL EmuBold, EmuItalic; int thickness; + FT_Int32 load_flags; // TODO: Write test-cases to exactly match real Windows in different // bad parameters (e.g. does Windows check the DC or the RECT first?). @@ -5213,6 +5218,11 @@ else RenderMode = FT_RENDER_MODE_MONO; + if (RenderMode == FT_RENDER_MODE_MONO) + load_flags = FT_LOAD_MONOCHROME; + else + load_flags = FT_LOAD_DEFAULT; + if (!TextIntUpdateSize(dc, TextObj, FontGDI, FALSE)) { IntUnLockFreeType; @@ -5286,10 +5296,11 @@ realglyph = NULL; else realglyph = ftGdiGlyphCacheGet(face, glyph_index, - plf->lfHeight, pmxWorldToDevice); + plf->lfHeight, RenderMode, + pmxWorldToDevice); if (!realglyph) { - error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT); + error = FT_Load_Glyph(face, glyph_index, load_flags); if (error) { DPRINT1("WARNING: Failed to load and render glyph! [index: %d]\n", glyph_index); @@ -5393,7 +5404,7 @@ else glyph_index = FT_Get_Char_Index(face, String[i]); - error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT); + error = FT_Load_Glyph(face, glyph_index, load_flags); if (error) { DPRINT1("Failed to load and render glyph! [index: %d]\n", glyph_index); @@ -5510,11 +5521,11 @@ if (EmuBold || EmuItalic) realglyph = NULL; else - realglyph = ftGdiGlyphCacheGet(face, glyph_index, - plf->lfHeight, pmxWorldToDevice); + realglyph = ftGdiGlyphCacheGet(face, glyph_index, plf->lfHeight, + RenderMode, pmxWorldToDevice); if (!realglyph) { - error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT); + error = FT_Load_Glyph(face, glyph_index, load_flags); if (error) { DPRINT1("Failed to load and render glyph! [index: %d]\n", glyph_index); Index: reactos/win32ss/user/user32/windows/draw.c =================================================================== --- reactos/win32ss/user/user32/windows/draw.c (revision 75391) +++ reactos/win32ss/user/user32/windows/draw.c (working copy) @@ -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 @@ 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 @@ 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 @@ 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 @@ 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 */