The patch is also available at
http://cr.openjdk.java.net/~aivanov/dmitry.batrak/8146035/jdk9/webrev.00/
The fix has been integrated into 9/client
https://bugs.openjdk.java.net/browse/JDK-8146035
and to 8u-dev
https://bugs.openjdk.java.net/browse/JDK-8154232
Regards,
Alexey
On 12.04.2016 20:43, Dmitry Batrak wrote:
Repeating the patch inline:
=== patch start ===
--- old/src/java.desktop/windows/native/libfontmanager/lcdglyph.c
2016-04-07 13:10:01.507608685 +0300
+++ new/src/java.desktop/windows/native/libfontmanager/lcdglyph.c
2016-04-07 13:10:01.391608686 +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);
}
=== patch end ===
Thanks,
Dmitry
On Tue, Apr 12, 2016 at 8:22 PM, Phil Race <philip.r...@oracle.com
<mailto:philip.r...@oracle.com>> wrote:
Alexey didn't say this but he already proposed exactly this fix
himself
in a private email exchange,
+1, although I am not sure we can legally pull down the patch from
that (any) website.
Please resubmit it as a diff in the email.
Or Alexey could just push it as his own :-)
-phil.
On 04/07/2016 05:26 AM, Dmitry Batrak wrote:
Hello,
I'd like to propose a fix for JDK-8146035. I am not a committer,
so I hope someone can sponsor this fix.
I work at Jetbrains, which has signed a company-level
contributor agreement,
so, from a legal perspective, I believe, there are no obstacles.
My investigation shows that the issue is caused by incorrect
determination
of bitmap size, prepared for glyph rendering, so only part of
glyph
becomes visible due to cropping. This seems to happen because
compatible bitmap is not selected into memory device context (DC)
before calling GetTextMetrics. Documentation for
CreateCompatibleDC call
(https://msdn.microsoft.com/en-us/library/windows/desktop/dd183489%28v=vs.85%29.aspx)
says compatible bitmap needs to be selected into DC before any
drawing operation.
Even though GetTextMetrics is not a drawing operation, it
turns out
to be affected by selected bitmap's type too (by default a
monochrome bitmap
is selected in a memory DC). This behaviour was also mentioned
in the following
MSDN blog post comment:
https://blogs.msdn.microsoft.com/oldnewthing/20060614-00/?p=30873#comment-392143
The proposed fix is to select a temporary 1x1 compatible bitmap
into memory DC before GetTextMetrics call.
Here's webrev link - http://adm-12504.intellij.net/
I didn't create a test case, as it would require a specific
font file
(I couldn't reproduce the issue for fonts bundled with Windows).
Best regards,
Dmitry Batrak
--
Dmitry Batrak
Senior Software Developer
JetBrains
http://www.jetbrains.com
The Drive to Develop