JDK-7082319 : Spacing is incorrect printing Arial 8pt on Windows.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86
  • Submitted: 2011-08-23
  • Updated: 2012-03-20
  • Resolved: 2011-09-02
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
Microsoft Windows [Version 6.1.7600]


A DESCRIPTION OF THE PROBLEM :
Spacing is incorrect printing Arial 8pt on Windows.

REGRESSION.  Last worked in version 5.0

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile, run, select printer and print.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
printing printing printing
ACTUAL -
printingprintingprinting

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package test;

import java.awt.*;
import java.awt.print.*;
import javax.swing.*;

public class PrintLabel extends JLabel implements Printable {
	public PrintLabel() {
		// Spacing is incorrect printing Arial 8pt on Windows.
		setFont(new Font("Arial", Font.PLAIN, 8));
		setText("printing printing printing");
		setBounds(10, 10, 200, 10);
		
        PrinterJob printJob = PrinterJob.getPrinterJob();
		printJob.setPrintable(this);
		if (printJob.printDialog()) {
			try {
				printJob.print();
				System.exit(0);
			} catch (Exception PrintException) {
				PrintException.printStackTrace();
			}
		}
	}
	
	public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
		if (pageIndex == 0) {
			paint(graphics);
			return Printable.PAGE_EXISTS;
		}
		return Printable.NO_SUCH_PAGE;
	}
	
	public static void main(String [] args) {
		new PrintLabel();
	}
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Unknown