diff --git a/gfx/thebes/public/gfxPlatformMac.h b/gfx/thebes/public/gfxPlatformMac.h index 5c6db4af404a..eb210cfb93e4 100644 --- a/gfx/thebes/public/gfxPlatformMac.h +++ b/gfx/thebes/public/gfxPlatformMac.h @@ -57,6 +57,10 @@ public: FontResolverCallback aCallback, void *aClosure, PRBool& aAborted); + + nsresult GetFontList(const nsACString& aLangGroup, + const nsACString& aGenericFamily, + nsStringArray& aListOfFonts); }; #endif /* GFX_PLATFORM_MAC_H */ diff --git a/gfx/thebes/src/gfxPlatformMac.cpp b/gfx/thebes/src/gfxPlatformMac.cpp index df4bbc9192cd..f7a61670af14 100644 --- a/gfx/thebes/src/gfxPlatformMac.cpp +++ b/gfx/thebes/src/gfxPlatformMac.cpp @@ -41,6 +41,8 @@ #include "gfxImageSurface.h" #include "gfxQuartzSurface.h" +#include "gfxQuartzFontCache.h" + #ifdef MOZ_ENABLE_GLITZ #include "gfxGlitzSurface.h" #include "glitz-agl.h" @@ -144,3 +146,11 @@ gfxPlatformMac::ResolveFontName(const nsAString& aFontName, return NS_OK; } +nsresult +gfxPlatformMac::GetFontList(const nsACString& aLangGroup, + const nsACString& aGenericFamily, + nsStringArray& aListOfFonts) +{ + gfxQuartzFontCache::SharedFontCache()->GetFontList(aLangGroup, aGenericFamily, aListOfFonts); + return NS_OK; +} diff --git a/gfx/thebes/src/gfxQuartzFontCache.h b/gfx/thebes/src/gfxQuartzFontCache.h index 816af3a6c838..271a53abd8c5 100644 --- a/gfx/thebes/src/gfxQuartzFontCache.h +++ b/gfx/thebes/src/gfxQuartzFontCache.h @@ -43,6 +43,7 @@ #include "gfxAtsuiFonts.h" #include "nsUnicharUtils.h" +#include "nsVoidArray.h" class gfxQuartzFontCache { public: @@ -57,6 +58,9 @@ public: ATSUFontID GetDefaultATSUFontID (const gfxFontStyle* aStyle); + void GetFontList (const nsACString& aLangGroup, + const nsACString& aGenericFamily, + nsStringArray& aListOfFonts); private: static gfxQuartzFontCache *sSharedFontCache; diff --git a/gfx/thebes/src/gfxQuartzFontCache.mm b/gfx/thebes/src/gfxQuartzFontCache.mm index 349da22fd3b0..596b78d56108 100644 --- a/gfx/thebes/src/gfxQuartzFontCache.mm +++ b/gfx/thebes/src/gfxQuartzFontCache.mm @@ -389,3 +389,24 @@ gfxQuartzFontCache::GetDefaultATSUFontID (const gfxFontStyle* aStyle) { return [[NSFont userFontOfSize:aStyle->size] _atsFontID]; } + +void +gfxQuartzFontCache::GetFontList (const nsACString& aLangGroup, + const nsACString& aGenericFamily, + nsStringArray& aListOfFonts) +{ + NSFontManager *fontManager = [NSFontManager sharedFontManager]; + NSArray *familyArray = [fontManager availableFontFamilies]; + + unsigned int nFamilies = [familyArray count]; + for (unsigned int i = 0; i < nFamilies; i++) { + NSString *family = [familyArray objectAtIndex:i]; + nsString str; + str.SetLength([family length]); + [family getCharacters:(str.BeginWriting())]; + aListOfFonts.AppendString(str); + } + + aListOfFonts.Sort(); +} +