FULL PRODUCT VERSION : java version "1.5.0" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64) Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing) ADDITIONAL OS VERSION INFORMATION : Microsoft Windows XP [Version 5.1.2600] A DESCRIPTION OF THE PROBLEM : When you want to adjust glyphs positions, you must call setGlyphPosition. This statement works fine when drawing in screen but is ignored when printing. 'Graphics.DrawGlyphVector' seems to be mapped to 'drawString' when printing. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Running the executable test case. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - Numbers from 0 to 9 separated by 10 millimeters aproximately. ACTUAL - Numbers from 0 to 9 writen without separation. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.awt.*; import java.awt.geom.*; import java.awt.font.*; import java.awt.print.*; import javax.print.attribute.*; public class Print implements Printable { public static void main(String args[]) { try { HashPrintRequestAttributeSet aSet; aSet = new HashPrintRequestAttributeSet(); PrinterJob pj = PrinterJob.getPrinterJob(); if(pj.printDialog(aSet)) { pj.setPrintable(new Print()); pj.print(aSet); } } catch(PrinterException ex) { ex.printStackTrace(); } System.exit(0); } public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException { if(pageIndex > 0) return NO_SUCH_PAGE; float x = (float)pageFormat.getImageableX() + 20f, y = (float)pageFormat.getImageableY() + 30f; Graphics2D g2 = (Graphics2D)g; Font font = new Font("SansSerif", Font.PLAIN, 20); FontRenderContext frc = g2.getFontRenderContext(); GlyphVector v = font.createGlyphVector(frc, "0123456789"); for(int i = 0; i <= v.getNumGlyphs(); i++) { Point2D.Float p = new Point2D.Float(); p.x = i * 40f; p.y = 0; v.setGlyphPosition(i, p); } g2.drawGlyphVector(v, x, y); return PAGE_EXISTS; } } ---------- END SOURCE ---------- ###@###.### 10/29/04 19:51 GMT
|