void gfxPlatformFontList::GetFontList(nsIAtom *aLangGroup, const nsACString& aGenericFamily, nsTArray<nsString>& aListOfFonts) { for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) { nsRefPtr<gfxFontFamily>& family = iter.Data(); // use the first variation for now. This data should be the same // for all the variations and should probably be moved up to // the Family gfxFontStyle style; style.language = aLangGroup; bool needsBold; nsRefPtr<gfxFontEntry> fontEntry = family->FindFontForStyle(style, needsBold); NS_ASSERTION(fontEntry, "couldn't find any font entry in family"); if (!fontEntry) { continue; } /* skip symbol fonts */ if (fontEntry->IsSymbolFont()) { continue; } if (fontEntry->SupportsLangGroup(aLangGroup) && fontEntry->MatchesGenericFamily(aGenericFamily)) { nsAutoString localizedFamilyName; family->LocalizedName(localizedFamilyName); aListOfFonts.AppendElement(localizedFamilyName); } } aListOfFonts.Sort(); aListOfFonts.Compact(); }
void gfxPlatformFontList::GetFontList(nsIAtom *aLangGroup, const nsACString& aGenericFamily, nsTArray<nsString>& aListOfFonts) { FontListData data(aLangGroup, aGenericFamily, aListOfFonts); mFontFamilies.Enumerate(gfxPlatformFontList::HashEnumFuncForFamilies, &data); aListOfFonts.Sort(); aListOfFonts.Compact(); }
nsresult gfxAndroidPlatform::GetFontList(nsIAtom *aLangGroup, const nsACString& aGenericFamily, nsTArray<nsString>& aListOfFonts) { FontListData data(aLangGroup, aGenericFamily, aListOfFonts); mFonts.Enumerate(FontListHashEnumFunc, &data); aListOfFonts.Sort(); aListOfFonts.Compact(); return NS_OK; }
template<class T> static void DoDeferredRelease(nsTArray<T> &array) { while(1) { PRUint32 count = array.Length(); if(!count) { array.Compact(); break; } T wrapper = array[count-1]; array.RemoveElementAt(count-1); NS_RELEASE(wrapper); } }