Gravity (for pango) in Magick++

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

Gravity (for pango) in Magick++

Post by olear »

Hi, been using Pango Markup for a while, works great, but I need some form of text align, I see in the code for pango.c (https://github.com/ImageMagick/ImageMag ... ngo.c#L304) that you take align info from DrawInfo, but I can't find any option in Magick++ to set this.

What are my options for align and gravity using Pango?
Last edited by olear on 2015-10-22T00:41:18-07:00, edited 1 time in total.
olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

Re: Set text/draw align (for pango) in Magick++

Post by olear »

Using convert I can just do: convert -gravity Center pango:"whatever", how can I reproduce gravity before read in Magick++?
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Gravity (for pango) in Magick++

Post by dlemstra »

At this moment you cannot do that in Magick++. We will have to figure out how we want to make this available in Magick++. I will get back to this topic when we have decided how to do this.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

Re: Gravity (for pango) in Magick++

Post by olear »

Thanks for the info.

EDIT: a pango align define would be good enough for me.
olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

Re: Gravity (for pango) in Magick++

Post by olear »

Added this as a tmp/quick fix for myself:

Code: Select all

--- coders/pango.c.orig	2015-10-27 19:45:50.079263256 +0100
+++ coders/pango.c	2015-10-27 19:46:33.672399568 +0100
@@ -320,6 +320,17 @@
   if ((align != PANGO_ALIGN_CENTER) &&
       (draw_info->direction == RightToLeftDirection))
     align=(PangoAlignment) (PANGO_ALIGN_LEFT+PANGO_ALIGN_RIGHT-align);
+  // start hack for TextPango.ofx
+  option=GetImageOption(image_info,"pango:align");
+  if (option != (const char *) NULL) {
+    if (LocaleCompare(option,"center") == 0)
+      align=PANGO_ALIGN_CENTER;
+    if (LocaleCompare(option,"left") == 0)
+      align=PANGO_ALIGN_LEFT;
+    if (LocaleCompare(option,"right") == 0)
+      align=PANGO_ALIGN_RIGHT;
+  }
+  // end hack
   pango_layout_set_alignment(layout,align);
   if (draw_info->font == (char *) NULL)
     description=pango_font_description_new();
Post Reply