Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are re-discovering a well-known problem with Graphics.DrawString(), it is not <em>accurate</em>. The most graphic demonstration of this problem is this sample Winforms form:</p> <pre><code>public partial class Form1 : Form { public Form1() { InitializeComponent(); } protected override void OnPaint(PaintEventArgs e) { e.Graphics.DrawString("Hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", this.Font, Brushes.Black, 0, 0); } } </code></pre> <p>Which looks like this:</p> <p><img src="https://i.stack.imgur.com/Dk0SF.png" alt="enter image description here"></p> <p>No amount of magic is ever going to get you overlap on the part of the string where the spacing between the letters i suddenly changes. GDI+ was Microsoft's first attempt at resolution independent text rendering and it didn't work out well. It is in good company, WPF was the second attempt and it got a lot of flak for fuzzy output. Solved in a way that was similar to the way it got fixed in .NET 2.0 for Winforms, you should always render text to a window with TextRenderer.DrawText(). Which makes no attempt to make rendered text scale smoothly, it always prefers fitting to the pixel grid. Same thing with WPF's <em>ideal</em> vs <em>display</em> rendering modes, <a href="http://blogs.msdn.com/b/text/archive/2009/08/24/wpf-4-0-text-stack-improvements.aspx" rel="nofollow noreferrer">added in .NET 4</a>.</p> <p>There are significant other problems with your approach, the way the text is rendered is significantly unsuitable for a printer. You can see that when you zoom in you can see the pixels, SysInternals' ZoomIt utility is good for that. I zoomed in on the letter a in your right-hand side graphic:</p> <p><img src="https://i.stack.imgur.com/ToiIO.png" alt="enter image description here"></p> <p>Note the reddish and bluish pixels at the fringe of the letter shape. This is an anti-aliasing technique called <a href="http://en.wikipedia.org/wiki/Cleartype" rel="nofollow noreferrer">ClearType</a>, it enhances the perceived resolution of LCD monitors. It only works well on LCD panels, it does <strong>not</strong> work on a printer which doesn't have the same stripe pattern. On paper, the letter will just look fuzzy with a colored fringe. Albeit that it is not quite as bad on a Zebra printer since it doesn't supporting printing in color.</p> <p>These are artifacts that are specific to rendering text to a monitor, devices that have a rather poor resolution. Pixel grid fitting and ClearType are tricks to make the text look decent. Typical monitors have no more than about 120 pixels per inch. Albeit that this is finally improving with Apple's push for "retina" displays. A company that has a stake in high resolution monitors, they traditionally rendered text <a href="http://www.codinghorror.com/blog/2007/06/whats-wrong-with-apples-font-rendering.html" rel="nofollow noreferrer">in "ideal" mode</a>.</p> <p>These rendering tricks are <em>completely</em> inappropriate for a printer, a device that has much higher resolution. 600 pixels per inch is typical, easily 5 times better than a monitor. By drawing a picturebox to the printer you are in effect <strong>wasting</strong> the improvements you'll get when drawing directly to the printer. They difference is very significant and easy to see with the unaided eye. Text looks much more beautiful and crisp when you render text at 600 dpi. Text that was originally rendered for 120 dpi and enlarged for a printer looks "blobby" and crude.</p> <p>Always use the PrintDocument class to draw to the printer.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload