TextRenderer.DrawText vs Graphics.DrawString

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all,
I have a WYSIWYG editor which uses Graphics.DrawString to render it's
text. The Font size is scaled based on the sized of the form and everything
looks the same, no matter how you resize the form (i.e consitent word
wrapping).

I tried switching to TextRenderer.DrawText and cannot get consistent results
: when resizing the form, word wrapping is inconsistent : sometimes a word is
at the end of a line and sometimes the word wrap to the next line.

I used the TextFormatFlagsUtil (see MSDN Mag, March 2006) to match the flags
I'm using with DrawString --> DrawText.

Any idea / reason why I can't have consistent results ??

thank you
 
Hi plumeprog,

Well, TextRenderer uses GDI while Graphics.DrawString uses GDI+ to render strings. Unfortunately I don't know the exact reason for
the behavior you have witnessed so I assume it is this fundamental difference between the tools that is causing inconsistent text
wrapping.

AFAIK it doesn't really matter which method you choose, so choose the one that works for you.
 
Back
Top