diff --git a/gfx/thebes/src/gfxPlatformMac.cpp b/gfx/thebes/src/gfxPlatformMac.cpp index b320a84c70f0..037421be4d4d 100644 --- a/gfx/thebes/src/gfxPlatformMac.cpp +++ b/gfx/thebes/src/gfxPlatformMac.cpp @@ -127,7 +127,8 @@ gfxFontEntry* gfxPlatformMac::LookupLocalFont(const gfxProxyFontEntry *aProxyEntry, const nsAString& aFontName) { - return gfxQuartzFontCache::SharedFontCache()->LookupLocalFont(aFontName); + return gfxQuartzFontCache::SharedFontCache()->LookupLocalFont(aProxyEntry, + aFontName); } gfxFontEntry* diff --git a/gfx/thebes/src/gfxQuartzFontCache.h b/gfx/thebes/src/gfxQuartzFontCache.h index fe042e6399ff..012e14653c0f 100644 --- a/gfx/thebes/src/gfxQuartzFontCache.h +++ b/gfx/thebes/src/gfxQuartzFontCache.h @@ -234,7 +234,8 @@ public: void AddOtherFamilyName(MacOSFamilyEntry *aFamilyEntry, nsAString& aOtherFamilyName); - gfxFontEntry* LookupLocalFont(const nsAString& aFontName); + gfxFontEntry* LookupLocalFont(const gfxProxyFontEntry *aProxyEntry, + const nsAString& aFontName); gfxFontEntry* MakePlatformFont(const gfxFontEntry *aProxyEntry, const PRUint8 *aFontData, PRUint32 aLength); diff --git a/gfx/thebes/src/gfxQuartzFontCache.mm b/gfx/thebes/src/gfxQuartzFontCache.mm index 2cb738bb33fd..6ce185a0fb27 100644 --- a/gfx/thebes/src/gfxQuartzFontCache.mm +++ b/gfx/thebes/src/gfxQuartzFontCache.mm @@ -1289,25 +1289,37 @@ gfxQuartzFontCache::AddOtherFamilyName(MacOSFamilyEntry *aFamilyEntry, nsAString } gfxFontEntry* -gfxQuartzFontCache::LookupLocalFont(const nsAString& aFontName) +gfxQuartzFontCache::LookupLocalFont(const gfxProxyFontEntry *aProxyEntry, + const nsAString& aFontName) { NSString *faceName = GetNSStringForString(aFontName); - NSFont *font = [NSFont fontWithName:faceName size:0.0]; + + // first lookup a single face based on postscript name + ATSFontRef fontRef = ATSFontFindFromPostScriptName(CFStringRef(faceName), + kATSOptionFlagsDefault); - if (font) { - nsAutoString availableFamilyName; - NSString *availableFamily = [font familyName]; - GetStringForNSString(availableFamily, availableFamilyName); + // if not found, lookup using full font name + if (fontRef == kInvalidFont) + fontRef = ATSFontFindFromName(CFStringRef(faceName), + kATSOptionFlagsDefault); + + // not found + if (fontRef == kInvalidFont) + return nsnull; - MacOSFamilyEntry *familyEntry = FindFamily(availableFamilyName); - if (familyEntry) { - MacOSFontEntry *fontEntry = familyEntry->FindFont(aFontName); - return fontEntry; - } - } + PRUint16 w = aProxyEntry->mWeight; + NS_ASSERTION(w >= 100 && w <= 900, "bogus font weight value!"); - // didn't find the font - return nsnull; + MacOSFontEntry *newFontEntry = + new MacOSFontEntry(aFontName, + FMGetFontFromATSFontRef(fontRef), + w, aProxyEntry->mStretch, + (PRUint32(aProxyEntry->mItalic) ? + FONT_STYLE_ITALIC : + FONT_STYLE_NORMAL), + nsnull); + + return newFontEntry; } // grumble, another non-publised Apple API dependency (found in Webkit code) diff --git a/layout/reftests/font-face/reftest.list b/layout/reftests/font-face/reftest.list index 23bed102eb95..81f63ede4915 100644 --- a/layout/reftests/font-face/reftest.list +++ b/layout/reftests/font-face/reftest.list @@ -25,6 +25,11 @@ HTTP(..) == src-list-format-6.html src-list-format-3-ref.html # assumes AAT fonts are only supported on MacOS skip-if(MOZ_WIDGET_TOOLKIT=="cocoa") HTTP(..) == src-list-format-7.html src-list-format-2-ref.html skip-if(MOZ_WIDGET_TOOLKIT!="cocoa") HTTP(..) == src-list-format-7.html src-list-format-3-ref.html +fails-if(MOZ_WIDGET_TOOLKIT=="windows") == src-list-local-full.html src-list-local-full-ref.html # bug 468387 +fails-if(MOZ_WIDGET_TOOLKIT=="windows") == src-list-local-full-quotes.html src-list-local-full-ref.html # bug 468387 +# Postscript name lookup only supported on MacOS currently +skip-if(MOZ_WIDGET_TOOLKIT!="cocoa") == src-list-local-ps.html src-list-local-full-ref.html + # FIXME: The behavior here is neither mandated nor specified by the spec, but # it really ought to be. HTTP(..) == order-1.html order-1-ref.html @@ -66,4 +71,4 @@ HTTP(..) == ahem-metrics-1.html ahem-metrics-1-ref.html HTTP(..) == ex-unit-1.html ex-unit-1-ref.html HTTP(..) == ex-unit-1-dynamic.html ex-unit-1-ref.html -fails-if(MOZ_WIDGET_TOOLKIT!="gtk2") == local-1.html local-1-ref.html # fails on MS Windows and Mac due to bug 465463 +fails-if(MOZ_WIDGET_TOOLKIT=="windows") == local-1.html local-1-ref.html # bug 468387