gimp r25012 - in branches/weskaggs: . app/text



Author: weskaggs
Date: Mon Mar  3 22:27:38 2008
New Revision: 25012
URL: http://svn.gnome.org/viewvc/gimp?rev=25012&view=rev

Log:
Bill Skaggs  <weskaggs primate ucdavis edu>

	* text/gimptextlayout.c
	* text/gimptext-compat.c: Hack in some very basic
	markup-rendering capability.


Modified:
   branches/weskaggs/ChangeLog
   branches/weskaggs/app/text/gimptext-compat.c
   branches/weskaggs/app/text/gimptextlayout.c

Modified: branches/weskaggs/app/text/gimptext-compat.c
==============================================================================
--- branches/weskaggs/app/text/gimptext-compat.c	(original)
+++ branches/weskaggs/app/text/gimptext-compat.c	Mon Mar  3 22:27:38 2008
@@ -144,6 +144,7 @@
   PangoLayout          *layout;
   PangoFontMap         *fontmap;
   PangoRectangle        rect;
+  GError               *error  = NULL;
 
   g_return_val_if_fail (fontname != NULL, FALSE);
   g_return_val_if_fail (text != NULL, FALSE);
@@ -161,7 +162,16 @@
   pango_layout_set_font_description (layout, font_desc);
   pango_font_description_free (font_desc);
 
-  pango_layout_set_text (layout, text, -1);
+  /*
+   * we want to treat the text as markup if possible, but
+   * first we have to check that it can be parsed.  If not,
+   * we treat it as plain text.
+  */
+  pango_parse_markup (text, -1, 0, NULL, NULL, NULL, &error);
+  if (error)
+    pango_layout_set_text (layout, text, -1);
+  else
+    pango_layout_set_markup (layout, text, -1);
 
   pango_layout_get_pixel_extents (layout, NULL, &rect);
 

Modified: branches/weskaggs/app/text/gimptextlayout.c
==============================================================================
--- branches/weskaggs/app/text/gimptextlayout.c	(original)
+++ branches/weskaggs/app/text/gimptextlayout.c	Mon Mar  3 22:27:38 2008
@@ -133,11 +133,29 @@
   pango_layout_set_font_description (layout->layout, font_desc);
   pango_font_description_free (font_desc);
 
+  /* FIXME */
   if (text->text)
-    pango_layout_set_text (layout->layout, text->text, -1);
+    {
+      GError *error       = NULL;
+      gchar  *markup_text = text->text;
+
+      pango_parse_markup (markup_text, -1, 0, NULL,
+                          NULL, NULL, &error);
+
+      if (error)
+        {
+          pango_layout_set_text (layout->layout, markup_text, -1);
+          g_print ("markup parse error: %s", error->message);
+        }
+      else
+        pango_layout_set_markup (layout->layout, markup_text, -1);
+    }
   else
     pango_layout_set_text (layout->layout, NULL, 0);
 
+/*   if (text->attr_list) */
+/*     pango_layout_set_attributes (layout->layout, text->attr_list); */
+
   switch (text->justify)
     {
     case GIMP_TEXT_JUSTIFY_LEFT:
@@ -150,9 +168,6 @@
       alignment = PANGO_ALIGN_CENTER;
       break;
     case GIMP_TEXT_JUSTIFY_FILL:
-      /* FIXME: This doesn't work since the implementation is missing
-         at the Pango level.
-       */
       alignment = PANGO_ALIGN_LEFT;
       pango_layout_set_justify (layout->layout, TRUE);
       break;



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