diff --git a/gfx/thebes/gfxGDIFontList.cpp b/gfx/thebes/gfxGDIFontList.cpp index 7b29a6b043c0..5418e4d9dc6b 100644 --- a/gfx/thebes/gfxGDIFontList.cpp +++ b/gfx/thebes/gfxGDIFontList.cpp @@ -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 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 e; + rv = localDir->GetDirectoryEntries(getter_AddRefs(e)); + if (NS_FAILED(rv)) { + return; + } + + bool hasMore; + while (NS_SUCCEEDED(e->HasMoreElements(&hasMore)) && hasMore) { + nsCOMPtr entry; + if (NS_FAILED(e->GetNext(getter_AddRefs(entry)))) { + break; + } + nsCOMPtr file = do_QueryInterface(entry); + if (!file) { + continue; + } + nsCString path; + if (NS_FAILED(file->GetNativePath(path))) { + continue; + } + AddFontResourceEx(path.get(), FR_PRIVATE, nullptr); + } +} + +#endif diff --git a/gfx/thebes/gfxGDIFontList.h b/gfx/thebes/gfxGDIFontList.h index 05cee1119e16..f27e277b6a2a 100644 --- a/gfx/thebes/gfxGDIFontList.h +++ b/gfx/thebes/gfxGDIFontList.h @@ -341,6 +341,10 @@ private: virtual already_AddRefed CreateFontInfoData(); +#ifdef MOZ_BUNDLED_FONTS + void ActivateBundledFonts(); +#endif + typedef nsRefPtrHashtable FontTable; FontTable mFontSubstitutes;