A major weakness in GDI+ is text handling. The GDI+ “undocumentation” in MSDN has been the primary source of my grievances.
About the only good features in GDI+’s text support are device independence and floating-point coordinates. Vanilla GDI includes more API calls, performs much faster and enables complex scripts. GDI use different, incompatible layout algorithms from GDI+, so that text drawn in GDI also looks different from it GDI+ counterpart. .NET 2.0 includes a new class System.Windows.Forms.TextRenderer for rendering consistent-looking text in system controls.
The text drawing functions in GDI+ are limited in number and require a string copy for each call, making it difficult to create a performant text-layout engine. The standard method MeasureCharacterRanges allocates a number of heavy objects; this is quite expensive for operation that is likely to be called frequently. There are a few ways out by using MeasureString such as pinvoking to gdiplus.dll, writing unsafe code, or using reflection to obtain the private backing string of a StringBuilder. In the latter case, if the string is sufficiently large, it effectively becomes a mutable string which can be manipulated through the StringBuilder’s methods; this avoids a lot of copying when measuring text; however, this approach may break in future versions of the framework.
The default settings for GDI+ are unsuitable for advanced text layout. The casual user will discover that MeasureText does not actually measure text correctly. One must always use a string format derived from StringFormat.GenericTypographic and turn on anti-aliasing text rendering. The only source of this information use to be this KnowledgeBase article.
Wait until you try getting performance out of WPF Text.
Posted by: Mooseblaster | June 13, 2006 at 12:00 AM
This reminds me of a document I read which states that text in Avalon are rendered as collections of triangles sent to GPU.
Posted by: Wesner Moise | June 14, 2006 at 11:57 PM
What?! Text in WPF are rendered as triangles from the GPU? That would be 2d triangles, right? (I would hope!)
Posted by: Judah | June 15, 2006 at 09:33 AM