[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-macosx-port-dev
Subject:    Printing problem on Mountain Lion with java7
From:       Timo Tommila <timo.tommila () me ! com>
Date:       2013-02-10 14:04:29
Message-ID: 66ED375C-3BAC-4879-8862-9E4A41F1C2B7 () me ! com
[Download RAW message or body]

Hi,

Printing on Mountain Lion with java7 is not working correctly!

If I try to change font family, font size or to use bold effect etc, 
I always get the same 'unknown' font, the font  size is fixed and the bold effect is not applied.

The code works correctly on XP with java7 on the same MacBook Pro (with help of VMWare) and
of course the code works also on windows PC.

Is this a known bug?

I am using following setup:

java version "1.7.0_13"
Java(TM) SE Runtime Environment (build 1.7.0_13-b20)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)

MacOSX 10.8.2

Timo

ps. You will find the test code below:

_________________________________________________________________

package printingtest;

import java.awt.*;
import java.awt.print.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;

public class PrintingTest implements Printable {

    public PrintingTest() {

        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        aset.add(new JobName("Test printing job", null));
        PrinterJob pj = PrinterJob.getPrinterJob();
        pj.setPrintable(this);
        PrintService[] services = PrinterJob.lookupPrintServices();

        if (services.length > 0) {
            try {
                pj.setPrintService(services[0]);
                pj.pageDialog(aset);
                if (pj.printDialog(aset)) pj.print(aset);

            } catch (PrinterException pe) {}
        }
    }
    Font titleFont = new Font("Times", Font.BOLD, 24);
    Font textFont = new Font("monospaced", Font.PLAIN, 12);
    Font signatureFont = new Font("Serif", Font.PLAIN, 7);

    public int print(Graphics g, PageFormat pf, int pageIndex) {
        if (pageIndex == 0) {
            Graphics2D g2d = (Graphics2D) g;
            g2d.translate(pf.getImageableX(), pf.getImageableY());
            g2d.setFont(titleFont);     g2d.drawString("Title string in Times(24,bold)", 150, 260);
            g2d.setFont(textFont);      g2d.drawString("Text string in monospaced(12)", 150, 280);
            g2d.setFont(signatureFont); g2d.drawString("Signature string in Serif(7)", 150, 300);

            return Printable.PAGE_EXISTS;
        } else  return Printable.NO_SUCH_PAGE;
    }

    public static void main(String arg[]) {
        PrintingTest sp = new PrintingTest();
    }
}

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic