Author: mjansen Date: Fri Sep 22 19:47:34 2017 New Revision: 75928
URL: http://svn.reactos.org/svn/reactos?rev=75928&view=rev Log: [USER32][WIN32K] Make antialiased disabled font readable. Patch by Katayama Hirofumi MZ. CORE-7721
Modified: trunk/reactos/win32ss/gdi/ntgdi/font.h trunk/reactos/win32ss/gdi/ntgdi/freetype.c trunk/reactos/win32ss/user/user32/windows/draw.c
Modified: trunk/reactos/win32ss/gdi/ntgdi/font.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/font.h?re... ============================================================================== --- trunk/reactos/win32ss/gdi/ntgdi/font.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/font.h [iso-8859-1] Fri Sep 22 19:47:34 2017 @@ -29,6 +29,7 @@ FT_Face Face; FT_BitmapGlyph BitmapGlyph; int Height; + FT_Render_Mode RenderMode; MATRIX mxWorldToDevice; } FONT_CACHE_ENTRY, *PFONT_CACHE_ENTRY;
Modified: trunk/reactos/win32ss/gdi/ntgdi/freetype.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/freetype.... ============================================================================== --- trunk/reactos/win32ss/gdi/ntgdi/freetype.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/freetype.c [iso-8859-1] Fri Sep 22 19:47:34 2017 @@ -1392,6 +1392,7 @@ switch (logfont->lfQuality) { case ANTIALIASED_QUALITY: + break; case NONANTIALIASED_QUALITY: return FT_RENDER_MODE_MONO; case DRAFT_QUALITY: @@ -2608,6 +2609,7 @@ FT_Face Face, INT GlyphIndex, INT Height, + FT_Render_Mode RenderMode, PMATRIX pmx) { PLIST_ENTRY CurrentEntry; @@ -2622,6 +2624,7 @@ if ((FontEntry->Face == Face) && (FontEntry->GlyphIndex == GlyphIndex) && (FontEntry->Height == Height) && + (FontEntry->RenderMode == RenderMode) && (SameScaleMatrix(&FontEntry->mxWorldToDevice, pmx))) break; CurrentEntry = CurrentEntry->Flink; @@ -2737,6 +2740,7 @@ NewEntry->Face = Face; NewEntry->BitmapGlyph = BitmapGlyph; NewEntry->Height = Height; + NewEntry->RenderMode = RenderMode; NewEntry->mxWorldToDevice = *pmx;
InsertHeadList(&FontCacheListHead, &NewEntry->ListEntry); @@ -3589,7 +3593,6 @@ else RenderMode = FT_RENDER_MODE_MONO;
- /* Get the DC's world-to-device transformation matrix */ pmxWorldToDevice = DC_pmxWorldToDevice(dc); FtSetCoordinateTransform(face, pmxWorldToDevice); @@ -3607,8 +3610,8 @@ if (EmuBold || EmuItalic) realglyph = NULL; else - realglyph = ftGdiGlyphCacheGet(face, glyph_index, - plf->lfHeight, pmxWorldToDevice); + realglyph = ftGdiGlyphCacheGet(face, glyph_index, plf->lfHeight, + RenderMode, pmxWorldToDevice);
if (EmuBold || EmuItalic || !realglyph) { @@ -5320,8 +5323,8 @@ 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); @@ -5543,8 +5546,8 @@ 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);
Modified: trunk/reactos/win32ss/user/user32/windows/draw.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/windows... ============================================================================== --- trunk/reactos/win32ss/user/user32/windows/draw.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/windows/draw.c [iso-8859-1] Fri Sep 22 19:47:34 2017 @@ -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 */ { @@ -1249,6 +1252,15 @@ len = lstrlenW((LPWSTR)lp); else 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 */ @@ -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 */