-
Bug
-
Resolution: Fixed
-
P4
-
1.4.2
-
b51
-
x86
-
linux
FULL PRODUCT VERSION :
java version "1.4.2_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Debian sid:
Linux SomeTwo 2.6.7-2-p4-smp #1 SMP Wed Jul 7 16:50:30 CDT 2004 i686 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
Cups printing system:
ii cupsys 1.1.23-1
A DESCRIPTION OF THE PROBLEM :
When drawing (printing) strings using PSPathGraphics, any String with a Question Mark is rendered as curves, instead of using a postscript font (if available).
My app requires consistent output. The output using our printers is very noticably different between the postscript text rendering path and the curve-based path. In fact, the difference is noticable even between a TTF rendered using glyphs, and the same font in Postscript format uploaded to the printer -- the glyphs are rendered significantly bolder than the PS font. The SansSerif font on our printers is another very noticable case since the glyphs on the printer are dramatically different from the TTF glyphs.
I've traced this through to the cause:
PSPathGraphics.drawString()
PSPrinterJob.textOut()
sun.awt.PlatformFont.makeMultiCharsetString(char[], int, int, boolean)
The final parameter to makeMultiCharsetString is a flag that indicates if unconvertable characters should be returned as a default value (a question mark character, it seems). If the flag is set to false, null is returned instead of returning the CharsetString array.
The issue is in the code which tests for "convertability". It checks if each char can be converted successfully; if it cannot be converted, the current character is set to the default char (a question mark). If any character ends up as the default character and the allowDefault flag is false, null is returned. If your string contains a question mark and allowDefault is false, null is returned always.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute the attached test case with a postscript printer discoverable. View the Postscript output (Print to File)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Simple strings with or without questions marks should be printed using the same path.
ACTUAL -
Simple strings with question marks are printed using glyphs. Simple strings without question marks are printed using the postscript font path.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.Destination;
import java.awt.*;
import java.awt.print.*;
import java.io.File;
public class PSQuestionMarkTest implements Printable {
private static String prefix;
// Args[0] is a prefix that will be printed on all 3 lines for comparison purposes.
public static void main(String[] args) throws PrinterException {
prefix = (args.length > 0 ? args[0] : "");
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setPrintable(new PSQuestionMarkTest());
final PrintService[] printServices =
PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.POSTSCRIPT, null);
if (printServices.length > 0)
pj.setPrintService(printServices[0]);
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
File output = new File(System.getProperty("user.home"), "PSQuestionMarkTest.ps");
pras.add(new Destination(output.toURI()));
if (pj.printDialog(pras))
pj.print(pras);
}
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
if (pageIndex != 0)
return Printable.NO_SUCH_PAGE;
graphics.drawString(prefix + "1", 100, 100);
graphics.drawString(prefix + "?2", 100, 150);
graphics.drawString(prefix + "3", 100, 200);
return Printable.PAGE_EXISTS;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't print question marks.
OK fine, if your oddball app *must* print question marks but you require a consistent look, print text separately from question marks using a separate call to drawString.
###@###.### 2005-1-13 20:41:24 GMT
java version "1.4.2_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Debian sid:
Linux SomeTwo 2.6.7-2-p4-smp #1 SMP Wed Jul 7 16:50:30 CDT 2004 i686 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
Cups printing system:
ii cupsys 1.1.23-1
A DESCRIPTION OF THE PROBLEM :
When drawing (printing) strings using PSPathGraphics, any String with a Question Mark is rendered as curves, instead of using a postscript font (if available).
My app requires consistent output. The output using our printers is very noticably different between the postscript text rendering path and the curve-based path. In fact, the difference is noticable even between a TTF rendered using glyphs, and the same font in Postscript format uploaded to the printer -- the glyphs are rendered significantly bolder than the PS font. The SansSerif font on our printers is another very noticable case since the glyphs on the printer are dramatically different from the TTF glyphs.
I've traced this through to the cause:
PSPathGraphics.drawString()
PSPrinterJob.textOut()
sun.awt.PlatformFont.makeMultiCharsetString(char[], int, int, boolean)
The final parameter to makeMultiCharsetString is a flag that indicates if unconvertable characters should be returned as a default value (a question mark character, it seems). If the flag is set to false, null is returned instead of returning the CharsetString array.
The issue is in the code which tests for "convertability". It checks if each char can be converted successfully; if it cannot be converted, the current character is set to the default char (a question mark). If any character ends up as the default character and the allowDefault flag is false, null is returned. If your string contains a question mark and allowDefault is false, null is returned always.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute the attached test case with a postscript printer discoverable. View the Postscript output (Print to File)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Simple strings with or without questions marks should be printed using the same path.
ACTUAL -
Simple strings with question marks are printed using glyphs. Simple strings without question marks are printed using the postscript font path.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.Destination;
import java.awt.*;
import java.awt.print.*;
import java.io.File;
public class PSQuestionMarkTest implements Printable {
private static String prefix;
// Args[0] is a prefix that will be printed on all 3 lines for comparison purposes.
public static void main(String[] args) throws PrinterException {
prefix = (args.length > 0 ? args[0] : "");
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setPrintable(new PSQuestionMarkTest());
final PrintService[] printServices =
PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.POSTSCRIPT, null);
if (printServices.length > 0)
pj.setPrintService(printServices[0]);
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
File output = new File(System.getProperty("user.home"), "PSQuestionMarkTest.ps");
pras.add(new Destination(output.toURI()));
if (pj.printDialog(pras))
pj.print(pras);
}
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
if (pageIndex != 0)
return Printable.NO_SUCH_PAGE;
graphics.drawString(prefix + "1", 100, 100);
graphics.drawString(prefix + "?2", 100, 150);
graphics.drawString(prefix + "3", 100, 200);
return Printable.PAGE_EXISTS;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't print question marks.
OK fine, if your oddball app *must* print question marks but you require a consistent look, print text separately from question marks using a separate call to drawString.
###@###.### 2005-1-13 20:41:24 GMT