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

[macosx] printing large fonts doesn't work on Mac, short reproducible code example attach

    XMLWordPrintable

    Details

    • Subcomponent:
      2d
    • OS:
      os_x

      Description

      FULL PRODUCT VERSION :
      java version " 1.7.0_21 "
      Java(TM) SE Runtime Environment (build 1.7.0_21-b12)
      Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Mac 10.7

      Darwin Dev.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64

      A DESCRIPTION OF THE PROBLEM :
      large fonts show up large on screen and small on printer

      code attached should print 96 points but prints about 12 points instead:




      REGRESSION. Last worked in version 6u45

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      compile the attached code and run it

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Font should print at the specified size but prints at about 12 pt instead
      ACTUAL -
      12 point font printed instead of 96

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.print.*;
      import java.awt.Graphics;
      import java.awt.Graphics2D;
      import java.awt.Color;
      import java.awt.Font;

      public class FontFail implements Printable {
        
          public static Font largeFont = new Font( " Arial " , 0, 96); // a LARGE font! 96pt
          
          public static void main (String []args) {
              new FontFail().run();
          }
          
          public void run() {
               PrinterJob printJob = PrinterJob.getPrinterJob();
               PageFormat pf = printJob.defaultPage();
               pf = printJob.pageDialog(pf);

               printJob.setPrintable(this,pf);
              if (printJob.printDialog()) {
                 try {
                      printJob.print();
                 } catch (Exception ex) {
                     System.out.println( " A printing error occurred. " );
                 }
              }
          }
         
          public int print(Graphics g, final PageFormat pf, int pi) throws PrinterException {
              if (pi > 0)
                  return Printable.NO_SUCH_PAGE;

              Graphics2D g2 = (Graphics2D) g;
              g2.setPaint(Color.black);
              
              g2.setFont(largeFont); // This line works fine in Java 6 Mac but not Java 7. The font is still small on Java 7.
              g2.drawString( " Large? " ,100,200);
              
              return Printable.PAGE_EXISTS;
          }
      }
      ---------- END SOURCE ----------

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: