How to generate images with formatted text

Jun 3, 2013 at 12:49 PM
Edited Jun 3, 2013 at 12:50 PM
Dim img As ImageMagick.MagickImage = New MagickImage(path)
img.Draw(New DrawableFont("Comic Sans MS", FontStyleType.Italic, FontWeight.Weight400, FontStretch.Normal))
img.Draw(New DrawableFillColor(New MagickColor(10, 10, 10)))
img.Draw(New DrawableText(50, 15, "Shafi"))
img.Write(outputFilename)

The code above is generating image, but text is drawing as plain text only, the DrawableFont and DrawableFillColor is not at all reflecting.

Can someone help me out, I want to generate formatted text based Images.
Coordinator
Jun 3, 2013 at 9:46 PM
Edited Jun 3, 2013 at 9:52 PM
If you want to do multiple draw operations you should use the overload of Draw that accepts an IEnumerable<DrawableBase>. Below is an example in C#.
using (MagickImage img = new MagickImage(path))
{
    List<DrawableBase> drawables = new List<DrawableBase>();
    drawables.Add(new DrawableFont("Comic Sans Is Evil", FontStyleType.Italic, FontWeight.Weight400, FontStretch.Normal));
    drawables.Add(new DrawableFillColor(new MagickColor(10, 10, 10)));
    drawables.Add(new DrawableText(50, 15, "Shafi"));
    img.Draw(drawables);
}
Jun 4, 2013 at 6:38 AM
Hi dlemstra,

Thanks for your quick reply. Your reply helped me greatly. Thanks again for your support.

By the way - you puzzled me by referring the font "Comic Sans" as Evil. :)