Draw text into center(TextAlignment)

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Posts: 76
Joined: 2016-05-07T06:47:14-07:00
Authentication code: 1151

Draw text into center(TextAlignment)

Post by pablobhz »

I'm trying to draw some text in the center of an image, however, it never goes to the center ; stays on the left always.
I would like to know what can i do. The only way i've found to center my text was using Gravity.Center and then calculating offset pixels. But since TextAlignment is there, i believe there might be an easier way.

Here's my code:

Code: Select all

var h1FontMagick = new Drawables().FontPointSize(14).Font("Tahoma", FontStyleType.Bold, FontWeight.Bold, FontStretch.Condensed);
h1FontMagick.Text(0 ,varAltura, "Documento Auxiliar da Nota Fiscal de Consumidor Eletrônica").TextAlignment(TextAlignment.Center).Draw(imgNota);
Also, is there any way to wrap text using Magick Drawable ?
Thanks !

User avatar
Posts: 1625
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789

Re: Draw text into center(TextAlignment)

Post by dlemstra »

What happens when you use the `Gravity` method of the `Drawables` class?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate