зеркало из https://github.com/mozilla/gecko-dev.git
bug 998844 - part 3 - support bundled fonts on Windows/GDI. r=jdaggett
This commit is contained in:
Родитель
d132b2c66f
Коммит
7d9c5700f4
|
@ -574,6 +574,9 @@ GDIFontFamily::FindStyleVariations(FontInfoData *aFontInfoData)
|
|||
gfxGDIFontList::gfxGDIFontList()
|
||||
: mFontSubstitutes(50)
|
||||
{
|
||||
#ifdef MOZ_BUNDLED_FONTS
|
||||
ActivateBundledFonts();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1092,3 +1095,47 @@ gfxGDIFontList::CreateFontInfoData()
|
|||
|
||||
return fi.forget();
|
||||
}
|
||||
|
||||
#ifdef MOZ_BUNDLED_FONTS
|
||||
|
||||
void
|
||||
gfxGDIFontList::ActivateBundledFonts()
|
||||
{
|
||||
nsCOMPtr<nsIFile> localDir;
|
||||
nsresult rv = NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(localDir));
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
if (NS_FAILED(localDir->Append(NS_LITERAL_STRING("fonts")))) {
|
||||
return;
|
||||
}
|
||||
bool isDir;
|
||||
if (NS_FAILED(localDir->IsDirectory(&isDir)) || !isDir) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> e;
|
||||
rv = localDir->GetDirectoryEntries(getter_AddRefs(e));
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED(e->HasMoreElements(&hasMore)) && hasMore) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
if (NS_FAILED(e->GetNext(getter_AddRefs(entry)))) {
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
|
||||
if (!file) {
|
||||
continue;
|
||||
}
|
||||
nsCString path;
|
||||
if (NS_FAILED(file->GetNativePath(path))) {
|
||||
continue;
|
||||
}
|
||||
AddFontResourceEx(path.get(), FR_PRIVATE, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -341,6 +341,10 @@ private:
|
|||
|
||||
virtual already_AddRefed<FontInfoData> CreateFontInfoData();
|
||||
|
||||
#ifdef MOZ_BUNDLED_FONTS
|
||||
void ActivateBundledFonts();
|
||||
#endif
|
||||
|
||||
typedef nsRefPtrHashtable<nsStringHashKey, gfxFontFamily> FontTable;
|
||||
|
||||
FontTable mFontSubstitutes;
|
||||
|
|
Загрузка…
Ссылка в новой задаче