MeasureString() pads the text on the left and the right

后端 未结 5 835
野趣味
野趣味 2021-01-04 01:54

I\'m using GDI+ in C++. (This issue might exist in C# too).

I notice that whenever I call Graphics::MeasureString() or Graphics::DrawString(), the string is padded

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-04 02:02

    TextRenderer was great for getting the size of the font. But in the drawing loop, using TextRenderer.DrawText was excruciatingly slow compared to graphics.DrawString().

    Since the width of a string is the problem, your much better off using a combination of TextRenderer.MeasureText and graphics.DrawString..

提交回复
热议问题