<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    The patch is also available at<br>
<a class="moz-txt-link-freetext" href="http://cr.openjdk.java.net/~aivanov/dmitry.batrak/8146035/jdk9/webrev.00/">http://cr.openjdk.java.net/~aivanov/dmitry.batrak/8146035/jdk9/webrev.00/</a><br>
    <br>
    The fix has been integrated into 9/client<br>
    <a class="moz-txt-link-freetext" href="https://bugs.openjdk.java.net/browse/JDK-8146035">https://bugs.openjdk.java.net/browse/JDK-8146035</a><br>
    <br>
    and to 8u-dev<br>
    <a class="moz-txt-link-freetext" href="https://bugs.openjdk.java.net/browse/JDK-8154232">https://bugs.openjdk.java.net/browse/JDK-8154232</a><br>
    <br>
    <br>
    Regards,<br>
    Alexey<br>
    <br>
    <div class="moz-cite-prefix">On 12.04.2016 20:43, Dmitry Batrak
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAET5FPsPSxzoGJw7hTrjF2b9xuq+fPQpnaPo8jmPpF4KemAV3A@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div>
            <div>
              <div>Repeating the patch inline:<br>
                <br>
              </div>
              === patch start ===<br>
              ---
              old/src/java.desktop/windows/native/libfontmanager/lcdglyph.c   
              2016-04-07 13:10:01.507608685 +0300<br>
              +++
              new/src/java.desktop/windows/native/libfontmanager/lcdglyph.c   
              2016-04-07 13:10:01.391608686 +0300<br>
              @@ -157,6 +157,9 @@<br>
                   if (hBitmap != 0) { \<br>
                       DeleteObject(hBitmap); \<br>
                   } \<br>
              +    if (tmpBitmap != 0) { \<br>
              +        DeleteObject(tmpBitmap); \<br>
              +    } \<br>
                   if (dibImage != NULL) { \<br>
                       free(dibImage); \<br>
                   } \<br>
              @@ -196,6 +199,7 @@<br>
                   int bmWidth, bmHeight;<br>
                   int x, y;<br>
                   HBITMAP hBitmap = NULL, hOrigBM;<br>
              +    HBITMAP tmpBitmap = NULL;<br>
                   int gamma, orient;<br>
               <br>
                   HWND hWnd = NULL;<br>
              @@ -250,6 +254,12 @@<br>
                   }<br>
                   oldFont = SelectObject(hMemoryDC, hFont);<br>
               <br>
              +    tmpBitmap = CreateCompatibleBitmap(hDesktopDC, 1, 1);<br>
              +    if (tmpBitmap == NULL) {<br>
              +        FREE_AND_RETURN;<br>
              +    }<br>
              +    hOrigBM = (HBITMAP)SelectObject(hMemoryDC,
              tmpBitmap);<br>
              +<br>
                   memset(&textMetric, 0, sizeof(TEXTMETRIC));<br>
                   err = GetTextMetrics(hMemoryDC, &textMetric);<br>
                   if (err == 0) {<br>
              @@ -334,7 +344,7 @@<br>
                   if (hBitmap == NULL) {<br>
                       FREE_AND_RETURN;<br>
                   }<br>
              -    hOrigBM = (HBITMAP)SelectObject(hMemoryDC, hBitmap);<br>
              +    SelectObject(hMemoryDC, hBitmap);<br>
               <br>
                   /* Fill in black */<br>
                   rect.left = 0;<br>
              @@ -478,6 +488,7 @@<br>
                   ReleaseDC(hWnd, hDesktopDC);<br>
                   DeleteObject(hMemoryDC);<br>
                   DeleteObject(hBitmap);<br>
              +    DeleteObject(tmpBitmap);<br>
               <br>
                   return ptr_to_jlong(glyphInfo);<br>
               }<br>
            </div>
            === patch end ===<br>
            <br>
          </div>
          Thanks,<br>
        </div>
        Dmitry<br>
        <div>
          <div>
            <div>
              <div>
                <div>
                  <div class="gmail_extra"><br>
                    <div class="gmail_quote">On Tue, Apr 12, 2016 at
                      8:22 PM, Phil Race <span dir="ltr"><<a
                          moz-do-not-send="true"
                          href="mailto:philip.race@oracle.com"
                          target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:philip.race@oracle.com">philip.race@oracle.com</a></a>></span>
                      wrote:<br>
                      <blockquote class="gmail_quote" style="margin:0px
                        0px 0px 0.8ex;border-left:1px solid
                        rgb(204,204,204);padding-left:1ex">Alexey didn't
                        say this but he already proposed exactly this
                        fix himself<br>
                        in a private email exchange,<br>
                        <br>
                        +1, although I am not sure we can legally pull
                        down the patch from that (any) website.<br>
                        Please resubmit it as a diff in the email.<br>
                        <br>
                        Or Alexey could just push it as his own :-)<br>
                        <br>
                        -phil.<br>
                        <br>
                        On 04/07/2016 05:26 AM, Dmitry Batrak wrote:<br>
                        <blockquote class="gmail_quote"
                          style="margin:0px 0px 0px
                          0.8ex;border-left:1px solid
                          rgb(204,204,204);padding-left:1ex">
                          Hello,<br>
                          <br>
                          I'd like to propose a fix for JDK-8146035. I
                          am not a committer,<br>
                          so I hope someone can sponsor this fix.<br>
                          I work at Jetbrains, which has signed a
                          company-level contributor agreement,<br>
                          so, from a legal perspective, I believe, there
                          are no obstacles.<br>
                          <br>
                          My investigation shows that the issue is
                          caused by incorrect determination<br>
                          of bitmap size, prepared for glyph rendering,
                          so only part of glyph<br>
                          becomes visible due to cropping. This seems to
                          happen because<br>
                          compatible bitmap is not selected into memory
                          device context (DC)<br>
                          before calling GetTextMetrics. Documentation
                          for CreateCompatibleDC call<br>
                          (<a moz-do-not-send="true"
href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd183489%28v=vs.85%29.aspx"
                            rel="noreferrer" target="_blank">https://msdn.microsoft.com/en-us/library/windows/desktop/dd183489%28v=vs.85%29.aspx</a>)
                          <br>
                          says compatible bitmap needs to be selected
                          into DC before any drawing operation.<br>
                          Even though GetTextMetrics is not a drawing
                          operation, it turns out<br>
                          to be affected by selected bitmap's type too
                          (by default a monochrome bitmap<br>
                          is selected in a memory DC). This behaviour
                          was also mentioned in the following<br>
                          MSDN blog post comment:<br>
                          <a moz-do-not-send="true"
href="https://blogs.msdn.microsoft.com/oldnewthing/20060614-00/?p=30873#comment-392143"
                            rel="noreferrer" target="_blank">https://blogs.msdn.microsoft.com/oldnewthing/20060614-00/?p=30873#comment-392143</a><br>
                          <br>
                          The proposed fix is to select a temporary 1x1
                          compatible bitmap<br>
                          into memory DC before GetTextMetrics call.<br>
                          Here's webrev link - <a
                            moz-do-not-send="true"
                            href="http://adm-12504.intellij.net/"
                            rel="noreferrer" target="_blank"><a class="moz-txt-link-freetext" href="http://adm-12504.intellij.net/">http://adm-12504.intellij.net/</a></a><br>
                          I didn't create a test case, as it would
                          require a specific font file<br>
                          (I couldn't reproduce the issue for fonts
                          bundled with Windows).<br>
                          <br>
                          Best regards,<br>
                          Dmitry Batrak<br>
                        </blockquote>
                        <br>
                      </blockquote>
                    </div>
                    <br>
                    <br clear="all">
                    <br>
                    -- <br>
                    <div class="gmail_signature">
                      <div dir="ltr">
                        <div>
                          <div dir="ltr">Dmitry Batrak<br>
                            Senior Software Developer<br>
                            JetBrains<br>
                            <a moz-do-not-send="true"
                              href="http://www.jetbrains.com"
                              target="_blank">http://www.jetbrains.com</a><br>
                            The Drive to Develop<br>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>