diff --git a/gfx/thebes/gfxFontEntry.cpp b/gfx/thebes/gfxFontEntry.cpp index 4d8d72ec91..a333d0bfc0 100644 --- a/gfx/thebes/gfxFontEntry.cpp +++ b/gfx/thebes/gfxFontEntry.cpp @@ -1720,6 +1720,8 @@ gfxFontFamily::ReadFaceNames(gfxPlatformFontList *aPlatformFontList, } #endif +#ifdef __LP64__ +// Can't run on 10.4-10.6. if (!mOtherFamilyNamesInitialized && aFontInfoData && aFontInfoData->mLoadOtherNames && @@ -1742,6 +1744,7 @@ gfxFontFamily::ReadFaceNames(gfxPlatformFontList *aPlatformFontList, (mFaceNamesInitialized || !aNeedFullnamePostscriptNames)) { return; } +#endif FindStyleVariations(aFontInfoData); diff --git a/gfx/thebes/gfxMacFont.cpp b/gfx/thebes/gfxMacFont.cpp index 7f45cc077b..dcf3947908 100644 --- a/gfx/thebes/gfxMacFont.cpp +++ b/gfx/thebes/gfxMacFont.cpp @@ -223,18 +223,18 @@ gfxMacFont::InitMetrics() { ByteCount tableSize; - if (::ATSFontGetTable(myATSFont, + if (MOZ_UNLIKELY(::ATSFontGetTable(myATSFont, TRUETYPE_TAG('h','e','a','d'), - 0, 0, NULL, &tableSize) != noErr) + 0, 0, NULL, &tableSize) != noErr)) return; CFMutableDataRef data = ::CFDataCreateMutable(kCFAllocatorDefault, tableSize); - if (!data) return; + if (MOZ_UNLIKELY(!data)) return; ::CFDataIncreaseLength(data, tableSize); - if (::ATSFontGetTable(myATSFont, + if (MOZ_UNLIKELY(::ATSFontGetTable(myATSFont, TRUETYPE_TAG('h','e','a','d'), 0, tableSize, ::CFDataGetMutableBytePtr(data), - &tableSize) != noErr) { + &tableSize) != noErr)) { ::CFRelease(data); return; } @@ -253,7 +253,7 @@ gfxMacFont::InitMetrics() upem = ::CGFontGetUnitsPerEm(mCGFont); } - if (upem < 16 || upem > 16384) { + if (MOZ_UNLIKELY(upem < 16 || upem > 16384)) { // See http://www.microsoft.com/typography/otspec/head.htm #ifdef DEBUG char warnBuf[1024]; @@ -294,7 +294,7 @@ gfxMacFont::InitMetrics() err = ::ATSFontGetHorizontalMetrics(myATSFont, kATSOptionFlagsDefault, &atsMetrics); - if (err != noErr) { + if (MOZ_UNLIKELY(err != noErr)) { NS_WARNING("could not get CGFontGetXHeight, no ATS fallback"); return; // just fail -- Cameron Kludge } @@ -330,7 +330,7 @@ gfxMacFont::InitMetrics() err = ::ATSFontGetHorizontalMetrics(myATSFont, kATSOptionFlagsDefault, &atsMetrics); - if (err != noErr) { + if (MOZ_UNLIKELY(err != noErr)) { NS_WARNING("could not get CGFontGetXHeight again, no ATS fallback"); return; // just fail -- Cameron Kludge } @@ -353,15 +353,15 @@ gfxMacFont::InitMetrics() CFDataRef cmap; { ByteCount tableSize; - if (::ATSFontGetTable(myATSFont, TRUETYPE_TAG('c','m','a','p'), 0, 0, NULL, - &tableSize) != noErr) return; + if (MOZ_UNLIKELY(::ATSFontGetTable(myATSFont, TRUETYPE_TAG('c','m','a','p'), 0, 0, NULL, + &tableSize) != noErr)) return; CFMutableDataRef data = ::CFDataCreateMutable(kCFAllocatorDefault, tableSize); - if (!data) return; + if (MOZ_UNLIKELY(!data)) return; ::CFDataIncreaseLength(data, tableSize); - if (::ATSFontGetTable(myATSFont, TRUETYPE_TAG('c','m','a','p'), + if (MOZ_UNLIKELY(::ATSFontGetTable(myATSFont, TRUETYPE_TAG('c','m','a','p'), 0, tableSize, - ::CFDataGetMutableBytePtr(data), &tableSize) != noErr) + ::CFDataGetMutableBytePtr(data), &tableSize) != noErr)) { ::CFRelease(data); return; } cmap = data; } @@ -512,7 +512,7 @@ static_cast(GetFontEntry())->GetATSFontRef(); err = ::ATSFontGetHorizontalMetrics(aFontRef, kATSOptionFlagsDefault, &atsMetrics); - if (err != noErr) { + if (MOZ_UNLIKELY(err != noErr)) { #ifdef DEBUG char warnBuf[1024]; sprintf(warnBuf, "Bad font metrics for: %s err: %8.8x", diff --git a/gfx/thebes/gfxMacPlatformFontList.mm b/gfx/thebes/gfxMacPlatformFontList.mm index e8c46f4095..3480d19ed2 100644 --- a/gfx/thebes/gfxMacPlatformFontList.mm +++ b/gfx/thebes/gfxMacPlatformFontList.mm @@ -512,7 +512,7 @@ new FontTableRec(dataRef), #endif OSStatus status = ::ATSFontGetTable(fontRef, aTag, 0, 0, 0, &dataLength); - if (status != noErr) return nullptr; + if (MOZ_UNLIKELY(status != noErr)) return nullptr; } // Taking advantage of bridging CFMutableDataRef to CFDataRef. @@ -521,9 +521,9 @@ new FontTableRec(dataRef), if (!dataRef) return nullptr; ::CFDataIncreaseLength(dataRef, dataLength); // paranoia - if(::ATSFontGetTable(fontRef, aTag, 0, dataLength, + if(MOZ_UNLIKELY(::ATSFontGetTable(fontRef, aTag, 0, dataLength, ::CFDataGetMutableBytePtr(dataRef), - &dataLength) != noErr) { + &dataLength) != noErr)) { ::CFRelease(dataRef); return nullptr; } @@ -612,10 +612,10 @@ static bool FindTagInTableDir(FallibleTArray& table, ByteCount sizer; - if(::ATSFontGetTableDirectory(fontRef, 0, NULL, &sizer) == noErr) { + if(MOZ_LIKELY(::ATSFontGetTableDirectory(fontRef, 0, NULL, &sizer) == noErr)) { // If the header is abnormal, try the old, slower way in case this // is a gap in our algorithm. - if (sizer <= 12 || ((sizer-12) % 16) || sizer >= 1024) { + if (MOZ_UNLIKELY(sizer <= 12 || ((sizer-12) % 16) || sizer >= 1024)) { fprintf(stderr, "Warning: TenFourFox found " "abnormal font table dir in %s (%i).\n", NS_ConvertUTF16toUTF8(mName).get(), sizer); @@ -631,8 +631,8 @@ static bool FindTagInTableDir(FallibleTArray& table, fprintf(stderr, "Size of %s font table directory: %i\nTables: ", NS_ConvertUTF16toUTF8(mName).get(), mFontTableDir.Length()); #endif - if (::ATSFontGetTableDirectory(fontRef, mFontTableDirSize, - reinterpret_cast(mFontTableDir.Elements()), &sizer) == noErr) { + if (MOZ_LIKELY(::ATSFontGetTableDirectory(fontRef, mFontTableDirSize, + reinterpret_cast(mFontTableDir.Elements()), &sizer) == noErr)) { // Push to platform. if (!mIsDataUserFont || mIsLocalUserFont) @@ -1175,6 +1175,7 @@ explicit gfxSingleFaceMacFontFamily(nsAString& aName) : void gfxMacPlatformFontList::InitSystemFonts() { +#ifdef __LP64__ // system font under 10.11 are two distinct families for text/display sizes if (nsCocoaFeatures::OnElCapitanOrLater()) { mUseSizeSensitiveSystemFont = true; @@ -1209,6 +1210,16 @@ explicit gfxSingleFaceMacFontFamily(nsAString& aName) : "system text/display font size switch point is not as expected!"); #endif } +#else // LP64 + // Simplified version for 10.4-10.6 + + NSFont* sys = [NSFont systemFontOfSize: 0.0]; + NSString* textFamilyName = GetRealFamilyName(sys); + nsAutoString familyName; + nsCocoaUtils::GetStringForNSString(textFamilyName, familyName); + mSystemTextFontFamily = FindSystemFontFamily(familyName); + NS_ASSERTION(mSystemTextFontFamily, "null system display font family"); +#endif // LP64 #ifdef DEBUG // different system font API's always map to the same family under OSX, so @@ -1583,7 +1594,7 @@ static void ReleaseData(void *info, const void *data, size_t size) &containerRef); mATSGeneration = ::ATSGetGeneration(); - if (err != noErr) { + if (MOZ_UNLIKELY(err != noErr)) { #if DEBUG char warnBuf[1024]; sprintf(warnBuf, "downloaded font error, ATSFontActivateFromMemory err: %d", @@ -1596,7 +1607,7 @@ static void ReleaseData(void *info, const void *data, size_t size) // ignoring containers with multiple fonts, use the first face only for now err = ::ATSFontFindFromContainer(containerRef, kATSOptionFlagsDefault, 1, &fontRef, NULL); - if (err != noErr) { + if (MOZ_UNLIKELY(err != noErr)) { #if DEBUG char warnBuf[1024]; sprintf(warnBuf, "downloaded font error, ATSFontFindFromContainer err: %d", @@ -1611,7 +1622,7 @@ static void ReleaseData(void *info, const void *data, size_t size) OSStatus err; NSString *psname = NULL; err = ::ATSFontGetPostScriptName(fontRef, kATSOptionFlagsDefault, (CFStringRef*) (&psname)); - if (err == noErr) { + if (MOZ_LIKELY(err == noErr)) { #if(0) fprintf(stderr, "Trying: %s.\n", [psname UTF8String]); #endif @@ -1679,7 +1690,7 @@ new MacOSFontEntry(uniqueName, containerRef, true, false); // if succeeded and font cmap is good, return the new font - if (newFontEntry->mIsValid && NS_SUCCEEDED(newFontEntry->ReadCMAP())) { + if (MOZ_LIKELY(newFontEntry->mIsValid && NS_SUCCEEDED(newFontEntry->ReadCMAP()))) { return newFontEntry; } @@ -1753,10 +1764,12 @@ new MacOSFontEntry(uniqueName, { // search for special system font name, -apple-system if (aFamily.EqualsLiteral(kSystemFont_system)) { +#ifdef __LP64__ if (mUseSizeSensitiveSystemFont && aStyle && (aStyle->size * aDevToCssSize) >= kTextDisplayCrossover) { return mSystemDisplayFontFamily; } +#endif return mSystemTextFontFamily; } @@ -1847,11 +1860,13 @@ new MacOSFontEntry(uniqueName, virtual ~MacFontInfo() {} virtual void Load() { +#ifdef __LP64__ nsAutoreleasePool localPool; // bug 975460 - async font loader crashes sometimes under 10.6, disable if (nsCocoaFeatures::OnLionOrLater()) { FontInfoData::Load(); } +#endif } // loads font data for all members of a given family