mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-06-09 11:29:39 +00:00
#417: remove 10.7+ font handling and tune up gfx/thebes/ etc.
This commit is contained in:
parent
07656dbb88
commit
e45c857b4f
|
@ -1720,6 +1720,8 @@ gfxFontFamily::ReadFaceNames(gfxPlatformFontList *aPlatformFontList,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __LP64__
|
||||||
|
// Can't run on 10.4-10.6.
|
||||||
if (!mOtherFamilyNamesInitialized &&
|
if (!mOtherFamilyNamesInitialized &&
|
||||||
aFontInfoData &&
|
aFontInfoData &&
|
||||||
aFontInfoData->mLoadOtherNames &&
|
aFontInfoData->mLoadOtherNames &&
|
||||||
|
@ -1742,6 +1744,7 @@ gfxFontFamily::ReadFaceNames(gfxPlatformFontList *aPlatformFontList,
|
||||||
(mFaceNamesInitialized || !aNeedFullnamePostscriptNames)) {
|
(mFaceNamesInitialized || !aNeedFullnamePostscriptNames)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
FindStyleVariations(aFontInfoData);
|
FindStyleVariations(aFontInfoData);
|
||||||
|
|
||||||
|
|
|
@ -223,18 +223,18 @@ gfxMacFont::InitMetrics()
|
||||||
|
|
||||||
{
|
{
|
||||||
ByteCount tableSize;
|
ByteCount tableSize;
|
||||||
if (::ATSFontGetTable(myATSFont,
|
if (MOZ_UNLIKELY(::ATSFontGetTable(myATSFont,
|
||||||
TRUETYPE_TAG('h','e','a','d'),
|
TRUETYPE_TAG('h','e','a','d'),
|
||||||
0, 0, NULL, &tableSize) != noErr)
|
0, 0, NULL, &tableSize) != noErr))
|
||||||
return;
|
return;
|
||||||
CFMutableDataRef data = ::CFDataCreateMutable(kCFAllocatorDefault,
|
CFMutableDataRef data = ::CFDataCreateMutable(kCFAllocatorDefault,
|
||||||
tableSize);
|
tableSize);
|
||||||
if (!data) return;
|
if (MOZ_UNLIKELY(!data)) return;
|
||||||
::CFDataIncreaseLength(data, tableSize);
|
::CFDataIncreaseLength(data, tableSize);
|
||||||
if (::ATSFontGetTable(myATSFont,
|
if (MOZ_UNLIKELY(::ATSFontGetTable(myATSFont,
|
||||||
TRUETYPE_TAG('h','e','a','d'),
|
TRUETYPE_TAG('h','e','a','d'),
|
||||||
0, tableSize, ::CFDataGetMutableBytePtr(data),
|
0, tableSize, ::CFDataGetMutableBytePtr(data),
|
||||||
&tableSize) != noErr) {
|
&tableSize) != noErr)) {
|
||||||
::CFRelease(data);
|
::CFRelease(data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ gfxMacFont::InitMetrics()
|
||||||
upem = ::CGFontGetUnitsPerEm(mCGFont);
|
upem = ::CGFontGetUnitsPerEm(mCGFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (upem < 16 || upem > 16384) {
|
if (MOZ_UNLIKELY(upem < 16 || upem > 16384)) {
|
||||||
// See http://www.microsoft.com/typography/otspec/head.htm
|
// See http://www.microsoft.com/typography/otspec/head.htm
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
char warnBuf[1024];
|
char warnBuf[1024];
|
||||||
|
@ -294,7 +294,7 @@ gfxMacFont::InitMetrics()
|
||||||
|
|
||||||
err = ::ATSFontGetHorizontalMetrics(myATSFont, kATSOptionFlagsDefault,
|
err = ::ATSFontGetHorizontalMetrics(myATSFont, kATSOptionFlagsDefault,
|
||||||
&atsMetrics);
|
&atsMetrics);
|
||||||
if (err != noErr) {
|
if (MOZ_UNLIKELY(err != noErr)) {
|
||||||
NS_WARNING("could not get CGFontGetXHeight, no ATS fallback");
|
NS_WARNING("could not get CGFontGetXHeight, no ATS fallback");
|
||||||
return; // just fail -- Cameron Kludge
|
return; // just fail -- Cameron Kludge
|
||||||
}
|
}
|
||||||
|
@ -330,7 +330,7 @@ gfxMacFont::InitMetrics()
|
||||||
err = ::ATSFontGetHorizontalMetrics(myATSFont,
|
err = ::ATSFontGetHorizontalMetrics(myATSFont,
|
||||||
kATSOptionFlagsDefault,
|
kATSOptionFlagsDefault,
|
||||||
&atsMetrics);
|
&atsMetrics);
|
||||||
if (err != noErr) {
|
if (MOZ_UNLIKELY(err != noErr)) {
|
||||||
NS_WARNING("could not get CGFontGetXHeight again, no ATS fallback");
|
NS_WARNING("could not get CGFontGetXHeight again, no ATS fallback");
|
||||||
return; // just fail -- Cameron Kludge
|
return; // just fail -- Cameron Kludge
|
||||||
}
|
}
|
||||||
|
@ -353,15 +353,15 @@ gfxMacFont::InitMetrics()
|
||||||
CFDataRef cmap;
|
CFDataRef cmap;
|
||||||
{
|
{
|
||||||
ByteCount tableSize;
|
ByteCount tableSize;
|
||||||
if (::ATSFontGetTable(myATSFont, TRUETYPE_TAG('c','m','a','p'), 0, 0, NULL,
|
if (MOZ_UNLIKELY(::ATSFontGetTable(myATSFont, TRUETYPE_TAG('c','m','a','p'), 0, 0, NULL,
|
||||||
&tableSize) != noErr) return;
|
&tableSize) != noErr)) return;
|
||||||
CFMutableDataRef data = ::CFDataCreateMutable(kCFAllocatorDefault,
|
CFMutableDataRef data = ::CFDataCreateMutable(kCFAllocatorDefault,
|
||||||
tableSize);
|
tableSize);
|
||||||
if (!data) return;
|
if (MOZ_UNLIKELY(!data)) return;
|
||||||
::CFDataIncreaseLength(data, tableSize);
|
::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,
|
0, tableSize,
|
||||||
::CFDataGetMutableBytePtr(data), &tableSize) != noErr)
|
::CFDataGetMutableBytePtr(data), &tableSize) != noErr))
|
||||||
{ ::CFRelease(data); return; }
|
{ ::CFRelease(data); return; }
|
||||||
cmap = data;
|
cmap = data;
|
||||||
}
|
}
|
||||||
|
@ -512,7 +512,7 @@ static_cast<MacOSFontEntry*>(GetFontEntry())->GetATSFontRef();
|
||||||
|
|
||||||
err = ::ATSFontGetHorizontalMetrics(aFontRef, kATSOptionFlagsDefault,
|
err = ::ATSFontGetHorizontalMetrics(aFontRef, kATSOptionFlagsDefault,
|
||||||
&atsMetrics);
|
&atsMetrics);
|
||||||
if (err != noErr) {
|
if (MOZ_UNLIKELY(err != noErr)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
char warnBuf[1024];
|
char warnBuf[1024];
|
||||||
sprintf(warnBuf, "Bad font metrics for: %s err: %8.8x",
|
sprintf(warnBuf, "Bad font metrics for: %s err: %8.8x",
|
||||||
|
|
|
@ -512,7 +512,7 @@ MacOSFontEntry::GetFontTable(uint32_t aTag)
|
||||||
#endif
|
#endif
|
||||||
OSStatus status = ::ATSFontGetTable(fontRef, aTag, 0, 0, 0,
|
OSStatus status = ::ATSFontGetTable(fontRef, aTag, 0, 0, 0,
|
||||||
&dataLength);
|
&dataLength);
|
||||||
if (status != noErr) return nullptr;
|
if (MOZ_UNLIKELY(status != noErr)) return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Taking advantage of bridging CFMutableDataRef to CFDataRef.
|
// Taking advantage of bridging CFMutableDataRef to CFDataRef.
|
||||||
|
@ -521,9 +521,9 @@ MacOSFontEntry::GetFontTable(uint32_t aTag)
|
||||||
if (!dataRef) return nullptr;
|
if (!dataRef) return nullptr;
|
||||||
|
|
||||||
::CFDataIncreaseLength(dataRef, dataLength); // paranoia
|
::CFDataIncreaseLength(dataRef, dataLength); // paranoia
|
||||||
if(::ATSFontGetTable(fontRef, aTag, 0, dataLength,
|
if(MOZ_UNLIKELY(::ATSFontGetTable(fontRef, aTag, 0, dataLength,
|
||||||
::CFDataGetMutableBytePtr(dataRef),
|
::CFDataGetMutableBytePtr(dataRef),
|
||||||
&dataLength) != noErr) {
|
&dataLength) != noErr)) {
|
||||||
::CFRelease(dataRef);
|
::CFRelease(dataRef);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -612,10 +612,10 @@ MacOSFontEntry::HasFontTable(uint32_t aTableTag)
|
||||||
|
|
||||||
ByteCount sizer;
|
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
|
// If the header is abnormal, try the old, slower way in case this
|
||||||
// is a gap in our algorithm.
|
// 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 "
|
fprintf(stderr, "Warning: TenFourFox found "
|
||||||
"abnormal font table dir in %s (%i).\n",
|
"abnormal font table dir in %s (%i).\n",
|
||||||
NS_ConvertUTF16toUTF8(mName).get(), sizer);
|
NS_ConvertUTF16toUTF8(mName).get(), sizer);
|
||||||
|
@ -631,8 +631,8 @@ MacOSFontEntry::HasFontTable(uint32_t aTableTag)
|
||||||
fprintf(stderr, "Size of %s font table directory: %i\nTables: ",
|
fprintf(stderr, "Size of %s font table directory: %i\nTables: ",
|
||||||
NS_ConvertUTF16toUTF8(mName).get(), mFontTableDir.Length());
|
NS_ConvertUTF16toUTF8(mName).get(), mFontTableDir.Length());
|
||||||
#endif
|
#endif
|
||||||
if (::ATSFontGetTableDirectory(fontRef, mFontTableDirSize,
|
if (MOZ_LIKELY(::ATSFontGetTableDirectory(fontRef, mFontTableDirSize,
|
||||||
reinterpret_cast<void *>(mFontTableDir.Elements()), &sizer) == noErr) {
|
reinterpret_cast<void *>(mFontTableDir.Elements()), &sizer) == noErr)) {
|
||||||
|
|
||||||
// Push to platform.
|
// Push to platform.
|
||||||
if (!mIsDataUserFont || mIsLocalUserFont)
|
if (!mIsDataUserFont || mIsLocalUserFont)
|
||||||
|
@ -1175,6 +1175,7 @@ const CGFloat kTextDisplayCrossover = 20.0; // use text family below this size
|
||||||
void
|
void
|
||||||
gfxMacPlatformFontList::InitSystemFonts()
|
gfxMacPlatformFontList::InitSystemFonts()
|
||||||
{
|
{
|
||||||
|
#ifdef __LP64__
|
||||||
// system font under 10.11 are two distinct families for text/display sizes
|
// system font under 10.11 are two distinct families for text/display sizes
|
||||||
if (nsCocoaFeatures::OnElCapitanOrLater()) {
|
if (nsCocoaFeatures::OnElCapitanOrLater()) {
|
||||||
mUseSizeSensitiveSystemFont = true;
|
mUseSizeSensitiveSystemFont = true;
|
||||||
|
@ -1209,6 +1210,16 @@ gfxMacPlatformFontList::InitSystemFonts()
|
||||||
"system text/display font size switch point is not as expected!");
|
"system text/display font size switch point is not as expected!");
|
||||||
#endif
|
#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
|
#ifdef DEBUG
|
||||||
// different system font API's always map to the same family under OSX, so
|
// different system font API's always map to the same family under OSX, so
|
||||||
|
@ -1583,7 +1594,7 @@ gfxMacPlatformFontList::MakePlatformFont(const nsAString& aFontName,
|
||||||
&containerRef);
|
&containerRef);
|
||||||
mATSGeneration = ::ATSGetGeneration();
|
mATSGeneration = ::ATSGetGeneration();
|
||||||
|
|
||||||
if (err != noErr) {
|
if (MOZ_UNLIKELY(err != noErr)) {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
char warnBuf[1024];
|
char warnBuf[1024];
|
||||||
sprintf(warnBuf, "downloaded font error, ATSFontActivateFromMemory err: %d",
|
sprintf(warnBuf, "downloaded font error, ATSFontActivateFromMemory err: %d",
|
||||||
|
@ -1596,7 +1607,7 @@ gfxMacPlatformFontList::MakePlatformFont(const nsAString& aFontName,
|
||||||
// ignoring containers with multiple fonts, use the first face only for now
|
// ignoring containers with multiple fonts, use the first face only for now
|
||||||
err = ::ATSFontFindFromContainer(containerRef, kATSOptionFlagsDefault, 1,
|
err = ::ATSFontFindFromContainer(containerRef, kATSOptionFlagsDefault, 1,
|
||||||
&fontRef, NULL);
|
&fontRef, NULL);
|
||||||
if (err != noErr) {
|
if (MOZ_UNLIKELY(err != noErr)) {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
char warnBuf[1024];
|
char warnBuf[1024];
|
||||||
sprintf(warnBuf, "downloaded font error, ATSFontFindFromContainer err: %d",
|
sprintf(warnBuf, "downloaded font error, ATSFontFindFromContainer err: %d",
|
||||||
|
@ -1611,7 +1622,7 @@ gfxMacPlatformFontList::MakePlatformFont(const nsAString& aFontName,
|
||||||
OSStatus err;
|
OSStatus err;
|
||||||
NSString *psname = NULL;
|
NSString *psname = NULL;
|
||||||
err = ::ATSFontGetPostScriptName(fontRef, kATSOptionFlagsDefault, (CFStringRef*) (&psname));
|
err = ::ATSFontGetPostScriptName(fontRef, kATSOptionFlagsDefault, (CFStringRef*) (&psname));
|
||||||
if (err == noErr) {
|
if (MOZ_LIKELY(err == noErr)) {
|
||||||
#if(0)
|
#if(0)
|
||||||
fprintf(stderr, "Trying: %s.\n", [psname UTF8String]);
|
fprintf(stderr, "Trying: %s.\n", [psname UTF8String]);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1679,7 +1690,7 @@ gfxMacPlatformFontList::MakePlatformFont(const nsAString& aFontName,
|
||||||
containerRef, true, false);
|
containerRef, true, false);
|
||||||
|
|
||||||
// if succeeded and font cmap is good, return the new font
|
// 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;
|
return newFontEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1753,10 +1764,12 @@ gfxMacPlatformFontList::FindFamily(const nsAString& aFamily, gfxFontStyle* aStyl
|
||||||
{
|
{
|
||||||
// search for special system font name, -apple-system
|
// search for special system font name, -apple-system
|
||||||
if (aFamily.EqualsLiteral(kSystemFont_system)) {
|
if (aFamily.EqualsLiteral(kSystemFont_system)) {
|
||||||
|
#ifdef __LP64__
|
||||||
if (mUseSizeSensitiveSystemFont &&
|
if (mUseSizeSensitiveSystemFont &&
|
||||||
aStyle && (aStyle->size * aDevToCssSize) >= kTextDisplayCrossover) {
|
aStyle && (aStyle->size * aDevToCssSize) >= kTextDisplayCrossover) {
|
||||||
return mSystemDisplayFontFamily;
|
return mSystemDisplayFontFamily;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return mSystemTextFontFamily;
|
return mSystemTextFontFamily;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1847,11 +1860,13 @@ public:
|
||||||
virtual ~MacFontInfo() {}
|
virtual ~MacFontInfo() {}
|
||||||
|
|
||||||
virtual void Load() {
|
virtual void Load() {
|
||||||
|
#ifdef __LP64__
|
||||||
nsAutoreleasePool localPool;
|
nsAutoreleasePool localPool;
|
||||||
// bug 975460 - async font loader crashes sometimes under 10.6, disable
|
// bug 975460 - async font loader crashes sometimes under 10.6, disable
|
||||||
if (nsCocoaFeatures::OnLionOrLater()) {
|
if (nsCocoaFeatures::OnLionOrLater()) {
|
||||||
FontInfoData::Load();
|
FontInfoData::Load();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// loads font data for all members of a given family
|
// loads font data for all members of a given family
|
||||||
|
|
Loading…
Reference in New Issue
Block a user