printing - .NET PrintDocument does not print monospace fonts correctly -


i code print few blocks of text:

var doc=new printdocument();  doc.printpage += (sender, e) => {    e.graphics.drawstring(     "123456789 123456789 123456789 123456789 123456789 123456789 123456789 ",       new font("courier new", 12),       brushes.black, 0, 0);    };  doc.print(); 

courier new supposed 10 charsperinch, each block (including space) should 2.54 cm long. when printing - regardless on printer, measure 13.1 cm 5 blocks instead of 12.7 cm. when draw rectangles 1 inch width, can see text longer should be, not general scaling problem, text printed wrong.

can confirm , more importantly show me way around? need text 10 cpi, not 10.3 cpi experienced :-(

"10 cpi" meaningful in previous century when dot-matrix printers still dominant. fell victim typographer's insistence on getting perfect letter shapes, very picky that. graphics class not keep secret, when use graphics.measurestring() on string you'll see 7.164388 inches wide, not 7.0 hoped.

the typographer's preferences powered scalable outline font support , laser printers 600 dpi resolution. take advantage of that, font size floating point value, not integer. graphics.scaletransform() works too. should prefer, printer engines still subject mechanical tolerances ought keep config parameter around user can tweak pixel-perfect.

quick fix:

    new font("courier new", 11.72465f), 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -