Bug 1197717 - Load fonts from profile-agnostic writable location. r=jfkthame

In addition to the system's font folder and the profile folder we will try to load
fonts from NS_XPCOM_CURRENT_PROCESS_DIR/fonts. This will allow us to later
download fonts at runtime and use them independently from the current profile.

--HG--
extra : commitid : XencMwkyLl
extra : rebase_source : b0e0eca9dc745ce0bae167ce329a148b03416829
This commit is contained in:
Sebastian Kaspari 2015-09-22 15:55:56 +02:00
parent b531a8c7a6
commit 2e0c208b14

View File

@ -1205,6 +1205,22 @@ gfxFT2FontList::FindFonts()
FindFontsInOmnijar(&fnc);
}
// Look for downloaded fonts in a profile-agnostic "fonts" directory.
nsCOMPtr<nsIProperties> dirSvc =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
if (dirSvc) {
nsCOMPtr<nsIFile> appDir;
nsresult rv = dirSvc->Get(NS_XPCOM_CURRENT_PROCESS_DIR,
NS_GET_IID(nsIFile), getter_AddRefs(appDir));
if (NS_SUCCEEDED(rv)) {
appDir->AppendNative(NS_LITERAL_CSTRING("fonts"));
nsCString localPath;
if (NS_SUCCEEDED(appDir->GetNativePath(localPath))) {
FindFontsInDir(localPath, &fnc, FT2FontFamily::kVisible);
}
}
}
// look for locally-added fonts in a "fonts" subdir of the profile
nsCOMPtr<nsIFile> localDir;
nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_LOCAL_50_DIR,