changeset 11536:e9a5a65f75b5

8146035: Windows - With LCD antialiasing, some glyphs are not rendered correctly Reviewed-by: serb, prr Contributed-by: Dmitry Batrak <dmitry.batrak@jetbrains.com>
author aivanov
date Fri, 15 Apr 2016 10:17:09 +0300
parents dec21caa0f9c
children 939fcf5887f6
files src/windows/native/sun/font/lcdglyph.c
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/windows/native/sun/font/lcdglyph.c	Tue Sep 15 15:10:49 2015 -0700
+++ b/src/windows/native/sun/font/lcdglyph.c	Fri Apr 15 10:17:09 2016 +0300
@@ -157,6 +157,9 @@
     if (hBitmap != 0) { \
         DeleteObject(hBitmap); \
     } \
+    if (tmpBitmap != 0) { \
+        DeleteObject(tmpBitmap); \
+    } \
     if (dibImage != NULL) { \
         free(dibImage); \
     } \
@@ -196,6 +199,7 @@
     int bmWidth, bmHeight;
     int x, y;
     HBITMAP hBitmap = NULL, hOrigBM;
+    HBITMAP tmpBitmap = NULL;
     int gamma, orient;
 
     HWND hWnd = NULL;
@@ -250,6 +254,12 @@
     }
     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 @@
     if (hBitmap == NULL) {
         FREE_AND_RETURN;
     }
-    hOrigBM = (HBITMAP)SelectObject(hMemoryDC, hBitmap);
+    SelectObject(hMemoryDC, hBitmap);
 
     /* Fill in black */
     rect.left = 0;
@@ -478,6 +488,7 @@
     ReleaseDC(hWnd, hDesktopDC);
     DeleteObject(hMemoryDC);
     DeleteObject(hBitmap);
+    DeleteObject(tmpBitmap);
 
     return ptr_to_jlong(glyphInfo);
 }