diff --git a/mozilla/browser/components/preferences/content.js b/mozilla/browser/components/preferences/content.js index 071dc4f6089..7fa85e08548 100644 --- a/mozilla/browser/components/preferences/content.js +++ b/mozilla/browser/components/preferences/content.js @@ -186,7 +186,7 @@ var gContentPane = { const kFontSizeFmtVariable = "font.size.variable.%LANG%"; var prefs = [{ format : aIsSerif ? kFontNameFmtSerif : kFontNameFmtSansSerif, - type : "unichar", + type : "fontname", element : "defaultFont", fonttype : aIsSerif ? "serif" : "sans-serif" }, { format : aIsSerif ? kFontNameListFmtSerif : kFontNameListFmtSansSerif, diff --git a/mozilla/browser/components/preferences/fonts.js b/mozilla/browser/components/preferences/fonts.js index 7a5a9b75a36..997cb4116b9 100644 --- a/mozilla/browser/components/preferences/fonts.js +++ b/mozilla/browser/components/preferences/fonts.js @@ -53,16 +53,16 @@ const kFontMinSizeFmt = "font.minimum-size.%LANG%"; var gFontsDialog = { _selectLanguageGroup: function (aLanguageGroup) { - var prefs = [{ format: kDefaultFontType, type: "string", element: "defaultFontType", fonttype: null}, - { format: kFontNameFmtSerif, type: "unichar", element: "serif", fonttype: "serif" }, - { format: kFontNameFmtSansSerif, type: "unichar", element: "sans-serif", fonttype: "sans-serif" }, - { format: kFontNameFmtMonospace, type: "unichar", element: "monospace", fonttype: "monospace" }, - { format: kFontNameListFmtSerif, type: "unichar", element: null, fonttype: "serif" }, - { format: kFontNameListFmtSansSerif, type: "unichar", element: null, fonttype: "sans-serif" }, - { format: kFontNameListFmtMonospace, type: "unichar", element: null, fonttype: "monospace" }, - { format: kFontSizeFmtVariable, type: "int", element: "sizeVar", fonttype: null }, - { format: kFontSizeFmtFixed, type: "int", element: "sizeMono", fonttype: null }, - { format: kFontMinSizeFmt, type: "int", element: "minSize", fonttype: null }]; + var prefs = [{ format: kDefaultFontType, type: "string", element: "defaultFontType", fonttype: null}, + { format: kFontNameFmtSerif, type: "fontname", element: "serif", fonttype: "serif" }, + { format: kFontNameFmtSansSerif, type: "fontname", element: "sans-serif", fonttype: "sans-serif" }, + { format: kFontNameFmtMonospace, type: "fontname", element: "monospace", fonttype: "monospace" }, + { format: kFontNameListFmtSerif, type: "unichar", element: null, fonttype: "serif" }, + { format: kFontNameListFmtSansSerif, type: "unichar", element: null, fonttype: "sans-serif" }, + { format: kFontNameListFmtMonospace, type: "unichar", element: null, fonttype: "monospace" }, + { format: kFontSizeFmtVariable, type: "int", element: "sizeVar", fonttype: null }, + { format: kFontSizeFmtFixed, type: "int", element: "sizeMono", fonttype: null }, + { format: kFontMinSizeFmt, type: "int", element: "minSize", fonttype: null }]; var preferences = document.getElementById("fontPreferences"); for (var i = 0; i < prefs.length; ++i) { var preference = document.getElementById(prefs[i].format.replace(/%LANG%/, aLanguageGroup)); diff --git a/mozilla/gfx/idl/nsIFontEnumerator.idl b/mozilla/gfx/idl/nsIFontEnumerator.idl index b6a1e06856f..31485ba78cc 100644 --- a/mozilla/gfx/idl/nsIFontEnumerator.idl +++ b/mozilla/gfx/idl/nsIFontEnumerator.idl @@ -39,7 +39,7 @@ #include "nsISupports.idl" -[scriptable, uuid(a6cf9114-15b3-11d2-932e-00805f8add32)] +[scriptable, uuid(924d98d9-3518-4cb4-8708-c74fe8e3ec3c)] interface nsIFontEnumerator : nsISupports { /** @@ -83,4 +83,12 @@ interface nsIFontEnumerator : nsISupports * return true if font list is changed */ boolean updateFontList(); + + /** + * get the standard family name on the system from given family + * @param aName family name which may be alias + * @return the standard family name on the system, if given name does not + * exist, returns empty string + */ + wstring getStandardFamilyName(in wstring aName); }; diff --git a/mozilla/gfx/src/thebes/nsThebesFontEnumerator.cpp b/mozilla/gfx/src/thebes/nsThebesFontEnumerator.cpp index c45d4fda63c..bcaf8c8502a 100644 --- a/mozilla/gfx/src/thebes/nsThebesFontEnumerator.cpp +++ b/mozilla/gfx/src/thebes/nsThebesFontEnumerator.cpp @@ -128,3 +128,27 @@ nsThebesFontEnumerator::UpdateFontList(PRBool *_retval) *_retval = PR_FALSE; // always return false for now return NS_OK; } + +NS_IMETHODIMP +nsThebesFontEnumerator::GetStandardFamilyName(const PRUnichar *aName, + PRUnichar **aResult) +{ + NS_ENSURE_ARG_POINTER(aResult); + NS_ENSURE_ARG_POINTER(aName); + + nsAutoString name(aName); + if (name.IsEmpty()) { + *aResult = nsnull; + return NS_OK; + } + + nsAutoString family; + nsresult rv = gfxPlatform::GetPlatform()-> + GetStandardFamilyName(nsDependentString(aName), family); + if (NS_FAILED(rv) || family.IsEmpty()) { + *aResult = nsnull; + return NS_OK; + } + *aResult = ToNewUnicode(family); + return NS_OK; +} diff --git a/mozilla/gfx/thebes/public/gfxBeOSPlatform.h b/mozilla/gfx/thebes/public/gfxBeOSPlatform.h index f42c7364586..8cc68783a73 100644 --- a/mozilla/gfx/thebes/public/gfxBeOSPlatform.h +++ b/mozilla/gfx/thebes/public/gfxBeOSPlatform.h @@ -20,7 +20,6 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Masayuki Nakano * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -67,6 +66,8 @@ public: nsresult ResolveFontName(const nsAString& aFontName, FontResolverCallback aCallback, void *aClosure, PRBool& aAborted); + + nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName); protected: static gfxFontconfigUtils *sFontconfigUtils; }; diff --git a/mozilla/gfx/thebes/public/gfxOS2Platform.h b/mozilla/gfx/thebes/public/gfxOS2Platform.h index 6d86f4ba7c2..343bbe228ce 100644 --- a/mozilla/gfx/thebes/public/gfxOS2Platform.h +++ b/mozilla/gfx/thebes/public/gfxOS2Platform.h @@ -66,6 +66,7 @@ public: nsresult ResolveFontName(const nsAString& aFontName, FontResolverCallback aCallback, void *aClosure, PRBool& aAborted); + nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName); gfxFontGroup *CreateFontGroup(const nsAString &aFamilies, const gfxFontStyle *aStyle); diff --git a/mozilla/gfx/thebes/public/gfxPlatform.h b/mozilla/gfx/thebes/public/gfxPlatform.h index 716004d2f5a..4283c40ffd8 100644 --- a/mozilla/gfx/thebes/public/gfxPlatform.h +++ b/mozilla/gfx/thebes/public/gfxPlatform.h @@ -169,6 +169,12 @@ public: void *aClosure, PRBool& aAborted) = 0; + /** + * Resolving a font name to family name. The result MUST be in the result of GetFontList(). + * If the name doesn't in the system, aFamilyName will be empty string, but not failed. + */ + virtual nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName) = 0; + /** * Create the appropriate platform font group */ diff --git a/mozilla/gfx/thebes/public/gfxPlatformGtk.h b/mozilla/gfx/thebes/public/gfxPlatformGtk.h index dc3f89844e5..c855c117319 100644 --- a/mozilla/gfx/thebes/public/gfxPlatformGtk.h +++ b/mozilla/gfx/thebes/public/gfxPlatformGtk.h @@ -67,6 +67,8 @@ public: FontResolverCallback aCallback, void *aClosure, PRBool& aAborted); + nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName); + gfxFontGroup *CreateFontGroup(const nsAString &aFamilies, const gfxFontStyle *aStyle); diff --git a/mozilla/gfx/thebes/public/gfxPlatformMac.h b/mozilla/gfx/thebes/public/gfxPlatformMac.h index 1c652b39bd5..c1831788b65 100644 --- a/mozilla/gfx/thebes/public/gfxPlatformMac.h +++ b/mozilla/gfx/thebes/public/gfxPlatformMac.h @@ -60,6 +60,8 @@ public: FontResolverCallback aCallback, void *aClosure, PRBool& aAborted); + nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName); + gfxFontGroup *CreateFontGroup(const nsAString &aFamilies, const gfxFontStyle *aStyle); diff --git a/mozilla/gfx/thebes/public/gfxWindowsPlatform.h b/mozilla/gfx/thebes/public/gfxWindowsPlatform.h index 9733af92f45..c13c4dda716 100644 --- a/mozilla/gfx/thebes/public/gfxWindowsPlatform.h +++ b/mozilla/gfx/thebes/public/gfxWindowsPlatform.h @@ -69,6 +69,8 @@ public: FontResolverCallback aCallback, void *aClosure, PRBool& aAborted); + nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName); + gfxFontGroup *CreateFontGroup(const nsAString &aFamilies, const gfxFontStyle *aStyle); diff --git a/mozilla/gfx/thebes/src/gfxBeOSPlatform.cpp b/mozilla/gfx/thebes/src/gfxBeOSPlatform.cpp index 629d6046b9b..b22893e9550 100644 --- a/mozilla/gfx/thebes/src/gfxBeOSPlatform.cpp +++ b/mozilla/gfx/thebes/src/gfxBeOSPlatform.cpp @@ -109,3 +109,9 @@ gfxBeOSPlatform::ResolveFontName(const nsAString& aFontName, return sFontconfigUtils->ResolveFontName(aFontName, aCallback, aClosure, aAborted); } + +nsresult +gfxBeOSPlatform::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName) +{ + return sFontconfigUtils->GetStandardFamilyName(aFontName, aFamilyName); +} diff --git a/mozilla/gfx/thebes/src/gfxFontconfigUtils.cpp b/mozilla/gfx/thebes/src/gfxFontconfigUtils.cpp index 1cf878c8538..d601575ffe2 100755 --- a/mozilla/gfx/thebes/src/gfxFontconfigUtils.cpp +++ b/mozilla/gfx/thebes/src/gfxFontconfigUtils.cpp @@ -368,6 +368,115 @@ gfxFontconfigUtils::GetResolvedFonts(const nsACString& aName, return rv; } +nsresult +gfxFontconfigUtils::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName) +{ + aFamilyName.Truncate(); + + // The fontconfig has generic family names in the font list. + if (aFontName.EqualsLiteral("serif") || + aFontName.EqualsLiteral("sans-serif") || + aFontName.EqualsLiteral("monospace")) { + aFamilyName.Assign(aFontName); + return NS_OK; + } + + NS_ConvertUTF16toUTF8 fontname(aFontName); + + if (mFonts.IndexOf(fontname) >= 0) { + aFamilyName.Assign(aFontName); + return NS_OK; + } + + if (mNonExistingFonts.IndexOf(fontname) >= 0) + return NS_OK; + + FcPattern *pat = NULL; + FcObjectSet *os = NULL; + FcFontSet *givenFS = NULL; + nsCStringArray candidates; + FcFontSet *candidateFS = NULL; + nsresult rv = NS_ERROR_FAILURE; + + pat = FcPatternCreate(); + if (!pat) + goto end; + + FcPatternAddString(pat, FC_FAMILY, (FcChar8 *)fontname.get()); + + os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_INDEX, NULL); + if (!os) + goto end; + + givenFS = FcFontList(NULL, pat, os); + if (!givenFS) + goto end; + + // The first value associated with a FC_FAMILY property is the family + // returned by GetFontList(), so use this value if appropriate. + + // See if there is a font face with first family equal to the given family. + for (int i = 0; i < givenFS->nfont; ++i) { + char *firstFamily; + if (FcPatternGetString(givenFS->fonts[i], FC_FAMILY, 0, + (FcChar8 **) &firstFamily) != FcResultMatch) + continue; + + nsDependentCString first(firstFamily); + if (candidates.IndexOf(first) < 0) { + candidates.AppendCString(first); + + if (fontname.Equals(first)) { + aFamilyName.Assign(aFontName); + rv = NS_OK; + goto end; + } + } + } + + // See if any of the first family names represent the same set of font + // faces as the given family. + for (PRInt32 j = 0; j < candidates.Count(); ++j) { + FcPatternDel(pat, FC_FAMILY); + FcPatternAddString(pat, FC_FAMILY, (FcChar8 *)candidates[j]->get()); + + candidateFS = FcFontList(NULL, pat, os); + if (!candidateFS) + goto end; + + if (candidateFS->nfont != givenFS->nfont) + continue; + + PRBool equal = PR_TRUE; + for (int i = 0; i < givenFS->nfont; ++i) { + if (!FcPatternEqual(candidateFS->fonts[i], givenFS->fonts[i])) { + equal = PR_FALSE; + break; + } + } + if (equal) { + AppendUTF8toUTF16(*candidates[j], aFamilyName); + rv = NS_OK; + goto end; + } + } + + // No match found; return empty string. + rv = NS_OK; + + end: + if (pat) + FcPatternDestroy(pat); + if (os) + FcObjectSetDestroy(os); + if (givenFS) + FcFontSetDestroy(givenFS); + if (candidateFS) + FcFontSetDestroy(candidateFS); + + return rv; +} + nsresult gfxFontconfigUtils::ResolveFontName(const nsAString& aFontName, gfxPlatform::FontResolverCallback aCallback, diff --git a/mozilla/gfx/thebes/src/gfxFontconfigUtils.h b/mozilla/gfx/thebes/src/gfxFontconfigUtils.h index f716eed63e6..20e823ce020 100755 --- a/mozilla/gfx/thebes/src/gfxFontconfigUtils.h +++ b/mozilla/gfx/thebes/src/gfxFontconfigUtils.h @@ -75,6 +75,8 @@ public: gfxPlatform::FontResolverCallback aCallback, void *aClosure, PRBool& aAborted); + nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName); + protected: static gfxFontconfigUtils* sUtils; diff --git a/mozilla/gfx/thebes/src/gfxOS2Platform.cpp b/mozilla/gfx/thebes/src/gfxOS2Platform.cpp index b34e96235cd..a896a925a8f 100644 --- a/mozilla/gfx/thebes/src/gfxOS2Platform.cpp +++ b/mozilla/gfx/thebes/src/gfxOS2Platform.cpp @@ -147,6 +147,12 @@ gfxOS2Platform::ResolveFontName(const nsAString& aFontName, //return NS_OK; } +nsresult +gfxOS2Platform::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName) +{ + return sFontconfigUtils->GetStandardFamilyName(aFontName, aFamilyName); +} + gfxFontGroup * gfxOS2Platform::CreateFontGroup(const nsAString &aFamilies, const gfxFontStyle *aStyle) diff --git a/mozilla/gfx/thebes/src/gfxPlatformGtk.cpp b/mozilla/gfx/thebes/src/gfxPlatformGtk.cpp index 563e0ef76ba..39e09e74d24 100644 --- a/mozilla/gfx/thebes/src/gfxPlatformGtk.cpp +++ b/mozilla/gfx/thebes/src/gfxPlatformGtk.cpp @@ -253,6 +253,12 @@ gfxPlatformGtk::ResolveFontName(const nsAString& aFontName, aClosure, aAborted); } +nsresult +gfxPlatformGtk::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName) +{ + return sFontconfigUtils->GetStandardFamilyName(aFontName, aFamilyName); +} + gfxFontGroup * gfxPlatformGtk::CreateFontGroup(const nsAString &aFamilies, const gfxFontStyle *aStyle) diff --git a/mozilla/gfx/thebes/src/gfxPlatformMac.cpp b/mozilla/gfx/thebes/src/gfxPlatformMac.cpp index 1398ef7fa6a..9729ec879e3 100644 --- a/mozilla/gfx/thebes/src/gfxPlatformMac.cpp +++ b/mozilla/gfx/thebes/src/gfxPlatformMac.cpp @@ -180,6 +180,13 @@ gfxPlatformMac::ResolveFontName(const nsAString& aFontName, return NS_OK; } +nsresult +gfxPlatformMac::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName) +{ + gfxQuartzFontCache::SharedFontCache()->GetStandardFamilyName(aFontName, aFamilyName); + return NS_OK; +} + gfxFontGroup * gfxPlatformMac::CreateFontGroup(const nsAString &aFamilies, const gfxFontStyle *aStyle) diff --git a/mozilla/gfx/thebes/src/gfxQuartzFontCache.h b/mozilla/gfx/thebes/src/gfxQuartzFontCache.h index 350e96b4160..d52e7751037 100644 --- a/mozilla/gfx/thebes/src/gfxQuartzFontCache.h +++ b/mozilla/gfx/thebes/src/gfxQuartzFontCache.h @@ -128,7 +128,7 @@ public: virtual ~MacOSFamilyEntry() {} const nsString& Name() { return mName; } - virtual void LocalizedName(nsString& aLocalizedName); + virtual void LocalizedName(nsAString& aLocalizedName); virtual PRBool HasOtherFamilyNames(); nsTArray >& GetFontList() { return mAvailableFonts; } @@ -182,7 +182,7 @@ public: virtual ~SingleFaceFamily() {} - virtual void LocalizedName(nsString& aLocalizedName); + virtual void LocalizedName(nsAString& aLocalizedName); // read in other family names, if any, and use functor to add each into cache virtual void ReadOtherFamilyNames(AddOtherFamilyNameFunctor& aOtherFamilyFunctor); @@ -213,6 +213,7 @@ public: nsStringArray& aListOfFonts); PRBool ResolveFontName(const nsAString& aFontName, nsAString& aResolvedFontName); + PRBool GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName); void UpdateFontList() { InitFontList(); } diff --git a/mozilla/gfx/thebes/src/gfxQuartzFontCache.mm b/mozilla/gfx/thebes/src/gfxQuartzFontCache.mm index 0f018836d76..8cdcc27b44d 100644 --- a/mozilla/gfx/thebes/src/gfxQuartzFontCache.mm +++ b/mozilla/gfx/thebes/src/gfxQuartzFontCache.mm @@ -256,7 +256,7 @@ public: gfxQuartzFontCache *mFontCache; }; -void MacOSFamilyEntry::LocalizedName(nsString& aLocalizedName) +void MacOSFamilyEntry::LocalizedName(nsAString& aLocalizedName) { // no other names ==> only one name, just return it if (!HasOtherFamilyNames()) { @@ -656,7 +656,7 @@ MacOSFamilyEntry::ReadOtherFamilyNames(AddOtherFamilyNameFunctor& aOtherFamilyFu /* SingleFaceFamily */ #pragma mark- -void SingleFaceFamily::LocalizedName(nsString& aLocalizedName) +void SingleFaceFamily::LocalizedName(nsAString& aLocalizedName) { MacOSFontEntry *fontEntry; @@ -973,6 +973,57 @@ gfxQuartzFontCache::ResolveFontName(const nsAString& aFontName, nsAString& aReso return PR_FALSE; } +PRBool +gfxQuartzFontCache::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName) +{ + MacOSFamilyEntry *family = FindFamily(aFontName); + if (family) { + family->LocalizedName(aFamilyName); + return PR_TRUE; + } + + // Gecko 1.8 used Quickdraw font api's which produce a slightly different set of "family" + // names. Try to resolve based on these names, in case this is stored in an old profile + // 1.8: "Futura", "Futura Condensed" ==> 1.9: "Futura + FMFont fmFont; + + // convert of a NSString + NSString *fontName = GetNSStringForString(aFontName); + + // name ==> family id ==> old-style FMFont + ATSFontFamilyRef fmFontFamily = ATSFontFamilyFindFromName((CFStringRef)fontName, kATSOptionFlagsDefault); + OSStatus err = FMGetFontFromFontFamilyInstance(fmFontFamily, 0, &fmFont, nsnull); + if (err != noErr || fmFont == kInvalidFont) + return PR_FALSE; + + ATSFontRef atsFont = FMGetATSFontRefFromFont(fmFont); + if (!atsFont) + return PR_FALSE; + + NSString *psname; + + // now lookup the Postscript name + err = ATSFontGetPostScriptName(atsFont, kATSOptionFlagsDefault, (CFStringRef*) (&psname)); + if (err != noErr) + return PR_FALSE; + + // given an NSFont instance, Cocoa api's return the canonical family name + NSString *canonicalfamily = [[NSFont fontWithName:psname size:0.0] familyName]; + [psname release]; + + nsAutoString familyName; + + // lookup again using the canonical family name + GetStringForNSString(canonicalfamily, familyName); + family = FindFamily(familyName); + if (family) { + family->LocalizedName(aFamilyName); + return PR_TRUE; + } + + return PR_FALSE; +} + void gfxQuartzFontCache::ATSNotification(ATSFontNotificationInfoRef aInfo, void* aUserArg) diff --git a/mozilla/gfx/thebes/src/gfxWindowsPlatform.cpp b/mozilla/gfx/thebes/src/gfxWindowsPlatform.cpp index 0697edd1fb9..e75951fe074 100644 --- a/mozilla/gfx/thebes/src/gfxWindowsPlatform.cpp +++ b/mozilla/gfx/thebes/src/gfxWindowsPlatform.cpp @@ -395,6 +395,14 @@ gfxWindowsPlatform::InitBadUnderlineList() } } +nsresult +gfxWindowsPlatform::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName) +{ + aFamilyName.Truncate(); + PRBool aborted; + return ResolveFontName(aFontName, SimpleResolverCallback, &aFamilyName, aborted); +} + struct ResolveData { ResolveData(gfxPlatform::FontResolverCallback aCallback, gfxWindowsPlatform *aCaller, const nsAString *aFontName, diff --git a/mozilla/mail/components/preferences/fonts.js b/mozilla/mail/components/preferences/fonts.js index 5060430482a..1b3d9aa7251 100644 --- a/mozilla/mail/components/preferences/fonts.js +++ b/mozilla/mail/components/preferences/fonts.js @@ -58,16 +58,16 @@ var gFontsDialog = { _selectLanguageGroup: function (aLanguageGroup) { - var prefs = [{ format: kDefaultFontType, type: "string", element: "defaultFontType", fonttype: null}, - { format: kFontNameFmtSerif, type: "unichar", element: "serif", fonttype: "serif" }, - { format: kFontNameFmtSansSerif, type: "unichar", element: "sans-serif", fonttype: "sans-serif" }, - { format: kFontNameFmtMonospace, type: "unichar", element: "monospace", fonttype: "monospace" }, - { format: kFontNameListFmtSerif, type: "unichar", element: null, fonttype: "serif" }, - { format: kFontNameListFmtSansSerif, type: "unichar", element: null, fonttype: "sans-serif" }, - { format: kFontNameListFmtMonospace, type: "unichar", element: null, fonttype: "monospace" }, - { format: kFontSizeFmtVariable, type: "int", element: "sizeVar", fonttype: null }, - { format: kFontSizeFmtFixed, type: "int", element: "sizeMono", fonttype: null }, - { format: kFontMinSizeFmt, type: "int", element: "minSize", fonttype: null }]; + var prefs = [{ format: kDefaultFontType, type: "string", element: "defaultFontType", fonttype: null}, + { format: kFontNameFmtSerif, type: "fontname", element: "serif", fonttype: "serif" }, + { format: kFontNameFmtSansSerif, type: "fontname", element: "sans-serif", fonttype: "sans-serif" }, + { format: kFontNameFmtMonospace, type: "fontname", element: "monospace", fonttype: "monospace" }, + { format: kFontNameListFmtSerif, type: "unichar", element: null, fonttype: "serif" }, + { format: kFontNameListFmtSansSerif, type: "unichar", element: null, fonttype: "sans-serif" }, + { format: kFontNameListFmtMonospace, type: "unichar", element: null, fonttype: "monospace" }, + { format: kFontSizeFmtVariable, type: "int", element: "sizeVar", fonttype: null }, + { format: kFontSizeFmtFixed, type: "int", element: "sizeMono", fonttype: null }, + { format: kFontMinSizeFmt, type: "int", element: "minSize", fonttype: null }]; var preferences = document.getElementById("fontPreferences"); for (var i = 0; i < prefs.length; ++i) { var preference = document.getElementById(prefs[i].format.replace(/%LANG%/, aLanguageGroup)); diff --git a/mozilla/toolkit/content/widgets/preferences.xml b/mozilla/toolkit/content/widgets/preferences.xml index 2d4d55863f8..6137fd9e818 100644 --- a/mozilla/toolkit/content/widgets/preferences.xml +++ b/mozilla/toolkit/content/widgets/preferences.xml @@ -293,6 +293,11 @@ return this._branch .getComplexValue(this.name, Components.interfaces.nsISupportsString) .data; + case "fontname": + var family = this._branch + .getComplexValue(this.name, Components.interfaces.nsISupportsString) + .data; + return FontBuilder.enumerator.getStandardFamilyName(family); case "file": var f = this._branch .getComplexValue(this.name, Components.interfaces.nsILocalFile); @@ -327,6 +332,7 @@ break; case "string": case "unichar": + case "fontname": var iss = Components.classes["@mozilla.org/supports-string;1"] .createInstance(Components.interfaces.nsISupportsString); iss.data = val; diff --git a/mozilla/toolkit/mozapps/preferences/fontbuilder.js b/mozilla/toolkit/mozapps/preferences/fontbuilder.js index d8d599a6ec4..d421f0fdc9a 100644 --- a/mozilla/toolkit/mozapps/preferences/fontbuilder.js +++ b/mozilla/toolkit/mozapps/preferences/fontbuilder.js @@ -116,5 +116,18 @@ var FontBuilder = { } } aMenuList.appendChild(popup); + }, + + getStandardFamilyName: function (aName) + { + // XXX should return empty string on failure? + try { + var family = this.enumerator.getStandardFamilyName(aName); + if (!family) + return aName; + return family; + } catch (e) { + return aName; + } } };