8146035: Windows - With LCD antialiasing, some glyphs are not rendered correctly

Reviewed-by: serb, prr
This commit is contained in:
Dmitry Batrak 2016-04-14 13:07:35 +03:00 committed by Alexey Ivanov
parent 75a63ccb0d
commit b7b4dfdc09

@ -157,6 +157,9 @@ JNIEXPORT jboolean JNICALL
if (hBitmap != 0) { \
DeleteObject(hBitmap); \
} \
if (tmpBitmap != 0) { \
DeleteObject(tmpBitmap); \
} \
if (dibImage != NULL) { \
free(dibImage); \
} \
@ -196,6 +199,7 @@ Java_sun_font_FileFontStrike__1getGlyphImageFromWindows
int bmWidth, bmHeight;
int x, y;
HBITMAP hBitmap = NULL, hOrigBM;
HBITMAP tmpBitmap = NULL;
int gamma, orient;
HWND hWnd = NULL;
@ -250,6 +254,12 @@ Java_sun_font_FileFontStrike__1getGlyphImageFromWindows
}
oldFont = SelectObject(hMemoryDC, hFont);
tmpBitmap = CreateCompatibleBitmap(hDesktopDC, 1, 1);
if (tmpBitmap == NULL) {
FREE_AND_RETURN;
}
hOrigBM = (HBITMAP)SelectObject(hMemoryDC, tmpBitmap);
memset(&textMetric, 0, sizeof(TEXTMETRIC));
err = GetTextMetrics(hMemoryDC, &textMetric);
if (err == 0) {
@ -334,7 +344,7 @@ Java_sun_font_FileFontStrike__1getGlyphImageFromWindows
if (hBitmap == NULL) {
FREE_AND_RETURN;
}
hOrigBM = (HBITMAP)SelectObject(hMemoryDC, hBitmap);
SelectObject(hMemoryDC, hBitmap);
/* Fill in black */
rect.left = 0;
@ -478,6 +488,7 @@ Java_sun_font_FileFontStrike__1getGlyphImageFromWindows
ReleaseDC(hWnd, hDesktopDC);
DeleteObject(hMemoryDC);
DeleteObject(hBitmap);
DeleteObject(tmpBitmap);
return ptr_to_jlong(glyphInfo);
}