JDK-8193593 : Rotated and scaled text is printed with wrong orientation
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 8u91,9,10
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2017-12-13
  • Updated: 2025-10-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Causes :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [versão 10.0.15063]

EXTRA RELEVANT SYSTEM CONFIGURATION :
Tested with 3 different printers, all showed the problem:
- HP LaserJet P3010 Series PCL 6 (61.83.41.3)
- Brother MFC-J6510DW FV
- Microsoft Print to PDF (The one that comes with Windows 10)

A DESCRIPTION OF THE PROBLEM :
When printing text that is both rotated and scale to a printer, the outputs text orientation is wrong. Aparently, the individual characters are correctly rotated, but the text orientation as a whole is wrong (left-to-right instead of top-to-bottom).

Some extra information:
- Doesn't seem to happen for all combinations of fonts, sizes and scales. With the one provided in the sample source code it happened on every printer I tested.
- Doesn't seem to happen on screen or image Graphics, only PrinterJob graphics

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the source code, select a printer in the spool, click "Print", and the 4th printed text should be wrong

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All four texts to be printed in the correct orientation
ACTUAL -
The 4th combination is printed in the wrong orientation

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import javax.print.PrintService;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.swing.JFrame;

public class Test {

    public static void main(String[] args) throws Exception {
        PrintRequestAttributeSet attributeSet = new HashPrintRequestAttributeSet();
        PrinterJob job = PrinterJob.getPrinterJob();
        if (job.printDialog()) {
            PrintService sv = job.getPrintService();
            job.setPrintable(new ThePrinter());
            job.setJobName("Job");
            job.print(attributeSet);
        }

    }

    private static class ThePrinter implements Printable {

        @Override
        public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
            if (pageIndex > 0) {
                return Printable.NO_SUCH_PAGE;
            }
              Graphics2D g2d = (Graphics2D) graphics.create();
            AffineTransform af;
            g2d.setColor(Color.BLACK);
            // (Works) Text that is not rotated, without scale
            af = new AffineTransform();
            g2d.setFont(new Font("Arial", Font.PLAIN, 12).deriveFont(af));
            g2d.drawString("No rotate, no scale", 100, 100);
            // (Works) Text that is not rotated, with scale
            af = new AffineTransform();
            af.scale(0.93,1.0);
            g2d.setFont(new Font("Arial", Font.PLAIN, 12).deriveFont(af));
            g2d.drawString("No rotate, with scale", 100, 130);
            // (Works) Text that is rotated, without scale
            af = new AffineTransform();
            af.rotate(Math.toRadians(90));
            g2d.setFont(new Font("Arial", Font.PLAIN, 12).deriveFont(af));
            g2d.drawString("With rotate, no scale", 100, 160);
            // (DOESN'T Work) Text that is rotated, with scale
            af = new AffineTransform();
            af.rotate(Math.toRadians(90));
            af.scale(0.93,1.0);
            g2d.setFont(new Font("Arial", Font.PLAIN, 12).deriveFont(af));
            g2d.drawString("With rotate, with scale", 130, 160);

            g2d.dispose();
            return Printable.PAGE_EXISTS;
        }

    }

}

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


Comments
Regression of JDK-8132890. Passed in 9b91, failing from 9b92.
18-12-2017

Reported with: ============ JDK 8u152 Windows 10 - HP LaserJet P3010 Series PCL 6 (61.83.41.3) - Brother MFC-J6510DW FV - Microsoft Print to PDF (The one that comes with Windows 10) Checked this for reported JDK version as well as JDK 9 and 10 and could confirm the issue. See attached screenshots as reference from pdf print. Results: ========== 8: OK 8u77: OK 8u91: FAIL 8u152: FAIL 9: FAIL 10: FAIL This seems a regression in 8u91, likely introduced via fix in JDK-8132890. To verify run the attached test case with respective JDK version and test with any available printer or even Microsoft Print to PDF.
15-12-2017