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

[macosx] Wrong letters are printed when we draw Japanese and English

    XMLWordPrintable

Details

    • 2d
    • 7u6

    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 OS X 10.7.5

      A DESCRIPTION OF THE PROBLEM :
      Wrong letters are printed when we draw Japanese and English on Mac. " :abc123 " is printed as " >cde345 " .
      We can see this problem when we print the drawn String by graphics.drawString(AttributedStringIterator)

      REGRESSION. Last worked in version 6u45

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run the program to test
      2. Print dialog is shown
      3. Push the [Print] button
      4. Check the output

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
       " ???:abc123 " should be printed.
      ACTUAL -
       " ???<cde345 " is printed.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.Font;
      import java.awt.Graphics;
      import java.awt.Graphics2D;
      import java.awt.font.TextAttribute; import java.awt.print.PageFormat;
      import java.awt.print.Printable;
      import java.awt.print.PrinterException; import java.awt.print.PrinterJob; import java.text.AttributedString;
      import javax.swing.SwingUtilities;

      public class PrintTest2 implements Printable {
          public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException {
              if (pageIndex > 1) {
                  return Printable.NO_SUCH_PAGE;
              }

              Graphics2D g2 = (Graphics2D) g;
              g2.translate((int) pf.getImageableX(), (int) pf.getImageableY());
              AttributedString attrString = new AttributedString( " ???:abc123 " );
              attrString.addAttribute(TextAttribute.FONT, new Font(Font.SERIF, Font.PLAIN, 48));
              g2.drawString(attrString.getIterator(), 20f, 60f);
              return Printable.PAGE_EXISTS;
          }

          public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                  @Override
                  public void run() {
                      try {
                          PrinterJob job = PrinterJob.getPrinterJob();
                          PrintTest2 printable = new PrintTest2();
                          job.setPrintable(printable);
                          if (job.printDialog()) {
                              job.print();
                          }
                      } catch (PrinterException e) {
                          e.printStackTrace();
                      }
                  }
              });
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      We can avoid this bug if we use Java standard printing dialog.
      But the OS native printing dialog is better because that has a function to export PDF.

      Attachments

        Issue Links

          Activity

            People

              jgodinez Jennifer Godinez (Inactive)
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: