Search code examples
c#wpfgdi+gditext-rendering

Draw Anti-Aliased Text Image like Graphics Software


I would like to generate text images like the following (source: http://www.zune.net/en-US):

nice font rendering

The text has a nice thickness and is perfectly anti-aliased. Vector graphics software – such as Inkscape – produces the same result. However, the images I managed to create using GDI+ look like this:

enter image description here

These rendered text is too thin although the font family, size, weight etc. are identical. How can I increase the thickness of the text? Does WPF provide functionality to render the text as described above?


[Update] I created the following images using TextRenderer.DrawText(). The first one uses TextRenderingHint.ClearTypeGridFit, the second one TextRenderingHint.AntiAlias:

TextRenderingHint.ClearTypeGridFit

TextRenderingHint.AntiAlias


Solution

  • I managed to create nice-looking text images by rendering a WPF User Control containing a TextBlock inside a Canvas to a RenderTargetBitmap that – using a PngBitmapEncoder – is saved to a MemoryStream and turned to an image using Image.FromStream(Stream).