JDK-8007996 : Major printing bug in latest Java 7 on OSX: no font attributes being applied
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 7u13
  • Priority: P2
  • Status: Resolved
  • Resolution: Duplicate
  • OS: os_x
  • CPU: x86
  • Submitted: 2013-02-12
  • Updated: 2013-04-08
  • Resolved: 2013-04-08
Java version -  1.7.0_13-b20

While using our reporting tool that under OS X, the fonts were all looking the same - default size, plain, default font. A simple test showed that this is not complicated to reproduce:

import java.awt.Font;
import java.awt.Graphics;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterJob;

import javax.print.attribute.HashPrintRequestAttributeSet;

public class FontIssue {
  public static void main(String[] args) throws Exception {
    PrinterJob printerJob = PrinterJob.getPrinterJob();
    printerJob.setPrintable( new MyPrintable() );

    printerJob.print(new HashPrintRequestAttributeSet());

class MyPrintable implements Printable {

  public int print(Graphics g, PageFormat pf, int pageIndex) {
    if (pageIndex == 0) {
        g.translate((int) (pf.getImageableX()), (int) (pf.getImageableY()));
        g.setFont( new Font("Helvetica",5,Font.BOLD | Font.ITALIC) );
      g.drawString( "THIS IS A TEST", 123, 123 );
      return Printable.PAGE_EXISTS;
    return Printable.NO_SUCH_PAGE;

Normally the text "THIS IS A TEST" should print as size 5, bold and italic. Under Windows it does, but on a Mac system, the text is printed size 12 and in plain.

Note that this is a new issue, in earlier versions of Java 7 this did not occur.

Also, note that these folks seem to have the same issue as we do: https://www.servoy.com/forum/viewtopic.php?p=103912

CAP member can still reproduce the problem in 7u17. They can reproduce the issue not only with the test code they submitted but in ANY Java program that prints text with fonts - no font attributes are applied to any text when printing. However this problem is NOT reproducible in the latest version of Java 8 (which may also simply be because the bug was introduced in a patch that has not been applied to Java 8 yet).

Looks like a duplicate of 7183516 fixed in 7u14