# HG changeset patch # User Mark Doliner # Date 1229303819 0 # Node ID e268ad14e693b6eafe2941f4dfd40f115bc0a481 # Parent dce57ce0b86008ce77d8f58c345468af51be727f Change MySpace to wrap incoming messages in instead of just . The latter tag is suboptimal for two reasons: 1. It's deprecated 2. With MySpace the incoming messages are formatted with pt (well, basically). If we convert to the value then we lose a little bit of precision when we actually display it. This should have no effect on Pidgin--it will use the outter tag and happily ignore the font-size css property. But this change will benefit other UIs with more capable rendering widgets (Meebo, specifically, but I imagine this will help Adium, too). Basically it should just make the font sizes of incoming MySpace messages more accurate diff -r dce57ce0b860 -r e268ad14e693 libpurple/protocols/myspace/markup.c --- a/libpurple/protocols/myspace/markup.c Mon Dec 15 01:13:17 2008 +0000 +++ b/libpurple/protocols/myspace/markup.c Mon Dec 15 01:16:59 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); }