Bug 95227. Allow serif/sansserif defaults to be set per-language. Patch by Masayuki Nakano, r=dbaron,amadare,danm,smontagu,rbs,neil sr=roc

This commit is contained in:
roc+%cs.cmu.edu 2005-01-23 23:58:32 +00:00
Родитель 6ba3a1e41e
Коммит f1635b58a4
20 изменённых файлов: 242 добавлений и 167 удалений

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

@ -301,11 +301,11 @@ TranslatePropFont(unsigned char *aRegValue, DWORD aRegValueLength,
if (isSerif) {
prefs->SetCharPref("font.name.serif.x-western",
NS_REINTERPRET_CAST(char *, aRegValue));
prefs->SetCharPref("font.default", "serif");
prefs->SetCharPref("font.default.x-western", "serif");
} else {
prefs->SetCharPref("font.name.sans-serif.x-western",
NS_REINTERPRET_CAST(char *, aRegValue));
prefs->SetCharPref("font.default", "sans-serif");
prefs->SetCharPref("font.default.x-western", "sans-serif");
}
}

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

@ -49,7 +49,7 @@ catch(e)
var fontEnumerator = null;
var globalFonts = null;
var fontTypes = ["serif", "sans-serif", "monospace"];
var variableSize, fixedSize, minSize, languageList;
var defaultFont, variableSize, fixedSize, minSize, languageList;
var languageData = [];
var currentLanguage;
var gPrefutilitiesBundle;
@ -61,31 +61,26 @@ function GetFields()
var dataObject = { };
// store data for language independent widgets
var lists = ["selectLangs", "proportionalFont"];
for( var i = 0; i < lists.length; i++ )
{
if( !( "dataEls" in dataObject ) )
dataObject.dataEls = new Object;
dataObject.dataEls[ lists[i] ] = new Object;
dataObject.dataEls[ lists[i] ].value = document.getElementById( lists[i] ).value;
}
if( !( "dataEls" in dataObject ) )
dataObject.dataEls = new Object;
dataObject.dataEls[ "selectLangs" ] = new Object;
dataObject.dataEls[ "selectLangs" ].value = document.getElementById( "selectLangs" ).value;
dataObject.defaultFont = document.getElementById( "proportionalFont" ).value;
dataObject.fontDPI = document.getElementById( "screenResolution" ).value;
dataObject.useMyFonts = document.getElementById( "useMyFonts" ).checked ? 1 : 0;
dataObject.fontDPI = document.getElementById( "screenResolution" ).value;
dataObject.useMyFonts = document.getElementById( "useMyFonts" ).checked ? 1 : 0;
var items = ["foregroundText", "background", "unvisitedLinks", "visitedLinks", "browserUseSystemColors", "browserUnderlineAnchors", "useMyColors", "useMyFonts"];
for (i = 0; i < items.length; ++i)
dataObject.dataEls[items[i]] = new Object;
dataObject.dataEls["foregroundText"].value = document.getElementById("foregroundtextmenu").color;
dataObject.dataEls["background"].value = document.getElementById("backgroundmenu").color;
dataObject.dataEls["unvisitedLinks"].value = document.getElementById("unvisitedlinkmenu").color;
dataObject.dataEls["visitedLinks"].value = document.getElementById("visitedlinkmenu").color;
var items = ["foregroundText", "background", "unvisitedLinks", "visitedLinks", "browserUseSystemColors", "browserUnderlineAnchors", "useMyColors", "useMyFonts"];
for (i = 0; i < items.length; ++i)
dataObject.dataEls[items[i]] = new Object;
dataObject.dataEls["foregroundText"].value = document.getElementById("foregroundtextmenu").color;
dataObject.dataEls["background"].value = document.getElementById("backgroundmenu").color;
dataObject.dataEls["unvisitedLinks"].value = document.getElementById("unvisitedlinkmenu").color;
dataObject.dataEls["visitedLinks"].value = document.getElementById("visitedlinkmenu").color;
dataObject.dataEls["browserUseSystemColors"].checked = document.getElementById("browserUseSystemColors").checked;
dataObject.dataEls["browserUnderlineAnchors"].checked = document.getElementById("browserUnderlineAnchors").checked;
dataObject.dataEls["useMyColors"].checked = document.getElementById("useMyColors").checked;
dataObject.dataEls["useMyFonts"].checked = document.getElementById("useMyFonts").checked;
dataObject.dataEls["browserUseSystemColors"].checked = document.getElementById("browserUseSystemColors").checked;
dataObject.dataEls["browserUnderlineAnchors"].checked = document.getElementById("browserUnderlineAnchors").checked;
dataObject.dataEls["useMyColors"].checked = document.getElementById("useMyColors").checked;
dataObject.dataEls["useMyFonts"].checked = document.getElementById("useMyFonts").checked;
// save current state for language dependent fields and store
saveState();
@ -100,25 +95,19 @@ function SetFields(aDataObject)
languageData = "languageData" in aDataObject ? aDataObject.languageData : languageData ;
currentLanguage = "currentLanguage" in aDataObject ? aDataObject.currentLanguage : null ;
var lists = ["selectLangs", "proportionalFont"];
var prefvalue;
for( var i = 0; i < lists.length; i++ )
var element = document.getElementById( "selectLangs" );
if( "dataEls" in aDataObject )
{
var element = document.getElementById( lists[i] );
if( "dataEls" in aDataObject )
element.selectedItem = element.getElementsByAttribute( "value", aDataObject.dataEls[ "selectLangs" ].value )[0];
}
else
{
var prefstring = element.getAttribute( "prefstring" );
var preftype = element.getAttribute( "preftype" );
if( prefstring && preftype )
{
element.selectedItem = element.getElementsByAttribute( "value", aDataObject.dataEls[ lists[i] ].value )[0];
}
else
{
var prefstring = element.getAttribute( "prefstring" );
var preftype = element.getAttribute( "preftype" );
if( prefstring && preftype )
{
prefvalue = gPrefWindow.getPref( preftype, prefstring );
element.selectedItem = element.getElementsByAttribute( "value", prefvalue )[0];
}
var prefvalue = gPrefWindow.getPref( preftype, prefstring );
element.selectedItem = element.getElementsByAttribute( "value", prefvalue )[0];
}
}
@ -188,6 +177,7 @@ function SetFields(aDataObject)
function Startup()
{
// Initialize the sub-dialog
defaultFont = document.getElementById( "proportionalFont" );
variableSize = document.getElementById( "sizeVar" );
fixedSize = document.getElementById( "sizeMono" );
minSize = document.getElementById( "minSize" );
@ -466,6 +456,7 @@ function saveState()
if( currentLanguage && currentLanguage in languageData &&
"types" in languageData[currentLanguage] )
{
languageData[currentLanguage].defaultFont = defaultFont.value;
languageData[currentLanguage].variableSize = parseInt( variableSize.value );
languageData[currentLanguage].fixedSize = parseInt( fixedSize.value );
languageData[currentLanguage].minSize = parseInt( minSize.value );
@ -511,23 +502,26 @@ function selectLanguage()
listElement.setAttribute( "disabled", "true" );
}
// and set the font sizes
// and set the default font type and the font sizes
var dataObject = gPrefWindow.wsm.dataManager.pageData["chrome://browser/content/pref/pref-fonts.xul"].userData;
var langData = null;
try
{
var sizeVarVal, sizeFixedVal;
var defaultFontVal, sizeVarVal, sizeFixedVal;
if ('languageData' in dataObject) {
langData = dataObject.languageData[currentLanguage];
defaultFontVal = langData.defaultFont;
sizeVarVal = langData.variableSize;
sizeFixedVal = langData.fixedSize;
}
else {
defaultFontVal = gPrefWindow.getPref("string", "font.default." + languageList.value);
var variableSizePref = "font.size.variable." + languageList.value;
sizeVarVal = gPrefWindow.pref.GetIntPref( variableSizePref );
var fixedSizePref = "font.size.fixed." + languageList.value;
sizeFixedVal = gPrefWindow.pref.GetIntPref( fixedSizePref );
}
defaultFont.value = defaultFontVal;
variableSize.selectedItem = variableSize.getElementsByAttribute( "value", sizeVarVal )[0];
fixedSize.selectedItem = fixedSize.getElementsByAttribute( "value", sizeFixedVal )[0];
}

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

@ -107,8 +107,7 @@
accesskey="&proportional.accesskey;"
control="proportionalFont"/>
</hbox>
<menulist id="proportionalFont" flex="1" style="width: 0px;"
preftype="string" prefstring="font.default">
<menulist id="proportionalFont" flex="1" style="width: 0px;">
<menupopup>
<menuitem value="serif"
label="&useDefaultFontSerif.label;"/>

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

@ -157,17 +157,21 @@ function saveFontPrefs()
if (currValue != dataObject.languageData[language].types[type])
pref.SetUnicharPref(fontPrefString, dataObject.languageData[language].types[type]);
}
var defaultFontPref = "font.default." + language;
var variableSizePref = "font.size.variable." + language;
var fixedSizePref = "font.size.fixed." + language;
var minSizePref = "font.minimum-size." + language;
var currVariableSize = 12, currFixedSize = 12, minSizeVal = 0;
var currDefaultFont = "serif", currVariableSize = 12, currFixedSize = 12, minSizeVal = 0;
try {
currDefaultFont = pref.CopyUnicharPref(defaultFontPref);
currVariableSize = pref.GetIntPref(variableSizePref);
currFixedSize = pref.GetIntPref(fixedSizePref );
minSizeVal = pref.GetIntPref(minSizePref);
}
catch(e) {
}
if (currDefaultFont != dataObject.languageData[language].defaultFont)
pref.SetUnicharPref(defaultFontPref, dataObject.languageData[language].defaultFont);
if (currVariableSize != dataObject.languageData[language].variableSize)
pref.SetIntPref(variableSizePref, dataObject.languageData[language].variableSize);
if (currFixedSize != dataObject.languageData[language].fixedSize)
@ -180,7 +184,6 @@ function saveFontPrefs()
// font scaling
var fontDPI = parseInt(dataObject.fontDPI);
var myFonts = dataObject.dataEls["useMyFonts"].checked;
var defaultFont = dataObject.defaultFont;
var myColors = dataObject.dataEls["useMyColors"].checked;
try {
var currDPI = pref.GetIntPref("browser.display.screen_resolution");
@ -195,8 +198,6 @@ function saveFontPrefs()
pref.SetIntPref("browser.display.screen_resolution", fontDPI);
if (currFonts == myFonts)
pref.SetIntPref("browser.display.use_document_fonts", !myFonts);
if(currDefault != defaultFont)
pref.SetUnicharPref( "font.default", defaultFont );
if (currColors == myColors)
pref.SetBoolPref("browser.display.use_document_colors", !myColors);

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

@ -619,7 +619,7 @@ mozilla_set_pref( PtWidget_t *widget, char *option, char *value )
char *font_default = NULL;
char preference[256];
pref->CopyCharPref( "font.default", &font_default );
pref->CopyCharPref( "font.default.x-western", &font_default );
if( !font_default ) font_default = "serif";
sprintf( preference, "font.name.%s.x-western", font_default );
@ -864,7 +864,7 @@ static void mozilla_get_pref( PtWidget_t *widget, char *option, char *value ) {
char *font_default = NULL, *font;
char preference[256];
pref->CopyCharPref( "font.default", &font_default );
pref->CopyCharPref( "font.default.x-western", &font_default );
if( !font_default ) font_default = "serif";
sprintf( preference, "font.name.%s.x-western", font_default );

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

@ -253,11 +253,11 @@ TranslatePropFont(unsigned char *aRegValue, DWORD aRegValueLength,
if (isSerif) {
prefs->SetCharPref("font.name.serif.x-western",
NS_REINTERPRET_CAST(char *, aRegValue));
prefs->SetCharPref("font.default", "serif");
prefs->SetCharPref("font.default.x-western", "serif");
} else {
prefs->SetCharPref("font.name.sans-serif.x-western",
NS_REINTERPRET_CAST(char *, aRegValue));
prefs->SetCharPref("font.default", "sans-serif");
prefs->SetCharPref("font.default.x-western", "sans-serif");
}
}

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

@ -404,10 +404,14 @@ nsFontMetricsXft::Init(const nsFont& aFont, nsIAtom* aLangGroup,
return NS_ERROR_FAILURE;
nsXPIDLCString value;
const char* langGroup;
mLangGroup->GetUTF8String(&langGroup);
// Set up the default font name if it's not set
if (!mGenericFont) {
prefService->CopyCharPref("font.default", getter_Copies(value));
nsCAutoString name("font.default.");
name.Append(langGroup);
prefService->CopyCharPref(name.get(), getter_Copies(value));
if (value.get())
mDefaultFont = value.get();
@ -427,10 +431,6 @@ nsFontMetricsXft::Init(const nsFont& aFont, nsIAtom* aLangGroup,
name.Append("variable");
name.Append(char('.'));
const char* langGroup;
mLangGroup->GetUTF8String(&langGroup);
name.Append(langGroup);
PRInt32 minimum = 0;

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

@ -1626,8 +1626,12 @@ NS_IMETHODIMP nsFontMetricsGTK::Init(const nsFont& aFont, nsIAtom* aLangGroup,
mFont.EnumerateFamilies(FontEnumCallback, this);
nsXPIDLCString value;
const char* langGroup;
mLangGroup->GetUTF8String(&langGroup);
if (!mGeneric) {
gPref->CopyCharPref("font.default", getter_Copies(value));
nsCAutoString name("font.default.");
name.Append(langGroup);
gPref->CopyCharPref(name.get(), getter_Copies(value));
if (value.get()) {
mDefaultFont = value.get();
}
@ -1646,8 +1650,6 @@ NS_IMETHODIMP nsFontMetricsGTK::Init(const nsFont& aFont, nsIAtom* aLangGroup,
name.Append("variable");
}
name.Append(char('.'));
const char* langGroup = nsnull;
mLangGroup->GetUTF8String(&langGroup);
name.Append(langGroup);
PRInt32 minimum = 0;
res = gPref->GetIntPref(name.get(), &minimum);
@ -6743,4 +6745,3 @@ CharSetNameToCodeRangeBits(const char *aCharset,
*aCodeRange2 = charSetInfo->mCodeRange2Bits;
}
#endif

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

@ -208,10 +208,14 @@ nsFontMetricsPango::Init(const nsFont& aFont, nsIAtom* aLangGroup,
return NS_ERROR_FAILURE;
nsXPIDLCString value;
const char* langGroup;
mLangGroup->GetUTF8String(&langGroup);
// Set up the default font name if it's not set
if (!mGenericFont) {
prefService->CopyCharPref("font.default", getter_Copies(value));
nsCAutoString name("font.default.");
name.Append(langGroup);
prefService->CopyCharPref(name.get(), getter_Copies(value));
if (value.get())
mDefaultFont = value.get();
@ -231,10 +235,6 @@ nsFontMetricsPango::Init(const nsFont& aFont, nsIAtom* aLangGroup,
name.Append("variable");
name.Append(char('.'));
const char* langGroup;
mLangGroup->GetUTF8String(&langGroup);
name.Append(langGroup);
PRInt32 minimumInt = 0;

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

@ -376,10 +376,14 @@ nsFontMetricsXft::Init(const nsFont& aFont, nsIAtom* aLangGroup,
return NS_ERROR_FAILURE;
nsXPIDLCString value;
const char* langGroup;
mLangGroup->GetUTF8String(&langGroup);
// Set up the default font name if it's not set
if (!mGenericFont) {
prefService->CopyCharPref("font.default", getter_Copies(value));
nsCAutoString name("font.default.");
name.Append(langGroup);
prefService->CopyCharPref(name.get(), getter_Copies(value));
if (value.get())
mDefaultFont = value.get();
@ -399,10 +403,6 @@ nsFontMetricsXft::Init(const nsFont& aFont, nsIAtom* aLangGroup,
name.Append("variable");
name.Append(char('.'));
const char* langGroup;
mLangGroup->GetUTF8String(&langGroup);
name.Append(langGroup);
PRInt32 minimum = 0;

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

@ -1343,7 +1343,11 @@ nsFontMetricsOS2::RealizeFont()
// set a fallback generic font if the font-family list didn't have one
if (mGeneric.IsEmpty()) {
rv = gPref->CopyUnicharPref("font.default", getter_Copies(value));
const char* langGroup = nsnull;
mLangGroup->GetUTF8String(&langGroup);
pref.Assign("font.default.");
pref.Append(langGroup);
rv = gPref->CopyUnicharPref(pref.get(), getter_Copies(value));
if (NS_SUCCEEDED(rv)) {
mGeneric.Assign(value);
}

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

@ -875,9 +875,14 @@ nsFontPSXft::FindFont(PRUnichar aChar, const nsFont& aFont,
nsXPIDLCString value;
nsCAutoString defaultFont;
nsAutoString langGroupStr;
langGroup->ToString(langGroupStr);
// Set up the default font name if it's not set
if (!fpi.mGenericFont) {
prefService->CopyCharPref("font.default", getter_Copies(value));
nsCAutoString name("font.default.");
LossyAppendUTF16toASCII(langGroupStr, name);
prefService->CopyCharPref(name.get(), getter_Copies(value));
if (value.get())
defaultFont = value.get();
@ -1483,11 +1488,13 @@ nsFontPSFreeType::AddUserPref(nsIAtom *aLang, const nsFont& aFont,
NS_ENSURE_SUCCESS(rv, PR_FALSE);
nsXPIDLCString value;
pref->CopyCharPref("font.default", getter_Copies(value));
nsCAutoString name("font.default.");
name.Append(fpi->lang);
pref->CopyCharPref(name.get(), getter_Copies(value));
if (!value.get())
return PR_FALSE;
nsCAutoString name("font.name.");
name.Assign("font.name.");
name.Append(value);
name.Append(char('.'));
name.Append(fpi->lang);

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

@ -3557,7 +3557,11 @@ nsFontMetricsWin::RealizeFont()
// set a fallback generic font if the font-family list didn't have one
if (mGeneric.IsEmpty()) {
rv = gPref->CopyUnicharPref("font.default", getter_Copies(value));
pref.Assign("font.default.");
const char* langGroup;
mLangGroup->GetUTF8String(&langGroup);
pref.Append(langGroup);
rv = gPref->CopyUnicharPref(pref.get(), getter_Copies(value));
if (NS_SUCCEEDED(rv)) {
mGeneric.Assign(value);
}

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

@ -1975,8 +1975,12 @@ NS_IMETHODIMP nsFontMetricsXlib::Init(const nsFont& aFont, nsIAtom* aLangGroup,
mFont.EnumerateFamilies(FontEnumCallback, this);
nsXPIDLCString value;
const char* langGroup = nsnull;
mLangGroup->GetUTF8String(&langGroup);
if (!mGeneric) {
mFontMetricsContext->mPref->CopyCharPref("font.default", getter_Copies(value));
nsCAutoString name("font.default.");
name.Append(langGroup);
mFontMetricsContext->mPref->CopyCharPref(name.get(), getter_Copies(value));
if (value.get()) {
mDefaultFont = value.get();
}
@ -1995,8 +1999,6 @@ NS_IMETHODIMP nsFontMetricsXlib::Init(const nsFont& aFont, nsIAtom* aLangGroup,
name.Append("variable");
}
name.Append(char('.'));
const char* langGroup = nsnull;
mLangGroup->GetUTF8String(&langGroup);
name.Append(langGroup);
PRInt32 minimum = 0;
res = mFontMetricsContext->mPref->GetIntPref(name.get(), &minimum);
@ -6051,4 +6053,3 @@ void CharSetNameToCodeRangeBits(const char *aCharset,
*aCodeRange2 = charSetInfo->mCodeRange2Bits;
}
#endif /* MOZ_ENABLE_FREETYPE2 */

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

@ -366,7 +366,8 @@ nsPresContext::GetFontPreferences()
font->name.Assign(value);
}
else {
value = nsContentUtils::GetStringPref("font.default");
MAKE_FONT_PREF_KEY(pref, "font.default.", langGroup);
value = nsContentUtils::GetStringPref(pref.get());
if (!value.IsEmpty()) {
mDefaultVariableFont.name.Assign(value);
}

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

@ -49,7 +49,7 @@ catch(e)
var fontEnumerator = null;
var globalFonts = null;
var fontTypes = ["serif", "sans-serif", "monospace"];
var variableSize, fixedSize, minSize, languageList;
var defaultFont, variableSize, fixedSize, minSize, languageList;
var languageData = [];
var currentLanguage;
var gPrefutilitiesBundle;
@ -60,16 +60,11 @@ function GetFields()
var dataObject = parent.hPrefWindow.wsm.dataManager.pageData["chrome://communicator/content/pref/pref-fonts.xul"];
// store data for language independent widgets
var lists = ["selectLangs", "proportionalFont"];
for( var i = 0; i < lists.length; i++ )
{
if( !( "dataEls" in dataObject ) )
dataObject.dataEls = [];
dataObject.dataEls[ lists[i] ] = [];
dataObject.dataEls[ lists[i] ].value = document.getElementById( lists[i] ).value;
}
if( !( "dataEls" in dataObject ) )
dataObject.dataEls = [];
dataObject.dataEls[ "selectLangs" ] = [];
dataObject.dataEls[ "selectLangs" ].value = document.getElementById( "selectLangs" ).value;
dataObject.defaultFont = document.getElementById( "proportionalFont" ).value;
dataObject.fontDPI = document.getElementById( "screenResolution" ).value;
dataObject.useDocFonts = document.getElementById( "browserUseDocumentFonts" ).checked ? 1 : 0;
@ -86,25 +81,19 @@ function SetFields( aDataObject )
languageData = "languageData" in aDataObject ? aDataObject.languageData : languageData ;
currentLanguage = "currentLanguage" in aDataObject ? aDataObject.currentLanguage : null ;
var lists = ["selectLangs", "proportionalFont"];
var prefvalue;
for( var i = 0; i < lists.length; i++ )
var element = document.getElementById( "selectLangs" );
if( "dataEls" in aDataObject )
{
var element = document.getElementById( lists[i] );
if( "dataEls" in aDataObject )
element.selectedItem = element.getElementsByAttribute( "value", aDataObject.dataEls[ "selectLangs" ].value )[0];
}
else
{
var prefstring = element.getAttribute( "prefstring" );
var preftype = element.getAttribute( "preftype" );
if( prefstring && preftype )
{
element.selectedItem = element.getElementsByAttribute( "value", aDataObject.dataEls[ lists[i] ].value )[0];
}
else
{
var prefstring = element.getAttribute( "prefstring" );
var preftype = element.getAttribute( "preftype" );
if( prefstring && preftype )
{
prefvalue = parent.hPrefWindow.getPref( preftype, prefstring );
element.selectedItem = element.getElementsByAttribute( "value", prefvalue )[0];
}
var prefvalue = parent.hPrefWindow.getPref( preftype, prefstring );
element.selectedItem = element.getElementsByAttribute( "value", prefvalue )[0];
}
}
@ -148,6 +137,7 @@ function SetFields( aDataObject )
function Startup()
{
defaultFont = document.getElementById( "proportionalFont" );
variableSize = document.getElementById( "sizeVar" );
fixedSize = document.getElementById( "sizeMono" );
minSize = document.getElementById( "minSize" );
@ -458,12 +448,14 @@ function saveFontPrefs()
}
}
}
var defaultFontPref = "font.default." + language;
var variableSizePref = "font.size.variable." + language;
var fixedSizePref = "font.size.fixed." + language;
var minSizePref = "font.minimum-size." + language;
var currVariableSize = 12, currFixedSize = 12, minSizeVal = 0;
var currDefaultFont = "serif", currVariableSize = 12, currFixedSize = 12, minSizeVal = 0;
try
{
currDefaultFont = pref.CopyUnicharPref( defaultFontPref );
currVariableSize = pref.GetIntPref( variableSizePref );
currFixedSize = pref.GetIntPref( fixedSizePref );
minSizeVal = pref.GetIntPref( minSizePref );
@ -471,11 +463,13 @@ function saveFontPrefs()
catch(e)
{
}
if( currDefaultFont != dataObject.languageData[language].defaultFont )
pref.SetUnicharPref( defaultFontPref, dataObject.languageData[language].defaultFont );
if( currVariableSize != dataObject.languageData[language].variableSize )
pref.SetIntPref( variableSizePref, dataObject.languageData[language].variableSize );
if( currFixedSize != dataObject.languageData[language].fixedSize )
pref.SetIntPref( fixedSizePref, dataObject.languageData[language].fixedSize );
if ( minSizeVal != dataObject.languageData[language].minSize ) {
if( minSizeVal != dataObject.languageData[language].minSize ) {
pref.SetIntPref ( minSizePref, dataObject.languageData[language].minSize );
}
}
@ -483,13 +477,11 @@ function saveFontPrefs()
// font scaling
var fontDPI = parseInt( dataObject.fontDPI );
var documentFonts = dataObject.useDocFonts;
var defaultFont = dataObject.defaultFont;
try
{
var currDPI = pref.GetIntPref( "browser.display.screen_resolution" );
var currFonts = pref.GetIntPref( "browser.display.use_document_fonts" );
var currDefault = pref.CopyUnicharPref( "font.default" );
}
catch(e)
{
@ -498,10 +490,6 @@ function saveFontPrefs()
pref.SetIntPref( "browser.display.screen_resolution", fontDPI );
if( currFonts != documentFonts )
pref.SetIntPref( "browser.display.use_document_fonts", documentFonts );
if( currDefault != defaultFont )
{
pref.SetUnicharPref( "font.default", defaultFont );
}
// save off the language information...
}
@ -524,6 +512,7 @@ function saveState()
if( currentLanguage && currentLanguage in languageData &&
"types" in languageData[currentLanguage] )
{
languageData[currentLanguage].defaultFont = defaultFont.value;
languageData[currentLanguage].variableSize = parseInt( variableSize.value );
languageData[currentLanguage].fixedSize = parseInt( fixedSize.value );
languageData[currentLanguage].minSize = parseInt( minSize.value );
@ -569,9 +558,11 @@ function selectLanguage()
listElement.setAttribute( "disabled", "true" );
}
// and set the font sizes
// and set the default font type and the font sizes
try
{
defaultFont.value = parent.hPrefWindow.getPref("string", "font.default." + languageList.value);
var variableSizePref = "font.size.variable." + languageList.value;
var sizeVarVal = parent.hPrefWindow.pref.GetIntPref( variableSizePref );
variableSize.selectedItem = variableSize.getElementsByAttribute( "value", sizeVarVal )[0];

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

@ -90,8 +90,7 @@
accesskey="&proportional.accesskey;"
control="proportionalFont"/>
</hbox>
<menulist id="proportionalFont"
preftype="string" prefstring="font.default">
<menulist id="proportionalFont">
<menupopup>
<menuitem value="serif"
label="&useDefaultFontSerif.label;"/>

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

@ -973,55 +973,71 @@ pref("font.name.monospace.x-tamil", "Latha");
pref("font.name-list.serif.x-tamil", "Latha, Code2000");
pref("font.name-list.monospace.x-tamil", "Latha, Code2000");
pref("font.default", "serif");
pref("font.default.ar", "sans-serif");
pref("font.size.variable.ar", 16);
pref("font.size.fixed.ar", 13);
pref("font.default.el", "serif");
pref("font.size.variable.el", 16);
pref("font.size.fixed.el", 13);
pref("font.default.he", "sans-serif");
pref("font.size.variable.he", 16);
pref("font.size.fixed.he", 13);
pref("font.default.ja", "sans-serif");
pref("font.size.variable.ja", 16);
pref("font.size.fixed.ja", 16);
pref("font.default.ko", "sans-serif");
pref("font.size.variable.ko", 16);
pref("font.size.fixed.ko", 16);
pref("font.default.th", "serif");
pref("font.size.variable.th", 16);
pref("font.size.fixed.th", 13);
pref("font.default.tr", "serif");
pref("font.size.variable.tr", 16);
pref("font.size.fixed.tr", 13);
pref("font.default.x-baltic", "serif");
pref("font.size.variable.x-baltic", 16);
pref("font.size.fixed.x-baltic", 13);
pref("font.default.x-central-euro", "serif");
pref("font.size.variable.x-central-euro", 16);
pref("font.size.fixed.x-central-euro", 13);
pref("font.default.x-cyrillic", "serif");
pref("font.size.variable.x-cyrillic", 16);
pref("font.size.fixed.x-cyrillic", 13);
pref("font.default.x-devanagari", "serif");
pref("font.size.variable.x-devanagari", 16);
pref("font.size.fixed.x-devanagari", 13);
pref("font.default.x-tamil", "serif");
pref("font.size.variable.x-tamil", 16);
pref("font.size.fixed.x-tamil", 13);
pref("font.default.x-unicode", "serif");
pref("font.size.variable.x-unicode", 16);
pref("font.size.fixed.x-unicode", 13);
pref("font.default.x-western", "serif");
pref("font.size.variable.x-western", 16);
pref("font.size.fixed.x-western", 13);
pref("font.default.zh-CN", "sans-serif");
pref("font.size.variable.zh-CN", 16);
pref("font.size.fixed.zh-CN", 16);
pref("font.default.zh-TW", "sans-serif");
pref("font.size.variable.zh-TW", 16);
pref("font.size.fixed.zh-TW", 16);
pref("font.default.zh-HK", "sans-serif");
pref("font.size.variable.zh-HK", 16);
pref("font.size.fixed.zh-HK", 16);
@ -1180,49 +1196,63 @@ pref("font.name.monospace.zh-HK", "Apple LiGothic Medium");
pref("font.name.cursive.zh-HK", "XXX.cursive");
pref("font.name.fantasy.zh-HK", "XXX.fantasy");
pref("font.default", "serif");
pref("font.default.ar", "sans-serif");
pref("font.size.variable.ar", 15);
pref("font.size.fixed.ar", 13);
pref("font.default.el", "serif");
pref("font.size.variable.el", 16);
pref("font.size.fixed.el", 13);
pref("font.default.he", "sans-serif");
pref("font.size.variable.he", 15);
pref("font.size.fixed.he", 13);
pref("font.default.ja", "sans-serif");
pref("font.size.variable.ja", 14);
pref("font.size.fixed.ja", 14);
pref("font.default.ko", "sans-serif");
pref("font.size.variable.ko", 16);
pref("font.size.fixed.ko", 16);
pref("font.default.th", "serif");
pref("font.size.variable.th", 16);
pref("font.size.fixed.th", 13);
pref("font.default.tr", "serif");
pref("font.size.variable.tr", 16);
pref("font.size.fixed.tr", 13);
pref("font.default.x-baltic", "serif");
pref("font.size.variable.x-baltic", 16);
pref("font.size.fixed.x-baltic", 13);
pref("font.default.x-central-euro", "serif");
pref("font.size.variable.x-central-euro", 16);
pref("font.size.fixed.x-central-euro", 13);
pref("font.default.x-cyrillic", "serif");
pref("font.size.variable.x-cyrillic", 16);
pref("font.size.fixed.x-cyrillic", 13);
pref("font.default.x-unicode", "serif");
pref("font.size.variable.x-unicode", 16);
pref("font.size.fixed.x-unicode", 13);
pref("font.default.x-western", "serif");
pref("font.size.variable.x-western", 16);
pref("font.size.fixed.x-western", 13);
pref("font.default.zh-CN", "sans-serif");
pref("font.size.variable.zh-CN", 15);
pref("font.size.fixed.zh-CN", 16);
pref("font.default.zh-TW", "sans-serif");
pref("font.size.variable.zh-TW", 15);
pref("font.size.fixed.zh-TW", 16);
pref("font.default.zh-HK", "sans-serif");
pref("font.size.variable.zh-HK", 15);
pref("font.size.fixed.zh-HK", 16);
@ -1339,48 +1369,72 @@ pref("font.name.sans-serif.zh-HK", "Helv");
pref("font.name.monospace.zh-HK", "Courier");
pref("font.default", "serif");
pref("font.default.ar", "sans-serif");
pref("font.size.variable.ar", 16);
pref("font.size.fixed.ar", 13);
pref("font.default.el", "serif");
pref("font.size.variable.el", 16);
pref("font.size.fixed.el", 13);
pref("font.default.he", "sans-serif");
pref("font.size.variable.he", 16);
pref("font.size.fixed.he", 13);
pref("font.default.ja", "sans-serif");
pref("font.size.variable.ja", 16);
pref("font.size.fixed.ja", 16);
pref("font.default.ko", "sans-serif");
pref("font.size.variable.ko", 16);
pref("font.size.fixed.ko", 16);
pref("font.default.th", "serif");
pref("font.size.variable.th", 16);
pref("font.size.fixed.th", 13);
pref("font.default.tr", "serif");
pref("font.size.variable.tr", 16);
pref("font.size.fixed.tr", 13);
pref("font.default.x-baltic", "serif");
pref("font.size.variable.x-baltic", 16);
pref("font.size.fixed.x-baltic", 13);
pref("font.default.x-central-euro", "serif");
pref("font.size.variable.x-central-euro", 16);
pref("font.size.fixed.x-central-euro", 13);
pref("font.default.x-cyrillic", "serif");
pref("font.size.variable.x-cyrillic", 16);
pref("font.size.fixed.x-cyrillic", 13);
pref("font.default.x-devanagari", "serif");
pref("font.size.variable.x-devanagari", 16);
pref("font.size.fixed.x-devanagari", 13);
pref("font.default.x-tamil", "serif");
pref("font.size.variable.x-tamil", 16);
pref("font.size.fixed.x-tamil", 13);
pref("font.default.x-unicode", "serif");
pref("font.size.variable.x-unicode", 16);
pref("font.size.fixed.x-unicode", 13);
pref("font.default.x-western", "serif");
pref("font.size.variable.x-western", 16);
pref("font.size.fixed.x-western", 13);
pref("font.default.zh-CN", "sans-serif");
pref("font.size.variable.zh-CN", 16);
pref("font.size.fixed.zh-CN", 16);
pref("font.default.zh-TW", "sans-serif");
pref("font.size.variable.zh-TW", 16);
pref("font.size.fixed.zh-TW", 16);
pref("font.default.zh-HK", "sans-serif");
pref("font.size.variable.zh-HK", 16);
pref("font.size.fixed.zh-HK", 16);
@ -1423,49 +1477,63 @@ pref("intl.font_charset", "");
pref("intl.font_spec_list", "");
pref("mail.signature_date", 0);
pref("font.default", "serif");
pref("font.default.ar", "sans-serif");
pref("font.size.variable.ar", 16);
pref("font.size.fixed.ar", 13);
pref("font.default.el", "serif");
pref("font.size.variable.el", 16);
pref("font.size.fixed.el", 13);
pref("font.default.he", "sans-serif");
pref("font.size.variable.he", 16);
pref("font.size.fixed.he", 13);
pref("font.default.ja", "sans-serif");
pref("font.size.variable.ja", 16);
pref("font.size.fixed.ja", 16);
pref("font.default.ko", "sans-serif");
pref("font.size.variable.ko", 16);
pref("font.size.fixed.ko", 16);
pref("font.default.th", "serif");
pref("font.size.variable.th", 16);
pref("font.size.fixed.th", 13);
pref("font.default.tr", "serif");
pref("font.size.variable.tr", 16);
pref("font.size.fixed.tr", 13);
pref("font.default.x-baltic", "serif");
pref("font.size.variable.x-baltic", 16);
pref("font.size.fixed.x-baltic", 13);
pref("font.default.x-central-euro", "serif");
pref("font.size.variable.x-central-euro", 16);
pref("font.size.fixed.x-central-euro", 13);
pref("font.default.x-cyrillic", "serif");
pref("font.size.variable.x-cyrillic", 16);
pref("font.size.fixed.x-cyrillic", 13);
pref("font.default.x-unicode", "serif");
pref("font.size.variable.x-unicode", 16);
pref("font.size.fixed.x-unicode", 13);
pref("font.default.x-western", "serif");
pref("font.size.variable.x-western", 16);
pref("font.size.fixed.x-western", 13);
pref("font.default.zh-CN", "sans-serif");
pref("font.size.variable.zh-CN", 16);
pref("font.size.fixed.zh-CN", 16);
pref("font.default.zh-TW", "sans-serif");
pref("font.size.variable.zh-TW", 16);
pref("font.size.fixed.zh-TW", 16);
pref("font.default.zh-HK", "sans-serif");
pref("font.size.variable.zh-HK", 16);
pref("font.size.fixed.zh-HK", 16);
@ -1620,49 +1688,63 @@ pref("font.name.monospace.zh-HK", "-arphic-Ming for ISO10646-big5hkscs-0");
// zh-TW
pref("font.default", "serif");
pref("font.default.ar", "sans-serif");
pref("font.size.variable.ar", 16);
pref("font.size.fixed.ar", 12);
pref("font.default.el", "serif");
pref("font.size.variable.el", 16);
pref("font.size.fixed.el", 12);
pref("font.default.he", "sans-serif");
pref("font.size.variable.he", 16);
pref("font.size.fixed.he", 12);
pref("font.default.ja", "sans-serif");
pref("font.size.variable.ja", 16);
pref("font.size.fixed.ja", 16);
pref("font.default.ko", "sans-serif");
pref("font.size.variable.ko", 16);
pref("font.size.fixed.ko", 16);
pref("font.default.th", "serif");
pref("font.size.variable.th", 16);
pref("font.size.fixed.th", 12);
pref("font.default.tr", "serif");
pref("font.size.variable.tr", 16);
pref("font.size.fixed.tr", 12);
pref("font.default.x-baltic", "serif");
pref("font.size.variable.x-baltic", 16);
pref("font.size.fixed.x-baltic", 12);
pref("font.default.x-central-euro", "serif");
pref("font.size.variable.x-central-euro", 16);
pref("font.size.fixed.x-central-euro", 12);
pref("font.default.x-cyrillic", "serif");
pref("font.size.variable.x-cyrillic", 16);
pref("font.size.fixed.x-cyrillic", 12);
pref("font.default.x-unicode", "serif");
pref("font.size.variable.x-unicode", 16);
pref("font.size.fixed.x-unicode", 12);
pref("font.default.x-western", "serif");
pref("font.size.variable.x-western", 16);
pref("font.size.fixed.x-western", 12);
pref("font.default.zh-CN", "sans-serif");
pref("font.size.variable.zh-CN", 16);
pref("font.size.fixed.zh-CN", 16);
pref("font.default.zh-TW", "sans-serif");
pref("font.size.variable.zh-TW", 16);
pref("font.size.fixed.zh-TW", 16);
pref("font.default.zh-HK", "sans-serif");
pref("font.size.variable.zh-HK", 16);
pref("font.size.fixed.zh-HK", 16);

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

@ -40,7 +40,7 @@
var fontEnumerator = null;
var globalFonts = null;
var fontTypes = ["serif", "sans-serif", "cursive", "fantasy", "monospace"];
var variableSize, fixedSize, minSize, languageList;
var defaultFont, variableSize, fixedSize, minSize, languageList;
var languageData = [];
var currentLanguage;
var gPrefutilitiesBundle;
@ -51,18 +51,13 @@ function GetFields()
var dataObject = parent.hPrefWindow.wsm.dataManager.pageData["chrome://communicator/content/pref/pref-fonts.xul"];
// store data for language independent widgets
var lists = ["selectLangs", "proportionalFont"];
for( var i = 0; i < lists.length; i++ )
{
if( !( "dataEls" in dataObject ) )
dataObject.dataEls = [];
dataObject.dataEls[ lists[i] ] = [];
dataObject.dataEls[ lists[i] ].value = document.getElementById( lists[i] ).value;
}
if( !( "dataEls" in dataObject ) )
dataObject.dataEls = [];
dataObject.dataEls[ "selectLangs" ] = [];
dataObject.dataEls[ "selectLangs" ].value = document.getElementById( "selectLangs" ).value;
dataObject.defaultFont = document.getElementById( "proportionalFont" ).value;
dataObject.fontDPI = document.getElementById( "screenResolution" ).value;
dataObject.useDocFonts = document.getElementById( "browserUseDocumentFonts" ).checked ? 1 : 0;
dataObject.fontDPI = document.getElementById( "screenResolution" ).value;
dataObject.useDocFonts = document.getElementById( "browserUseDocumentFonts" ).checked ? 1 : 0;
// save current state for language dependent fields and store
saveState();
@ -77,25 +72,19 @@ function SetFields( aDataObject )
languageData = "languageData" in aDataObject ? aDataObject.languageData : languageData ;
currentLanguage = "currentLanguage" in aDataObject ? aDataObject.currentLanguage : null ;
var lists = ["selectLangs", "proportionalFont"];
var prefvalue;
for( var i = 0; i < lists.length; i++ )
var element = document.getElementById( "selectLangs" );
if( "dataEls" in aDataObject )
{
var element = document.getElementById( lists[i] );
if( "dataEls" in aDataObject )
element.selectedItem = element.getElementsByAttribute( "value", aDataObject.dataEls[ "selectLangs" ].value )[0];
}
else
{
var prefstring = element.getAttribute( "prefstring" );
var preftype = element.getAttribute( "preftype" );
if( prefstring && preftype )
{
element.selectedItem = element.getElementsByAttribute( "value", aDataObject.dataEls[ lists[i] ].value )[0];
}
else
{
var prefstring = element.getAttribute( "prefstring" );
var preftype = element.getAttribute( "preftype" );
if( prefstring && preftype )
{
prefvalue = parent.hPrefWindow.getPref( preftype, prefstring );
element.selectedItem = element.getElementsByAttribute( "value", prefvalue )[0];
}
var prefvalue = parent.hPrefWindow.getPref( preftype, prefstring );
element.selectedItem = element.getElementsByAttribute( "value", prefvalue )[0];
}
}
@ -137,6 +126,7 @@ function SetFields( aDataObject )
function Startup()
{
defaultFont = document.getElementById( "proportionalFont" );
variableSize = document.getElementById( "sizeVar" );
fixedSize = document.getElementById( "sizeMono" );
minSize = document.getElementById( "minSize" );
@ -433,12 +423,14 @@ function saveFontPrefs()
}
}
}
var defaultFontPref = "font.default." + language;
var variableSizePref = "font.size.variable." + language;
var fixedSizePref = "font.size.fixed." + language;
var minSizePref = "font.minimum-size." + language;
var currVariableSize = 12, currFixedSize = 12, minSizeVal = 0;
var currDefaultFont = "serif", currVariableSize = 12, currFixedSize = 12, minSizeVal = 0;
try
{
currDefaultFont = parent.hPrefWindow.getPref( "string", defaultFontPref );
currVariableSize = pref.getIntPref( variableSizePref );
currFixedSize = pref.getIntPref( fixedSizePref );
minSizeVal = pref.getIntPref( minSizePref );
@ -446,11 +438,13 @@ function saveFontPrefs()
catch(e)
{
}
if( currDefaultFont != dataObject.languageData[language].defaultFont )
parent.hPrefWindow.setPref( "string", defaultFontPref, dataObject.languageData[language].defaultFont );
if( currVariableSize != dataObject.languageData[language].variableSize )
pref.setIntPref( variableSizePref, dataObject.languageData[language].variableSize );
if( currFixedSize != dataObject.languageData[language].fixedSize )
pref.setIntPref( fixedSizePref, dataObject.languageData[language].fixedSize );
if ( minSizeVal != dataObject.languageData[language].minSize ) {
if( minSizeVal != dataObject.languageData[language].minSize ) {
pref.setIntPref ( minSizePref, dataObject.languageData[language].minSize );
}
}
@ -464,7 +458,6 @@ function saveFontPrefs()
{
var currDPI = pref.getIntPref( "browser.display.screen_resolution" );
var currFonts = pref.getIntPref( "browser.display.use_document_fonts" );
var currDefault = pref.getComplexValue( "font.default", Components.interfaces.nsISupportsString ).data;
}
catch(e)
{
@ -473,10 +466,6 @@ function saveFontPrefs()
pref.setIntPref( "browser.display.screen_resolution", fontDPI );
if( currFonts != documentFonts )
pref.setIntPref( "browser.display.use_document_fonts", documentFonts );
if( currDefault != defaultFont )
{
parent.hPrefWindow.setPref( "string", "font.default", defaultFont );
}
}
function saveState()
@ -497,6 +486,7 @@ function saveState()
if( currentLanguage && currentLanguage in languageData &&
"types" in languageData[currentLanguage] )
{
languageData[currentLanguage].defaultFont = defaultFont.value;
languageData[currentLanguage].variableSize = parseInt( variableSize.value );
languageData[currentLanguage].fixedSize = parseInt( fixedSize.value );
languageData[currentLanguage].minSize = parseInt( minSize.value );
@ -542,9 +532,11 @@ function selectLanguage()
listElement.setAttribute( "disabled", "true" );
}
// and set the font sizes
// and set the default font type and the font sizes
try
{
defaultFont.value = parent.hPrefWindow.getPref("string", "font.default." + languageList.value);
var variableSizePref = "font.size.variable." + languageList.value;
var sizeVarVal = parent.hPrefWindow.pref.getIntPref( variableSizePref );
variableSize.selectedItem = variableSize.getElementsByAttribute( "value", sizeVarVal )[0];

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

@ -116,8 +116,7 @@
accesskey="&proportional.accesskey;"
control="proportionalFont"/>
</hbox>
<menulist id="proportionalFont" flex="1" style="width: 0px;"
preftype="string" prefstring="font.default">
<menulist id="proportionalFont" flex="1" style="width: 0px;">
<menupopup>
<menuitem value="serif"
label="&useDefaultFontSerif.label;"/>