   [.net] Making GDI Resolution-Independent. -ish.
  Woo! I found the answer to my problem in this post(see quoted section at bottom), only to have a related question pop up. Seems it was the PrintDocument's resolution that was causing havoc with the GDI based TextRenderer. So, my question now is how to juggle the numbers so the resolution for GDI is the same as it 'appears' to GDI+.Thanks in advance![Edit] Or actually, just an algorithm to convert pixels to em/points would do nicely.Quote:Old Title: [GDI] PrintDocument and TextRendererRight, so I'm trying to support printing on my code editor control, and (System.Drawing.Printing.)PrintDocument looks like it'll be the way for this since you get passed a Graphics and can just draw away on it, so anything that could be drawn on the screen for the control could also be printed out on paper. Or so I thought...Yes, I realize that printing out code isn't something that'll likely happen a lot, but it was required in all my coding classes at uni, so whatever.Unfortunately, however, it would seem that PrintDocument favours GDI+, but frowns upon GDI. Drawing text using Graphics.DrawString works the way it should. Drawing text using TextRenderer.DrawText, passing the same(or equivalent) arguments prints the text all teeny-tiny, as if it is ignoring the font size. I attempted to draw the text on a Bitmap via its Graphics(pretty much along the lines of Graphics.FromImage(new Bitmap(width,height));) with TextRenderer, and it /still/ prints small(although a different(fuzzier?), but not what I'm wanting).I kinda have to use TextRenderer instead of Graphics' DrawString/MeasureString since I'll be using TextRenderer.MeasureText to determine where lines should wrap around or stop when it has reached the bottom of the page, and Graphics.MeasureString can be way off on this stuff.Oh, and the reason I tagged the title with "[GDI]" is because on trying to find the problem/solution throught Google, it kept giving me results containing "PrintDocument" and "GDI+"(not clever enough to find some way for Google to only give me "GDI" and not "GDI+"), and I know that TextRenderer is GDI based, so I figured that might be related to the problem.That and I like to send a chill down people's back.[lol]Thanks in advance for any comments/help.[Edited by - nerd_boy on June 27, 2009 10:11:26 AM]
  This should put you on the right trackhttp://msdn.microsoft.com/en-us/library/system.drawing.graphicsunit.aspx