gimp r26580 - in trunk: . app/text



Author: danedde
Date: Fri Aug 15 19:31:09 2008
New Revision: 26580
URL: http://svn.gnome.org/viewvc/gimp?rev=26580&view=rev

Log:
2008-08-15  Daniel Eddeland  <danedde svn gnome org>

	* app/text/gimptextlayout-render.c: make text align correctly if
	text-box is FIXED.



Modified:
   trunk/ChangeLog
   trunk/app/text/gimptextlayout-render.c

Modified: trunk/app/text/gimptextlayout-render.c
==============================================================================
--- trunk/app/text/gimptextlayout-render.c	(original)
+++ trunk/app/text/gimptextlayout-render.c	Fri Aug 15 19:31:09 2008
@@ -73,6 +73,7 @@
                          gpointer            render_data)
 {
   PangoLayoutIter *iter;
+  PangoRectangle   rect;
   gint             x, y;
 
   g_return_if_fail (GIMP_IS_TEXT_LAYOUT (layout));
@@ -83,11 +84,26 @@
   x *= PANGO_SCALE;
   y *= PANGO_SCALE;
 
+  pango_layout_get_extents (layout->layout, NULL, &rect);
+
+  /* If the width of the layout is > 0, then the text-box is FIXED
+   * and the layout position should be offset if the alignment
+   * is centered or right-aligned*/
+  if (pango_layout_get_width (layout->layout) > 0)
+    switch (pango_layout_get_alignment (layout->layout))
+      {
+      case PANGO_ALIGN_RIGHT:
+        x += pango_layout_get_width (layout->layout) - rect.width;
+        break;
+      case PANGO_ALIGN_CENTER:
+        x += (pango_layout_get_width (layout->layout) - rect.width) / 2;
+        break;
+      }
+
   iter = pango_layout_get_iter (layout->layout);
 
   do
     {
-      PangoRectangle   rect;
       PangoLayoutLine *line;
       gint             baseline;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]