Added support for font name of no charset specified case bug 38890, also changed to use pixel instead point for font size.

This commit is contained in:
nhotta%netscape.com 2000-05-12 20:35:29 +00:00
Родитель f2f98584c5
Коммит 0890f778e3
5 изменённых файлов: 12 добавлений и 19 удалений

Просмотреть файл

@ -1778,14 +1778,13 @@ ResetChannelCharset(MimeObject *obj)
////////////////////////////////////////////////////////////
nsresult GetMailNewsFont(MimeObject *obj, PRBool styleFixed, char *fontName, PRUint32 nameBuffSize, PRInt32 *fontSize)
nsresult GetMailNewsFont(MimeObject *obj, PRBool styleFixed, char *fontName, PRUint32 nameBuffSize, PRInt32 *fontPixelSize)
{
nsresult rv = NS_OK;
nsIPref *aPrefs = GetPrefServiceManager(obj->options);
if (aPrefs) {
MimeInlineText *text = (MimeInlineText *) obj;
PRInt32 screenRes;
nsCAutoString aCharset;
PRUnichar *unicode = nsnull;
nsCAutoString convertedStr;
@ -1793,13 +1792,9 @@ nsresult GetMailNewsFont(MimeObject *obj, PRBool styleFixed, char *fontName, PRU
// get a charset
if (!text->charset || !(*text->charset))
return NS_ERROR_FAILURE;
aCharset.Assign(text->charset);
// get a screen resolution
rv = aPrefs->GetIntPref("browser.screen_resolution", &screenRes);
if (NS_FAILED(rv))
return rv;
aCharset.Assign("us-ascii");
else
aCharset.Assign(text->charset);
// get variable font type
char* variable_font_type = nsnull;
@ -1867,11 +1862,10 @@ nsresult GetMailNewsFont(MimeObject *obj, PRBool styleFixed, char *fontName, PRU
// get a font size from pref
aPrefStr.Assign(!styleFixed ? "font.size.variable." : "font.size.fixed.");
aPrefStr.AppendWithConversion(langGroup);
rv = aPrefs->GetIntPref(aPrefStr, fontSize);
rv = aPrefs->GetIntPref(aPrefStr, fontPixelSize);
if (NS_FAILED(rv))
return rv;
*fontSize = *fontSize * 72 / screenRes;
}
// otherwise, use the mailnews font setting from pref
else {
@ -1893,11 +1887,10 @@ nsresult GetMailNewsFont(MimeObject *obj, PRBool styleFixed, char *fontName, PRU
PL_strcpy(fontName, convertedStr.GetBuffer());
// get a font size from pref
rv = aPrefs->GetIntPref(!styleFixed ? "mailnews.font.size.html" : "mailnews.font.size.plain", fontSize);
rv = aPrefs->GetIntPref(!styleFixed ? "mailnews.font.size.html" : "mailnews.font.size.plain", fontPixelSize);
if (NS_FAILED(rv))
return rv;
*fontSize = *fontSize * 72 / screenRes;
}
}

Просмотреть файл

@ -162,7 +162,7 @@ extern "C" char *MimeGetStringByID(PRInt32 stringID);
// Utility to create a nsIURI object...
extern "C" nsresult nsMimeNewURI(nsIURI** aInstancePtrResult, const char *aSpec, nsIURI *aBase);
extern "C" nsresult GetMailNewsFont(MimeObject *obj, PRBool styleFixed, char *fontName, PRUint32 nameBuffSize, PRInt32 *fontSize);
extern "C" nsresult GetMailNewsFont(MimeObject *obj, PRBool styleFixed, char *fontName, PRUint32 nameBuffSize, PRInt32 *fontPixelSize);
#ifdef __cplusplus
}

Просмотреть файл

@ -65,7 +65,7 @@ MimeInlineTextHTML_parse_begin (MimeObject *obj)
PRInt32 fontSize; // default font size
if (NS_SUCCEEDED(GetMailNewsFont(obj, PR_FALSE, fontName, 128, &fontSize)))
{
PR_snprintf(buf, 256, "<div style=\"font-family: %s; font-size: %dpt;\">", (const char *) fontName, fontSize);
PR_snprintf(buf, 256, "<div style=\"font-family: %s; font-size: %dpx;\">", (const char *) fontName, fontSize);
status = MimeObject_write(obj, buf, nsCRT::strlen(buf), PR_FALSE);
}
else

Просмотреть файл

@ -104,7 +104,7 @@ MimeInlineTextPlainFlowed_parse_begin (MimeObject *obj)
if (exdata->fixedwidthfont) {
rv = GetMailNewsFont(obj, PR_TRUE, fontName, 128, &fontSize);
if (NS_SUCCEEDED(rv)) {
PR_snprintf(buf, 256, "<tt style=\"font-family: %s; font-size: %dpt;\">", (const char *) fontName, fontSize);
PR_snprintf(buf, 256, "<tt style=\"font-family: %s; font-size: %dpx;\">", (const char *) fontName, fontSize);
status = MimeObject_write(obj, buf, nsCRT::strlen(buf), PR_FALSE);
}
else
@ -113,7 +113,7 @@ MimeInlineTextPlainFlowed_parse_begin (MimeObject *obj)
else {
rv = GetMailNewsFont(obj, PR_FALSE, fontName, 128, &fontSize);
if (NS_SUCCEEDED(rv)) {
PR_snprintf(buf, 256, "<div style=\"font-family: %s; font-size: %dpt;\">", (const char *) fontName, fontSize);
PR_snprintf(buf, 256, "<div style=\"font-family: %s; font-size: %dpx;\">", (const char *) fontName, fontSize);
status = MimeObject_write(obj, buf, nsCRT::strlen(buf), PR_FALSE);
}
else

Просмотреть файл

@ -158,11 +158,11 @@ MimeInlineTextPlain_parse_begin (MimeObject *obj)
// For quoting, keep it simple...
if ( (obj->options->format_out == nsMimeOutput::nsMimeMessageQuoting) ||
(obj->options->format_out == nsMimeOutput::nsMimeMessageBodyQuoting) )
PR_snprintf(buf, 256, "<pre %s style=\"font-family: %s; font-size: %dpt;\">",
PR_snprintf(buf, 256, "<pre %s style=\"font-family: %s; font-size: %dpx;\">",
obj->options->wrap_long_lines_p ? "wrap" : "",
(const char *) fontName, fontSize);
else
PR_snprintf(buf, 256, "<pre %s style=\"font-family: %s; font-size: %dpt;\">",
PR_snprintf(buf, 256, "<pre %s style=\"font-family: %s; font-size: %dpx;\">",
obj->options->wrap_long_lines_p ? "wrap" : "",
(const char *) fontName, fontSize);
}