JDK-8040274 : Postscript printer fonts not used by StreamPrintService on Linux
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 7u3
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • Submitted: 2013-12-05
  • Updated: 2014-11-21
  • Resolved: 2014-04-30
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
alex@alexdebian:~l$ cat /etc/debian_version
6.0.8
alex@alexdebian:~$ cat /etc/issue
Debian GNU/Linux 6.0 
 \l

alex@alexdebian:~l$ uname -a
Linux alexdebian 2.6.32-5-686 #1 SMP Mon Jun 13 04:13:06 UTC 2011 i686 GNU/Linux
alex@alexdebian:~$ uname -r
2.6.32-5-686


A DESCRIPTION OF THE PROBLEM :
When using the Java Print service to produce postscript stream output all fonts
are rendered as shapes rather than using standard postscript fonts.  This
causes any 'print' file to be extremely large and the processing excessively
slow.

REGRESSION.  Last worked in version 6u43

ADDITIONAL REGRESSION INFORMATION:
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached program and inspect the file out.ps

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The resulting postscript file is small (about 2KB) and the text string "example string" is rendered with the postscript command "<6578616d706c6520737472696e67> 87.12001 250.0 250.0 S"
ACTUAL -
The resulting postscript file is large (about 12KB) and the text string "example string" is rendered as shapes.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
//Source:http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4483236
/*
 * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
 *
 * This software is the proprietary information of Sun Microsystems, Inc.
 * Use is subject to license terms.
 *
 */

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

/*
 * Use the Java(TM) Print Service API to locate a service which can export
 * 2D graphics to a stream as Postscript. This may be spooled to a
 * Postscript printer, or used in a postscript viewer.
 */
public class Print2DtoStream implements Printable{

    public Print2DtoStream() {
        /* Use the pre-defined flavor for a Printable from an
InputStream */
        DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;

        /* Specify the type of the output stream */
        String psMimeType = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType
();

        /* Locate factory which can export a GIF image stream as
Postscript */
        StreamPrintServiceFactory[] factories =
        StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
                    flavor, psMimeType);
        if (factories.length == 0) {
            System.err.println("No suitable factories");
            System.exit(0);
        }

        try {
            /* Create a file for the exported postscript */
            FileOutputStream fos = new FileOutputStream("out.ps");

            /* Create a Stream printer for Postscript */
            StreamPrintService sps = factories[0].getPrintService
(fos);

            /* Create and call a Print Job */
            DocPrintJob pj = sps.createPrintJob();
            PrintRequestAttributeSet aset = new
HashPrintRequestAttributeSet();

            Doc doc = new SimpleDoc(this, flavor, null);

            pj.print(doc, aset);
            fos.close();

        } catch (PrintException pe) {
            System.err.println(pe);
        } catch (IOException ie) {
            System.err.println(ie);
        }
    }
public int print(Graphics g,PageFormat pf,int pageIndex) {
if (pageIndex == 0) {
Graphics2D g2d = (Graphics2D)g;

g2d.translate(pf.getImageableX(), pf.getImageableY());
g2d.setColor(Color.black);

g2d.fillRect(0,0,200,200);
g2d.drawString("example string", 250, 250);
return Printable.PAGE_EXISTS;
} else {
return Printable.NO_SUCH_PAGE;
}
}

public static void main(String args[]) {
Print2DtoStream sp = new Print2DtoStream();
}
}


---------- END SOURCE ----------
Comments
Dup of 8023990
30-04-2014

Will need review for >= JDK 7 Moving to 7u80 and will review ASAP. Ping me directly with any concerns about this move.
22-04-2014

is it affecting 8 or 9?
15-04-2014