[USER32][WIN32K] Make antialiased disabled font readable. Patch by Katayama Hirofumi MZ. CORE-7721

svn path=/trunk/; revision=75928
This commit is contained in:
Mark Jansen 2017-09-22 19:47:34 +00:00
parent 8749cbd5b9
commit 763d7b8473
3 changed files with 28 additions and 8 deletions

View file

@ -29,6 +29,7 @@ typedef struct _FONT_CACHE_ENTRY
FT_Face Face; FT_Face Face;
FT_BitmapGlyph BitmapGlyph; FT_BitmapGlyph BitmapGlyph;
int Height; int Height;
FT_Render_Mode RenderMode;
MATRIX mxWorldToDevice; MATRIX mxWorldToDevice;
} FONT_CACHE_ENTRY, *PFONT_CACHE_ENTRY; } FONT_CACHE_ENTRY, *PFONT_CACHE_ENTRY;

View file

@ -1392,6 +1392,7 @@ IntGetFontRenderMode(LOGFONTW *logfont)
switch (logfont->lfQuality) switch (logfont->lfQuality)
{ {
case ANTIALIASED_QUALITY: case ANTIALIASED_QUALITY:
break;
case NONANTIALIASED_QUALITY: case NONANTIALIASED_QUALITY:
return FT_RENDER_MODE_MONO; return FT_RENDER_MODE_MONO;
case DRAFT_QUALITY: case DRAFT_QUALITY:
@ -2608,6 +2609,7 @@ ftGdiGlyphCacheGet(
FT_Face Face, FT_Face Face,
INT GlyphIndex, INT GlyphIndex,
INT Height, INT Height,
FT_Render_Mode RenderMode,
PMATRIX pmx) PMATRIX pmx)
{ {
PLIST_ENTRY CurrentEntry; PLIST_ENTRY CurrentEntry;
@ -2622,6 +2624,7 @@ ftGdiGlyphCacheGet(
if ((FontEntry->Face == Face) && if ((FontEntry->Face == Face) &&
(FontEntry->GlyphIndex == GlyphIndex) && (FontEntry->GlyphIndex == GlyphIndex) &&
(FontEntry->Height == Height) && (FontEntry->Height == Height) &&
(FontEntry->RenderMode == RenderMode) &&
(SameScaleMatrix(&FontEntry->mxWorldToDevice, pmx))) (SameScaleMatrix(&FontEntry->mxWorldToDevice, pmx)))
break; break;
CurrentEntry = CurrentEntry->Flink; CurrentEntry = CurrentEntry->Flink;
@ -2737,6 +2740,7 @@ ftGdiGlyphCacheSet(
NewEntry->Face = Face; NewEntry->Face = Face;
NewEntry->BitmapGlyph = BitmapGlyph; NewEntry->BitmapGlyph = BitmapGlyph;
NewEntry->Height = Height; NewEntry->Height = Height;
NewEntry->RenderMode = RenderMode;
NewEntry->mxWorldToDevice = *pmx; NewEntry->mxWorldToDevice = *pmx;
InsertHeadList(&FontCacheListHead, &NewEntry->ListEntry); InsertHeadList(&FontCacheListHead, &NewEntry->ListEntry);
@ -3589,7 +3593,6 @@ TextIntGetTextExtentPoint(PDC dc,
else else
RenderMode = FT_RENDER_MODE_MONO; RenderMode = FT_RENDER_MODE_MONO;
/* Get the DC's world-to-device transformation matrix */ /* Get the DC's world-to-device transformation matrix */
pmxWorldToDevice = DC_pmxWorldToDevice(dc); pmxWorldToDevice = DC_pmxWorldToDevice(dc);
FtSetCoordinateTransform(face, pmxWorldToDevice); FtSetCoordinateTransform(face, pmxWorldToDevice);
@ -3607,8 +3610,8 @@ TextIntGetTextExtentPoint(PDC dc,
if (EmuBold || EmuItalic) if (EmuBold || EmuItalic)
realglyph = NULL; realglyph = NULL;
else else
realglyph = ftGdiGlyphCacheGet(face, glyph_index, realglyph = ftGdiGlyphCacheGet(face, glyph_index, plf->lfHeight,
plf->lfHeight, pmxWorldToDevice); RenderMode, pmxWorldToDevice);
if (EmuBold || EmuItalic || !realglyph) if (EmuBold || EmuItalic || !realglyph)
{ {
@ -5320,8 +5323,8 @@ GreExtTextOutW(
if (EmuBold || EmuItalic) if (EmuBold || EmuItalic)
realglyph = NULL; realglyph = NULL;
else else
realglyph = ftGdiGlyphCacheGet(face, glyph_index, realglyph = ftGdiGlyphCacheGet(face, glyph_index, plf->lfHeight,
plf->lfHeight, pmxWorldToDevice); RenderMode, pmxWorldToDevice);
if (!realglyph) if (!realglyph)
{ {
error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT); error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
@ -5543,8 +5546,8 @@ GreExtTextOutW(
if (EmuBold || EmuItalic) if (EmuBold || EmuItalic)
realglyph = NULL; realglyph = NULL;
else else
realglyph = ftGdiGlyphCacheGet(face, glyph_index, realglyph = ftGdiGlyphCacheGet(face, glyph_index, plf->lfHeight,
plf->lfHeight, pmxWorldToDevice); RenderMode, pmxWorldToDevice);
if (!realglyph) if (!realglyph)
{ {
error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT); error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);

View file

@ -6,6 +6,7 @@
* Copyright 2003 Andrew Greenwood * Copyright 2003 Andrew Greenwood
* Copyright 2003 Filip Navara * Copyright 2003 Filip Navara
* Copyright 2009 Matthias Kupfer * Copyright 2009 Matthias Kupfer
* Copyright 2017 Katayama Hirofumi MZ
* *
* Based on Wine code. * Based on Wine code.
* *
@ -1242,6 +1243,8 @@ IntDrawState(HDC hdc, HBRUSH hbr, DRAWSTATEPROC func, LPARAM lp, WPARAM wp,
UINT opcode = flags & 0xf; UINT opcode = flags & 0xf;
INT len = wp; INT len = wp;
BOOL retval, tmp; BOOL retval, tmp;
LOGFONTW lf;
HFONT hFontOriginal, hNaaFont = NULL;
if((opcode == DST_TEXT || opcode == DST_PREFIXTEXT) && !len) /* The string is '\0' terminated */ 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); 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 */ /* Find out what size the image has if not given by caller */
if(!cx || !cy) 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; if(!FillRect(memdc, &rc, (HBRUSH)GetStockObject(WHITE_BRUSH))) goto cleanup;
SetBkColor(memdc, RGB(255, 255, 255)); SetBkColor(memdc, RGB(255, 255, 255));
SetTextColor(memdc, RGB(0, 0, 0)); 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 )); SetLayout( memdc, GetLayout( hdc ));
/* DST_COMPLEX may draw text as well, /* 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; if(!hfsave && (opcode <= DST_PREFIXTEXT)) goto cleanup;
tmp = PAINTING_DrawStateJam(memdc, opcode, func, lp, len, &rc, dtflags, unicode); tmp = PAINTING_DrawStateJam(memdc, opcode, func, lp, len, &rc, dtflags, unicode);
if(hfsave) SelectObject(memdc, hfsave); if(hfsave) SelectObject(memdc, hfsave);
if (hNaaFont) DeleteObject(hNaaFont);
if(!tmp) goto cleanup; if(!tmp) goto cleanup;
/* This state cause the image to be dithered */ /* This state cause the image to be dithered */