[OpenJDK 2D-Dev] Artifacts when printing
Raffaele Sgarro
raffaelesgarro at gmail.com
Wed Oct 30 09:40:16 UTC 2013
It sems that certain characters in the "Dialog" font family broke the
painting (first line is Arial, second Times New, third Dialog):
[image: Immagine in linea 1]
This is the code to produce the output:
public class ArtifactsWhenUsingDialogFont {
public static void main(String... args) throws Exception {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintService(PrintServiceLookup.lookupDefaultPrintService());
job.setPrintable(new Printable(){
@Override
public int print(Graphics graphics, PageFormat pageFormat,
int pageIndex) throws PrinterException {
graphics.translate( (int) pageFormat.getImageableX(),
(int) pageFormat.getImageableY() );
final String target =
"OOOOOOOOOO\u2014MMMMMMMMM\u2014IIIIIIIIII\u2014";
printLine(graphics, target, "Arial");
printLine(graphics, target, "Times New Roman");
printLine(graphics, target, "Dialog");
return pageIndex == 0 ? PAGE_EXISTS : NO_SUCH_PAGE;
}
private int lineCounter = 0;
private void printLine(Graphics graphics, String text,
String fontName) {
graphics.setFont(new Font(fontName, Font.PLAIN, 20));
graphics.drawString(text, 20, 20 * ++lineCounter);
}
});
job.print();
}}
(link to the gist <https://gist.github.com/RaffaeleSgarro/7229649>)
The problem is that the "Dialog" font family appears to be the default one,
at least on the Windows platform. Is this a known bug?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20131030/e0f0ab54/attachment.html>
More information about the 2d-dev
mailing list