Page 1 of 1

Gravity (for pango) in Magick++

Posted: 2015-10-12T10:44:29-07:00
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?

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

Posted: 2015-10-22T00:40:31-07:00
by olear
Using convert I can just do: convert -gravity Center pango:"whatever", how can I reproduce gravity before read in Magick++?

Re: Gravity (for pango) in Magick++

Posted: 2015-10-22T02:07:50-07:00
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.

Re: Gravity (for pango) in Magick++

Posted: 2015-10-22T02:47:24-07:00
by olear
Thanks for the info.

EDIT: a pango align define would be good enough for me.

Re: Gravity (for pango) in Magick++

Posted: 2015-10-27T12:20:47-07:00
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();