GDI+ DrawString works incorrectly?

cpp Ukraine
  • 12 years ago
    Graphics g(...);
    g.DrawString("ffffffffffffffffffffffffff", ...);

    And the result looks like this: "fffffffffffff f f f f f"

    about a half of this string is drawn normaly but another part is drawn with other interval between characters.
    Has anyone ever faced with this? any solution?
  • 12 years ago

    Not sure why this happens, but try with less 'f' characters until it doesn't happen...

    Or, use a char buffer and store the string there and pass that as the parameter.

  • 12 years ago
    Whether the string is passed through any buffer as a parameter or not - it doesn't metter. If i draw a string "fffffff..." or "jjjjjj..." with a length less then 30 chars it's allright, if more - than i get the string drawn with verious distance between chars. And everything that takes place only when certain fonts are used "Arial, Verdana, ..." for "Times, Courier,.." - it's ok.
    I found one way to fix that : Set TextRenderingHintAntiAlias and everything seems working fine but the string is drawn very smoothed.

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” - Martin Fowler