JDK-8029984 : when printing the characters are overlapping to next character
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2013-05-30
  • Updated: 2014-12-04
  • Resolved: 2014-12-04
Related Reports
Duplicate :  
Duplicate :  
Description
FULL PRODUCT VERSION :


A DESCRIPTION OF THE PROBLEM :
I have a problem in printing to any printers. It working properly at java 6 but trying to print at java 7; the characters are overlapping to next character.

REGRESSION.  Last worked in version 7u21

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Here is the test case .

import java.awt.*;
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.awt.print.*;
import java.util.*;
import javax.swing.*;
 
public class PrintTest {
 
public static void main(String[] args) {
new PrintTestFrame().setVisible(true);
}
}
 
class PrintTestFrame extends JFrame implements ActionListener {
 
public PrintTestFrame() {
setTitle( " PrintTest " );
setSize(350, 300);
setDefaultCloseOperation(PrintTestFrame.EXIT_ON_CLOSE);
 
Container contentPane = getContentPane();
canvas = new PrintPanel();
contentPane.add(canvas,  " Center " );
 
JPanel buttonPanel = new JPanel();
printButton = new JButton( " Print " );
buttonPanel.add(printButton);
printButton.addActionListener(this);
 
contentPane.add(buttonPanel,  " North " );
}
 
public void actionPerformed(ActionEvent event) {
Object source = event.getSource();
if (source == printButton) {
PrinterJob printJob = PrinterJob.getPrinterJob();
PageFormat pageFormat = printJob.defaultPage();
printJob.setPrintable(canvas, pageFormat);
if (printJob.printDialog()) {
try {
printJob.print();
} catch (PrinterException exception) {
JOptionPane.showMessageDialog(this, exception);
}
}
}
}
 
private JButton printButton;
 
private PrintPanel canvas;
}
 
class PrintPanel extends JPanel implements Printable {
 
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
drawPage(g2);
}
 
public int print(Graphics g, PageFormat pf, int page)
throws PrinterException {
if (page >= 1)
return Printable.NO_SUCH_PAGE;
Graphics2D g2 = (Graphics2D) g;
g2.setPaint(Color.black);
g2.translate(pf.getImageableX(), pf.getImageableY());
g2.draw(new Rectangle2D.Double(0, 0, pf.getImageableWidth(), pf
.getImageableHeight()));
 
drawPage(g2);
return Printable.PAGE_EXISTS;
}
 
public void drawPage(Graphics2D g2) {
Font f = new Font(Font.DIALOG, Font.PLAIN, 12);
g2.setFont(f);
g2.drawString( " 100094 ?? ?? ??? ??????68??????  " , 10, 10);
}
}



REPRODUCIBILITY :
This bug can be reproduced always.
Comments
This involves CJK and a couple of bugs came to mind but it appears to be a duplicate of https://bugs.openjdk.java.net/browse/JDK-8008535 I decoded the CDK text string so that it could be put into Java source as :- String s = "\u0031\u0030\u0030\u0030\u0039\u0034\u0020\u4e2d\u56fd\u0020\u5317\u4eac\u0020" + "\u5317\u4eac\u5e02\u0020\u6d77\u6dc0\u533a\u5317\u6e05\u8def\u0036\u0038\u53f7\u7528\u53cb\u8f6f\u4ef6\u56ed\u0020"; I found this reproduced up to b92 but was fixed in b93. Its also fixed in 7u40+ since we backported 8008535 FWIW the bug was originally introduced in JDk 7 b08 by the fix for https://bugs.openjdk.java.net/browse/JDK-6425068
11-12-2013