bug 785291 - Add support to load fonts from an APK, search for fonts in res/fonts r=jfkthame
authorBrad Lassey <blassey@mozilla.com>
Wed, 03 Oct 2012 12:28:43 -0700
changeset 109220 5a788605acfe681ddd81ba4b479b6e4b5abdc4b6
parent 109219 5542e7d206769430dba9aca41bac4341d75fd05a
child 109221 d7ff5aecff0cac27d52091067d6b51643baee4c2
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersjfkthame
bugs785291
milestone18.0a1
bug 785291 - Add support to load fonts from an APK, search for fonts in res/fonts r=jfkthame
gfx/thebes/gfxFT2FontList.cpp
--- a/gfx/thebes/gfxFT2FontList.cpp
+++ b/gfx/thebes/gfxFT2FontList.cpp
@@ -939,28 +939,39 @@ gfxFT2FontList::FindFonts()
 
     FindFontsInDir(root, &fnc);
 
     if (mFontFamilies.Count() == 0) {
         // if we can't find/read the font directory, we are doomed!
         NS_RUNTIMEABORT("Could not read the system fonts directory");
     }
 
-    // look for locally-added fonts in the profile
+    // look for fonts shipped with the product
     nsCOMPtr<nsIFile> localDir;
-    nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_LOCAL_50_DIR,
+    nsresult rv = NS_GetSpecialDirectory(NS_APP_RES_DIR,
                                          getter_AddRefs(localDir));
     if (NS_SUCCEEDED(rv)) {
         nsCString localPath;
         rv = localDir->GetNativePath(localPath);
         if (NS_SUCCEEDED(rv)) {
             FindFontsInDir(localPath, &fnc);
         }
     }
 
+    // look for locally-added fonts in the profile
+    rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_LOCAL_50_DIR,
+                                getter_AddRefs(localDir));
+    if (NS_SUCCEEDED(rv)) {
+        nsCString localPath;
+        rv = localDir->GetNativePath(localPath);
+        if (NS_SUCCEEDED(rv)) {
+            FindFontsInDir(localPath, &fnc);
+        }
+    }
+
     // Finalize the families by sorting faces into standard order
     // and marking "simple" families.
     // Passing non-null userData here says that we want faces to be sorted.
     mFontFamilies.Enumerate(FinalizeFamilyMemberList, this);
 #endif // XP_WIN && ANDROID
 }
 
 #ifdef ANDROID