PR_snprintf(buf, 256, "<div style=\"font-family: %s; font-size: %dpt;\">\n", (const char *) fontName, fontSize);
if (bTEXT_HTML) PR_snprintf(buf, 256, "<div style=\"font-family: %s; font-size: %dpt;\">", (const char *) fontName, fontSize); else PR_snprintf(buf, 256, "<pre style=\"font-family: %s; font-size: %dpt;\">", (const char *) fontName, fontSize);
int BeginMailNewsFont(MimeObject *obj){  nsIPref *aPrefs = GetPrefServiceManager(obj->options);  int status = -1;  nsresult rv;  if (aPrefs) {    // check Content-Type:    PRBool bTEXT_HTML = PR_FALSE;    if (!nsCRT::strcasecmp(obj->content_type, TEXT_HTML))      bTEXT_HTML = PR_TRUE;    else if (nsCRT::strcasecmp(obj->content_type, TEXT_PLAIN))      goto done;  // not supported type    // if indicated by the pref, do language sensitive font selection (slower)    PRBool  languageSensitiveFont = PR_FALSE;    rv = aPrefs->GetBoolPref("mailnews.language_sensitive_font", &languageSensitiveFont);    if (NS_SUCCEEDED(rv) && languageSensitiveFont)      return bTEXT_HTML ?                DoLanguageSensitiveFont(obj, "font.name.serif.", "font.size.variable.") :                DoLanguageSensitiveFont(obj, "font.name.monospace.", "font.size.fixed.");    // otherwise, use the mailnews font setting from pref    MimeInlineText  *text = (MimeInlineText *) obj;    nsString aCharset;    PRUnichar *unicode = nsnull;    nsCAutoString fontName;    PRInt32 fontSize;    PRInt32 screenRes;    if (!text->charset || !(*text->charset))      goto done;    aCharset.AssignWithConversion(text->charset);    // get a font name from pref, could be non ascii (need charset conversion)    // this is not necessary if we insert this tag after the message is converted to UTF-8    rv = aPrefs->CopyUnicharPref(bTEXT_HTML ? "mailnews.font.name.html" : "mailnews.font.name.plain", &unicode);    if (NS_FAILED(rv))      goto done;    nsAutoString tempStr(unicode);    PR_FREEIF(unicode);    nsCAutoString charsetCStr;    charsetCStr.AssignWithConversion(aCharset);    rv = nsMsgI18NConvertFromUnicode(charsetCStr, tempStr, fontName);    if (NS_FAILED(rv))      goto done;    // get a font size from pref    rv = aPrefs->GetIntPref(bTEXT_HTML ? "mailnews.font.size.html" : "mailnews.font.size.plain", &fontSize);    if (NS_FAILED(rv))      goto done;    // get a screen resolution    rv = aPrefs->GetIntPref("browser.screen_resolution", &screenRes);    if (NS_FAILED(rv))      goto done;    fontSize = fontSize * 72 / screenRes;      char buf[256];    PR_snprintf(buf, 256, "<div style=\"font-family: %s; font-size: %dpt;\">\n", (const char *) fontName, fontSize);    status = MimeObject_write(obj, buf, nsCRT::strlen(buf), PR_FALSE);  }done:  // if nothing has been written then write out just "<div>" to match with "</div>"  if (status == -1)    status = MimeObject_write(obj, "<div>\n", 6, PR_FALSE);    return status;}