# HG changeset patch # User Elliott Sales de Andrade # Date 1229306030 0 # Node ID 773662f77be786901fcdb53f8d995f08ed6134cc # Parent e88d205cb4da4c90eafd2c662d6d5bac82136c00# Parent e268ad14e693b6eafe2941f4dfd40f115bc0a481 merge of '16c1dbfe5a0090d97df6477c7f8235365d07090c' and 'dbad9300b40f03937a5bed27529b9c1445d02322' diff -r e88d205cb4da -r 773662f77be7 libpurple/protocols/myspace/markup.c --- a/libpurple/protocols/myspace/markup.c Mon Dec 15 01:52:02 2008 +0000 +++ b/libpurple/protocols/myspace/markup.c Mon Dec 15 01:53:50 2008 +0000 @@ -192,35 +192,38 @@ height_str = xmlnode_get_attrib(root, "h"); decor_str = xmlnode_get_attrib(root, "s"); - if (height_str) { - height = atol(height_str); + /* Validate the font face, to avoid constructing invalid HTML later */ + if (strchr(face, '\'') != NULL) + face = NULL; + + height = height_str != NULL ? atol(height_str) : 12; + decor = decor_str != NULL ? atol(decor_str) : 0; + + /* + * The HTML we're constructing here is a bit redudant. Ideally we + * would use only the font-family and font-size CSS span, but Pidgin + * doesn't support it (it's included for other UIs). For Pidgin we + * wrap the whole thing in an ugly font tag, and Pidgin will happily + * ignore the . + */ + gs_begin = g_string_new(""); + if (height && !face) { + guint point_size = msim_height_to_point(session, height); + g_string_printf(gs_begin, + "", + msim_point_to_purple_size(session, point_size), + point_size); + } else if (height && face) { + guint point_size = msim_height_to_point(session, height); + g_string_printf(gs_begin, + "", + face, msim_point_to_purple_size(session, point_size), + face, point_size); } else { - height = 12; - } - - if (decor_str) { - decor = atol(decor_str); - } else { - decor = 0; + g_string_printf(gs_begin, ""); } - gs_begin = g_string_new(""); - /* TODO: get font size working */ - if (height && !face) { - g_string_printf(gs_begin, "", - msim_point_to_purple_size(session, msim_height_to_point(session, height))); - } else if (height && face) { - g_string_printf(gs_begin, "", face, - msim_point_to_purple_size(session, msim_height_to_point(session, height))); - } else { - g_string_printf(gs_begin, ""); - } - - /* No support for font-size CSS? */ - /* g_string_printf(gs_begin, "", face, - msim_height_to_point(height)); */ - - gs_end = g_string_new(""); + gs_end = g_string_new(""); if (decor & MSIM_TEXT_BOLD) { g_string_append(gs_begin, ""); @@ -237,7 +240,6 @@ g_string_append(gs_end, ""); } - *begin = g_string_free(gs_begin, FALSE); *end = g_string_free(gs_end, FALSE); } diff -r e88d205cb4da -r 773662f77be7 pidgin/gtkimhtml.c --- a/pidgin/gtkimhtml.c Mon Dec 15 01:52:02 2008 +0000 +++ b/pidgin/gtkimhtml.c Mon Dec 15 01:53:50 2008 +0000 @@ -3126,9 +3126,15 @@ font->size = 6; else if (g_ascii_strcasecmp(size, "xx-large") == 0) font->size = 7; - else - font->size = 3; - gtk_imhtml_font_set_size(imhtml, font->size); + + /* + * TODO: Handle other values, like percentages, or + * lengths specified as em, ex, px, in, cm, mm, pt + * or pc. Or even better, use an actual HTML + * renderer like webkit. + */ + if (font->size > 0) + gtk_imhtml_font_set_size(imhtml, font->size); } else if (oldfont) {