Bill Skaggs <weskaggs@primate.ucdavis.edu>

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

svn path=/branches/weskaggs/; revision=25012
This commit is contained in:
William Skaggs 2008-03-03 22:27:38 +00:00
parent 5f790005a5
commit 040b319e45
3 changed files with 36 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2008-03-03 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* text/gimptextlayout.c
* text/gimptext-compat.c: Hack in some very basic
markup-rendering capability.
2008-03-03 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* menus/image-menu.xml.in: Simplify menu by moving some

View File

@ -144,6 +144,7 @@ text_get_extents (const gchar *fontname,
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 @@ text_get_extents (const gchar *fontname,
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);

View File

@ -133,11 +133,29 @@ gimp_text_layout_new (GimpText *text,
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 @@ gimp_text_layout_new (GimpText *text,
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;