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

List:       openjdk-2d-dev
Subject:    [OpenJDK 2D-Dev] Artifacts when printing
From:       Raffaele Sgarro <raffaelesgarro () gmail ! com>
Date:       2013-10-30 9:40:16
Message-ID: CAKg=9UVmd7o-M_e8NK52+5YQK4t4b01+Rqxef5nNAzeN2SRCJA () mail ! gmail ! com
[Download RAW message or body]

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?

[Attachment #3 (text/html)]

<div dir="ltr">It sems that certain characters in the &quot;Dialog&quot; font family \
broke the painting (first line is Arial, second Times New, third \
Dialog):<div><br></div><div><img src="http://oi44.tinypic.com/28i45n5.jpg" \
alt="Immagine in linea 1"><br> </div><div><br></div><div>This is the code to produce \
the output:</div><div><br></div><div><pre \
style="color:rgb(0,0,0);font-size:medium"><span \
style="color:rgb(128,0,0);font-weight:bold">public</span> <span \
style="color:rgb(128,0,0);font-weight:bold">class</span> ArtifactsWhenUsingDialogFont \
<span style="color:rgb(128,0,128)">{</span>  
    <span style="color:rgb(128,0,0);font-weight:bold">public</span> <span \
style="color:rgb(128,0,0);font-weight:bold">static</span> <span \
style="color:rgb(187,121,119)">void</span> main<span \
style="color:rgb(128,128,48)">(</span><span \
style="color:rgb(187,121,119);font-weight:bold">String</span><span \
style="color:rgb(128,128,48)">.</span><span \
style="color:rgb(128,128,48)">.</span><span style="color:rgb(128,128,48)">.</span> \
args<span style="color:rgb(128,128,48)">)</span> <span \
style="color:rgb(128,0,0);font-weight:bold">throws</span> <span \
style="color:rgb(187,121,119);font-weight:bold">Exception</span> <span \
style="color:rgb(128,0,128)">{</span>  PrinterJob job <span \
style="color:rgb(128,128,48)">=</span> PrinterJob<span \
style="color:rgb(128,128,48)">.</span>getPrinterJob<span \
style="color:rgb(128,128,48)">(</span><span \
style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>  \
job<span style="color:rgb(128,128,48)">.</span>setPrintService<span \
style="color:rgb(128,128,48)">(</span>PrintServiceLookup<span \
style="color:rgb(128,128,48)">.</span>lookupDefaultPrintService<span \
style="color:rgb(128,128,48)">(</span><span \
style="color:rgb(128,128,48)">)</span><span \
style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>  \
job<span style="color:rgb(128,128,48)">.</span>setPrintable<span \
style="color:rgb(128,128,48)">(</span><span \
style="color:rgb(128,0,0);font-weight:bold">new</span> Printable<span \
style="color:rgb(128,128,48)">(</span><span \
style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">{</span>  
          <span style="color:rgb(128,128,48)">@</span>Override
          <span style="color:rgb(128,0,0);font-weight:bold">public</span> <span \
style="color:rgb(187,121,119)">int</span> print<span \
style="color:rgb(128,128,48)">(</span><span \
style="color:rgb(187,121,119);font-weight:bold">Graphics</span> graphics<span \
style="color:rgb(128,128,48)">,</span> PageFormat pageFormat<span \
style="color:rgb(128,128,48)">,</span> <span \
style="color:rgb(187,121,119)">int</span> pageIndex<span \
style="color:rgb(128,128,48)">)</span> <span \
style="color:rgb(128,0,0);font-weight:bold">throws</span> PrinterException <span \
style="color:rgb(128,0,128)">{</span>  graphics<span \
style="color:rgb(128,128,48)">.</span>translate<span \
style="color:rgb(128,128,48)">(</span> <span \
style="color:rgb(128,128,48)">(</span><span \
style="color:rgb(187,121,119)">int</span><span style="color:rgb(128,128,48)">)</span> \
pageFormat<span style="color:rgb(128,128,48)">.</span>getImageableX<span \
style="color:rgb(128,128,48)">(</span><span \
style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,128,48)">,</span> \
<span style="color:rgb(128,128,48)">(</span><span \
style="color:rgb(187,121,119)">int</span><span style="color:rgb(128,128,48)">)</span> \
pageFormat<span style="color:rgb(128,128,48)">.</span>getImageableY<span \
style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span> \
<span style="color:rgb(128,128,48)">)</span><span \
style="color:rgb(128,0,128)">;</span>  <span \
style="color:rgb(128,0,0);font-weight:bold">final</span> <span \
style="color:rgb(187,121,119);font-weight:bold">String</span> target <span \
style="color:rgb(128,128,48)">=</span> <span \
style="color:rgb(0,0,230)">&quot;OOOOOOOOOO</span><span \
style="color:rgb(15,105,255)">\u2014</span><span \
style="color:rgb(0,0,230)">MMMMMMMMM</span><span \
style="color:rgb(15,105,255)">\u2014</span><span \
style="color:rgb(0,0,230)">IIIIIIIIII</span><span \
style="color:rgb(15,105,255)">\u2014</span><span \
style="color:rgb(0,0,230)">&quot;</span><span style="color:rgb(128,0,128)">;</span>  \
printLine<span style="color:rgb(128,128,48)">(</span>graphics<span \
style="color:rgb(128,128,48)">,</span> target<span \
style="color:rgb(128,128,48)">,</span> <span \
style="color:rgb(0,0,230)">&quot;Arial&quot;</span><span \
style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>  \
printLine<span style="color:rgb(128,128,48)">(</span>graphics<span \
style="color:rgb(128,128,48)">,</span> target<span \
style="color:rgb(128,128,48)">,</span> <span style="color:rgb(0,0,230)">&quot;Times \
New Roman&quot;</span><span style="color:rgb(128,128,48)">)</span><span \
style="color:rgb(128,0,128)">;</span>  printLine<span \
style="color:rgb(128,128,48)">(</span>graphics<span \
style="color:rgb(128,128,48)">,</span> target<span \
style="color:rgb(128,128,48)">,</span> <span \
style="color:rgb(0,0,230)">&quot;Dialog&quot;</span><span \
style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>  \
<span style="color:rgb(128,0,0);font-weight:bold">return</span> pageIndex <span \
style="color:rgb(128,128,48)">=</span><span style="color:rgb(128,128,48)">=</span> \
<span style="color:rgb(0,140,0)">0</span> <span \
style="color:rgb(128,128,48)">?</span> PAGE_EXISTS <span \
style="color:rgb(128,128,48)">:</span> NO_SUCH_PAGE<span \
style="color:rgb(128,0,128)">;</span>  <span style="color:rgb(128,0,128)">}</span>
 
          <span style="color:rgb(128,0,0);font-weight:bold">private</span> <span \
style="color:rgb(187,121,119)">int</span> lineCounter <span \
style="color:rgb(128,128,48)">=</span> <span style="color:rgb(0,140,0)">0</span><span \
style="color:rgb(128,0,128)">;</span>  
          <span style="color:rgb(128,0,0);font-weight:bold">private</span> <span \
style="color:rgb(187,121,119)">void</span> printLine<span \
style="color:rgb(128,128,48)">(</span><span \
style="color:rgb(187,121,119);font-weight:bold">Graphics</span> graphics<span \
style="color:rgb(128,128,48)">,</span> <span \
style="color:rgb(187,121,119);font-weight:bold">String</span> text<span \
style="color:rgb(128,128,48)">,</span> <span \
style="color:rgb(187,121,119);font-weight:bold">String</span> fontName<span \
style="color:rgb(128,128,48)">)</span> <span style="color:rgb(128,0,128)">{</span>  \
graphics<span style="color:rgb(128,128,48)">.</span>setFont<span \
style="color:rgb(128,128,48)">(</span><span \
style="color:rgb(128,0,0);font-weight:bold">new</span> <span \
style="color:rgb(187,121,119);font-weight:bold">Font</span><span \
style="color:rgb(128,128,48)">(</span>fontName<span \
style="color:rgb(128,128,48)">,</span> <span \
style="color:rgb(187,121,119);font-weight:bold">Font</span><span \
style="color:rgb(128,128,48)">.</span>PLAIN<span \
style="color:rgb(128,128,48)">,</span> <span \
style="color:rgb(0,140,0)">20</span><span style="color:rgb(128,128,48)">)</span><span \
style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>  \
graphics<span style="color:rgb(128,128,48)">.</span>drawString<span \
style="color:rgb(128,128,48)">(</span>text<span \
style="color:rgb(128,128,48)">,</span> <span \
style="color:rgb(0,140,0)">20</span><span style="color:rgb(128,128,48)">,</span> \
<span style="color:rgb(0,140,0)">20</span> <span \
style="color:rgb(128,128,48)">*</span> <span \
style="color:rgb(128,128,48)">+</span><span \
style="color:rgb(128,128,48)">+</span>lineCounter<span \
style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>  \
                <span style="color:rgb(128,0,128)">}</span>
      <span style="color:rgb(128,0,128)">}</span><span \
style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>  \
job<span style="color:rgb(128,128,48)">.</span>print<span \
style="color:rgb(128,128,48)">(</span><span \
style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>    \
<span style="color:rgb(128,0,128)">}</span> <span \
style="color:rgb(128,0,128)">}</span></pre></div><div>(<a \
href="https://gist.github.com/RaffaeleSgarro/7229649">link to the \
gist</a>)</div><div><br></div><div>The problem is that the &quot;Dialog&quot; font \
family appears to be the default one, at least on the Windows platform. Is this a \
known bug?</div> </div>



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

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