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
Post Reply
pablobhz
Posts: 76
Joined: 2016-05-07T06:47:14-07:00
Authentication code: 1151

Draw text into center(TextAlignment)

Post by pablobhz » 2019-11-08T05:49:28-07:00

Hello.
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 !

Post Reply