From 3095ee414e872e0f8c864b1796429a72c6965955 Mon Sep 17 00:00:00 2001 From: "philringnalda@gmail.com" Date: Sun, 26 Aug 2007 14:34:03 -0700 Subject: [PATCH] Bug 379886 - Font preferences panel selects random fonts in cairo builds, patch by Karl Tomlinson , r+sr=vlad/pavlov --- gfx/thebes/src/gfxFontconfigUtils.cpp | 20 ++++++++++-------- modules/libpref/src/init/all.js | 30 +++++++++++++-------------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/gfx/thebes/src/gfxFontconfigUtils.cpp b/gfx/thebes/src/gfxFontconfigUtils.cpp index a11b5716783..7d8091edfd0 100755 --- a/gfx/thebes/src/gfxFontconfigUtils.cpp +++ b/gfx/thebes/src/gfxFontconfigUtils.cpp @@ -78,7 +78,9 @@ gfxFontconfigUtils::GetFontList(const nsACString& aLangGroup, for (PRInt32 i = 0; i < fonts->Count(); ++i) aListOfFonts.AppendString(NS_ConvertUTF8toUTF16(*fonts->CStringAt(i))); - PRInt32 serif = 0, sansSerif = 0, monospace = 0, nGenerics; + aListOfFonts.Sort(); + + PRInt32 serif = 0, sansSerif = 0, monospace = 0; // Fontconfig supports 3 generic fonts, "serif", "sans-serif", and // "monospace", slightly different from CSS's 5. @@ -95,16 +97,16 @@ gfxFontconfigUtils::GetFontList(const nsACString& aLangGroup, serif = sansSerif = 1; else NS_NOTREACHED("unexpected CSS generic font family"); - nGenerics = serif + sansSerif + monospace; - if (serif) - aListOfFonts.AppendString(NS_LITERAL_STRING("serif")); - if (sansSerif) - aListOfFonts.AppendString(NS_LITERAL_STRING("sans-serif")); + // The first in the list becomes the default in + // gFontsDialog.readFontSelection() if the preference-selected font is not + // available, so put system configured defaults first. if (monospace) - aListOfFonts.AppendString(NS_LITERAL_STRING("monospace")); - - aListOfFonts.Sort(); + aListOfFonts.InsertStringAt(NS_LITERAL_STRING("monospace"), 0); + if (sansSerif) + aListOfFonts.InsertStringAt(NS_LITERAL_STRING("sans-serif"), 0); + if (serif) + aListOfFonts.InsertStringAt(NS_LITERAL_STRING("serif"), 0); return NS_OK; } diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 8e6e3142737..82bb4cba061 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -2057,33 +2057,33 @@ pref("font.name.monospace.ko", "monospace"); // th -pref("font.name.serif.tr", "Times"); -pref("font.name.sans-serif.tr", "Helvetica"); -pref("font.name.monospace.tr", "Courier"); +pref("font.name.serif.tr", "serif"); +pref("font.name.sans-serif.tr", "sans-serif"); +pref("font.name.monospace.tr", "monospace"); pref("font.name.serif.x-baltic", "serif"); pref("font.name.sans-serif.x-baltic", "sans-serif"); pref("font.name.monospace.x-baltic", "monospace"); -pref("font.name.serif.x-central-euro", "Times"); -pref("font.name.sans-serif.x-central-euro", "Helvetica"); -pref("font.name.monospace.x-central-euro", "Courier"); +pref("font.name.serif.x-central-euro", "serif"); +pref("font.name.sans-serif.x-central-euro", "sans-serif"); +pref("font.name.monospace.x-central-euro", "monospace"); pref("font.name.serif.x-cyrillic", "serif"); pref("font.name.sans-serif.x-cyrillic", "sans-serif"); pref("font.name.monospace.x-cyrillic", "monospace"); -pref("font.name.serif.x-unicode", "Times"); -pref("font.name.sans-serif.x-unicode", "Helvetica"); -pref("font.name.monospace.x-unicode", "Courier"); +pref("font.name.serif.x-unicode", "serif"); +pref("font.name.sans-serif.x-unicode", "sans-serif"); +pref("font.name.monospace.x-unicode", "monospace"); -pref("font.name.serif.x-user-def", "Times"); -pref("font.name.sans-serif.x-user-def", "Helvetica"); -pref("font.name.monospace.x-user-def", "Courier"); +pref("font.name.serif.x-user-def", "serif"); +pref("font.name.sans-serif.x-user-def", "sans-serif"); +pref("font.name.monospace.x-user-def", "monospace"); -pref("font.name.serif.x-western", "Times"); -pref("font.name.sans-serif.x-western", "Helvetica"); -pref("font.name.monospace.x-western", "Courier"); +pref("font.name.serif.x-western", "serif"); +pref("font.name.sans-serif.x-western", "sans-serif"); +pref("font.name.monospace.x-western", "monospace"); pref("font.name.serif.zh-CN", "serif"); pref("font.name.sans-serif.zh-CN", "sans-serif");