DCSIMG
GDI vs GDI+ text rendering and measuring - IHateSpaghetti {code}

IHateSpaghetti {code}

VSX, DSL and Beyond by Eyal Lantzman

Syndication

Coding / Architecture

Extensibility /DSL

Projects

Articles

GDI vs GDI+ text rendering and measuring

I was investigate a GDI/GDI+ related bug the other day and I found out that GDI+ doesn’t render RTL text very well. In order to render it correctly you need to render it using GDI.

GDI+ Text rendering

This is done by Graphics.DrawString(…) / Graphics.MeasureString(..)

GDI Text rendering

This is done by TextRenderer.DrawText(..) / TextRenderer.MeasureText(…)

The interesting thing about GDI text measuring is that it sometimes the measured size might be larger than the maximum size so be aware of that!

Another point is to be aware of the GraphicsUnit in the Graphic.PageUnit instance vs. Font.Unit if one in pixels and the other is inches than it’s like comparing melons to oranges.

Test application

I've created this test application that might help you to see the differences between the two rendering technologies.

 Additional resources
Published Thursday, March 19, 2009 11:07 AM by Eyal

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: