Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8213453

Incorrect FontMetrics on Windows via PrinterJob Graphics

    XMLWordPrintable

Details

    • 2d
    • 11
    • x86_64
    • windows_10

    Description

      A DESCRIPTION OF THE PROBLEM :
      This has been reported on AdoptOpenJDK community.
      https://github.com/AdoptOpenJDK/openjdk-build/issues/443

      But the latest Oracle/OpenJDK 11.0.1 have also this problem.

      On Windows, the FontMetrics returned from Graphics.getFontMetrics(Font) within a PrinterJob are incorrect if the PageFormat has had the orientation explicitly set to PageFormat.LANDSCAPE or PageFormat.REVERSE_LANDSCAPE. The issue is not present when explicitly setting the orientation to PageFormat.PORTRAIT.

      fontMetrics.getHeight()) always returns 0.

      int i= 20;
      Font font = new Font("Monospaced", 0, i);
      FontMetrics fontMetrics = graphics.getFontMetrics(font);
      System.out.println("font size=" + i + " FontMetrics.getHeight(): " + fontMetrics.getHeight());

      REGRESSION : Last worked in version 8u191

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use this program.

      https://github.com/AdoptOpenJDK/openjdk-build/files/2287290/JPSFontMetrics.zip

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      fontMetrics.getHeight()) should return a correct value.
      ACTUAL -
      fontMetrics.getHeight()) should return 0 if PageFormat.LANDSCAPE or PageFormat.REVERSE_LANDSCAPE is set.

      ---------- BEGIN SOURCE ----------
      See this program.

      https://github.com/AdoptOpenJDK/openjdk-build/files/2287290/JPSFontMetrics.zip
      ---------- END SOURCE ----------

      FREQUENCY : always


      Attachments

        Issue Links

          Activity

            People

              prr Philip Race
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: