i trying print using textlayout class. when print mathematical symbols, odd behavior.
the image below shows results printing strings "first + 2" , "first \u222a 2" pdf file. when 'union' symbol (\u222a) printed, looks characters following symbol overwrite characters before symbol.
here test code prints string not contain \u222a , string does:
public class printtest { public static void main(string[] args) { printerjob pj = printerjob.getprinterjob(); pj.setprintable(new printable() { public int print(graphics g, pageformat pf, int pageindex) { if (pageindex != 0) return no_such_page; graphics2d g2 = (graphics2d) g; font font = new font("sansserif", font.plain, 10); // draw string + char textlayout layout = new textlayout("first + 2", font, g2 .getfontrendercontext()); layout.draw(g2, 40, 80); // draw string union character layout = new textlayout("first \u222a 2", font, g2 .getfontrendercontext()); layout.draw(g2, 40, 100); return page_exists; } }); if (pj.printdialog()) { try { pj.print(); } catch (printerexception e) { system.out.println(e.getmessage()); } } }
}
i running java 1.7.0_17 on windows 7 & 8, , have tested on several printers, including printing pdf. tests show same problem. same results 'union', 'intersection' , 'exclusion' symbols.
i stuck here. appreciated.
update: problem seems occur when using logical fonts. tested of installed logical fonts ('dialog', 'dialoginput', 'monospaced, 'sansserif' , 'serif') , got same problem. when tested physical fonts support these symbols ('lucida sans' , 'arial unicode ms') got desired output.
this resolves immediate issue me since i'm not tied using logical fonts.
actually, printing unicode characters time; title of post suggests printing other unicode. alphabetic characters print correctly encoded in unicode, since how java encodes strings.
so trying print "union" symbol, , isn't working. evidence have supported on printer printing on? quite possibly not supported on printer you've tried, hence unpredictable behavior. obvious thing cause this.
Comments
Post a Comment