Bug 1283573 - Don't attempt to look up a single-face-family name if the corresponding main family isn't available. r=mstange a=lizzard
authorJonathan Kew <jkew@mozilla.com>
Thu, 30 Jun 2016 20:03:15 +0100
changeset 333662 0968b5fb96974b862d6901f9250644d8e478a30f
parent 333661 306382512096564f06aa175ddddeef59a90f36f0
child 333663 36faf180f49d6e6af84f55231052b1bac85b3bcd
push id6213
push userjkew@mozilla.com
push dateThu, 14 Jul 2016 16:42:21 +0000
treeherdermozilla-beta@0968b5fb9697 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, lizzard
bugs1283573
milestone48.0
Bug 1283573 - Don't attempt to look up a single-face-family name if the corresponding main family isn't available. r=mstange a=lizzard
gfx/thebes/gfxMacPlatformFontList.mm
modules/libpref/init/all.js
--- a/gfx/thebes/gfxMacPlatformFontList.mm
+++ b/gfx/thebes/gfxMacPlatformFontList.mm
@@ -726,22 +726,31 @@ gfxMacPlatformFontList::InitSingleFaceLi
 {
     AutoTArray<nsString, 10> singleFaceFonts;
     gfxFontUtils::GetPrefsFontList("font.single-face-list", singleFaceFonts);
 
     uint32_t numFonts = singleFaceFonts.Length();
     for (uint32_t i = 0; i < numFonts; i++) {
         LOG_FONTLIST(("(fontlist-singleface) face name: %s\n",
                       NS_ConvertUTF16toUTF8(singleFaceFonts[i]).get()));
-        gfxFontEntry *fontEntry = LookupLocalFont(singleFaceFonts[i],
+        nsAutoString familyName(singleFaceFonts[i]);
+        auto colon = familyName.FindChar(':');
+        if (colon != kNotFound) {
+            nsAutoString key(Substring(familyName, colon + 1));
+            ToLowerCase(key);
+            if (!mFontFamilies.GetWeak(key)) {
+                continue;
+            }
+            familyName.Truncate(colon);
+        }
+        gfxFontEntry *fontEntry = LookupLocalFont(familyName,
                                                   400, 0,
                                                   NS_FONT_STYLE_NORMAL);
         if (fontEntry) {
-            nsAutoString familyName, key;
-            familyName = singleFaceFonts[i];
+            nsAutoString key;
             GenerateFontListKey(familyName, key);
             LOG_FONTLIST(("(fontlist-singleface) family name: %s, key: %s\n",
                           NS_ConvertUTF16toUTF8(familyName).get(),
                           NS_ConvertUTF16toUTF8(key).get()));
 
             // add only if doesn't exist already
             if (!mFontFamilies.GetWeak(key)) {
                 gfxFontFamily *familyEntry =
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -3673,19 +3673,19 @@ pref("font.size.variable.zh-TW", 15);
 pref("font.name.serif.x-math", "Latin Modern Math");
 // Apple's Symbol is Unicode so use it
 pref("font.name-list.serif.x-math", "Latin Modern Math, XITS Math, Cambria Math, TeX Gyre Bonum Math, TeX Gyre Pagella Math, TeX Gyre Schola, TeX Gyre Termes Math, STIX Math, Asana Math, STIXGeneral, DejaVu Serif, DejaVu Sans, Symbol, Times");
 pref("font.name.sans-serif.x-math", "Helvetica");
 pref("font.name.monospace.x-math", "Courier");
 pref("font.name.cursive.x-math", "Apple Chancery");
 pref("font.name.fantasy.x-math", "Papyrus");
 
-// individual font faces to be treated as independent families
-// names are Postscript names of each face
-pref("font.single-face-list", "Osaka-Mono");
+// Individual font faces to be treated as independent families,
+// listed as <Postscript name of face:Owning family name>
+pref("font.single-face-list", "Osaka-Mono:Osaka");
 
 // optimization hint for fonts with localized names to be read in at startup, otherwise read in at lookup miss
 // names are canonical family names (typically English names)
 pref("font.preload-names-list", "Hiragino Kaku Gothic ProN,Hiragino Mincho ProN,STSong");
 
 // Override font-weight values for some problematic families Apple ships
 // (see bug 931426).
 // The name here is the font's PostScript name, which can be checked in