Mercurial > pidgin
changeset 24739:773662f77be7
merge of '16c1dbfe5a0090d97df6477c7f8235365d07090c'
and 'dbad9300b40f03937a5bed27529b9c1445d02322'
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Mon, 15 Dec 2008 01:53:50 +0000 |
parents | e88d205cb4da (current diff) e268ad14e693 (diff) |
children | 7b6037f09baf ba8a5fded83c ca01403251f1 |
files | |
diffstat | 2 files changed, 38 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- 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 <span>. + */ + gs_begin = g_string_new(""); + if (height && !face) { + guint point_size = msim_height_to_point(session, height); + g_string_printf(gs_begin, + "<font size='%d'><span style='font-size: %dpt'>", + 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, + "<font face='%s' size='%d'><span style='font-family: %s; font-size: %dpt'>", + 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, "<font><span>"); } - gs_begin = g_string_new(""); - /* TODO: get font size working */ - if (height && !face) { - g_string_printf(gs_begin, "<font size='%d'>", - msim_point_to_purple_size(session, msim_height_to_point(session, height))); - } else if (height && face) { - g_string_printf(gs_begin, "<font face='%s' size='%d'>", face, - msim_point_to_purple_size(session, msim_height_to_point(session, height))); - } else { - g_string_printf(gs_begin, "<font>"); - } - - /* No support for font-size CSS? */ - /* g_string_printf(gs_begin, "<span style='font-family: %s; font-size: %dpt'>", face, - msim_height_to_point(height)); */ - - gs_end = g_string_new("</font>"); + gs_end = g_string_new("</span></font>"); if (decor & MSIM_TEXT_BOLD) { g_string_append(gs_begin, "<b>"); @@ -237,7 +240,6 @@ g_string_append(gs_end, "</u>"); } - *begin = g_string_free(gs_begin, FALSE); *end = g_string_free(gs_end, FALSE); }
--- 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) {