diff --git a/gfx/thebes/gfxMacPlatformFontList.mm b/gfx/thebes/gfxMacPlatformFontList.mm index 3480d19ed..fdbe0a89f 100644 --- a/gfx/thebes/gfxMacPlatformFontList.mm +++ b/gfx/thebes/gfxMacPlatformFontList.mm @@ -547,6 +547,7 @@ static bool FindTagInTableDir(FallibleTArray& table, // 96 bit header (three 32-bit words). One day we could even write // an AltiVec version ... #ifdef DEBUG_X + fprintf(stderr, "Tables: "); uint32_t j = 12; #endif uint32_t i; @@ -628,7 +629,7 @@ MacOSFontEntry::HasFontTable(uint32_t aTableTag) mFontTableDir.SetLength(mFontTableDirSize, fallible); #ifdef DEBUG - fprintf(stderr, "Size of %s font table directory: %i\nTables: ", + fprintf(stderr, "Size of %s font table directory: %i\n", NS_ConvertUTF16toUTF8(mName).get(), mFontTableDir.Length()); #endif if (MOZ_LIKELY(::ATSFontGetTableDirectory(fontRef, mFontTableDirSize, diff --git a/gfx/thebes/gfxPlatformMac.cpp b/gfx/thebes/gfxPlatformMac.cpp index b598baa3d..bdf01c9da 100644 --- a/gfx/thebes/gfxPlatformMac.cpp +++ b/gfx/thebes/gfxPlatformMac.cpp @@ -220,6 +220,24 @@ gfxPlatformMac::MakePlatformFont(const nsAString& aFontName, aLength); } +// Automates a whole buncha boilerplate. +// Since HTTPS is becoming more common, check that first. +#define HTTP_OR_HTTPS_SUBDIR(x) \ + { \ + if (!failed) { \ + NS_NAMED_LITERAL_CSTRING(https_, "https://" x); \ + spec.Left(loc, https_.Length()); \ + if (loc.Equals(https_)) { \ + failed = true; \ + } else { \ + NS_NAMED_LITERAL_CSTRING(http_, "http://" x); \ + spec.Left(loc, http_.Length()); \ + if (loc.Equals(http_)) \ + failed = true; \ + } \ + } \ + } + bool gfxPlatformMac::IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags) { @@ -228,13 +246,19 @@ gfxPlatformMac::IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags) "strange font format hint set"); // TenFourFox issue 261. Prevent loading certain known bad font URIs. - nsCString spec; + nsAutoCString spec, loc; nsresult rv = aFontURI->GetAsciiSpec(spec); + bool failed = false; + + if (MOZ_LIKELY(NS_SUCCEEDED(rv))) { #if DEBUG - if (NS_SUCCEEDED(rv)) fprintf(stderr, "Font blacklist checking: %s\n", spec.get()); #endif - if (NS_FAILED(rv) || + HTTP_OR_HTTPS_SUBDIR("www.apple.com/wss/fonts/SF-Pro-Text/v1/"); + HTTP_OR_HTTPS_SUBDIR("www.apple.com/wss/fonts/SF-Pro-Display/v1/"); + } else + failed = true; + if (failed || spec.Equals("https://cdn-static-1.medium.com/_/fp/fonts/charter-nonlatin.b-nw7PXlIqmGHGmHvkDiTw.woff") || spec.Equals("http://typeface.nytimes.com/fonts/nyt-cheltenham-200-normal.woff") || spec.Equals("https://typeface.nyt.com/fonts/nyt-cheltenham-200-normal.woff") || @@ -246,46 +270,9 @@ gfxPlatformMac::IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags) spec.Equals("http://fonts.gstatic.com/ea/notosansjapanese/v6/NotoSansJP-Bold.otf") || spec.Equals("https://www.icloud.com/fonts/SFNSText-Light.woff") || spec.Equals("https://www.icloud.com/fonts/SFNSText-Medium.woff") || - spec.Equals("https://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_bold.woff") || - spec.Equals("https://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_bold.ttf") || - spec.Equals("https://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_medium.woff") || - spec.Equals("https://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_medium.ttf") || - spec.Equals("https://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_semibold.woff") || - spec.Equals("https://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_semibold.ttf") || - spec.Equals("https://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_regular.woff") || - spec.Equals("https://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_regular.ttf") || - spec.Equals("https://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_light.woff") || - spec.Equals("https://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_light.ttf") || - spec.Equals("https://www.apple.com/wss/fonts/SF-Pro-Display/v1/sf-pro-display_medium.woff") || - spec.Equals("https://www.apple.com/wss/fonts/SF-Pro-Display/v1/sf-pro-display_medium.ttf") || - spec.Equals("https://www.apple.com/wss/fonts/SF-Pro-Display/v1/sf-pro-display_regular.woff") || - spec.Equals("https://www.apple.com/wss/fonts/SF-Pro-Display/v1/sf-pro-display_regular.ttf") || - spec.Equals("https://www.apple.com/wss/fonts/SF-Pro-Display/v1/sf-pro-display_light.woff") || - spec.Equals("https://www.apple.com/wss/fonts/SF-Pro-Display/v1/sf-pro-display_light.ttf") || - spec.Equals("https://www.apple.com/wss/fonts/SF-Pro-Display/v1/sf-pro-display_semibold.woff") || - spec.Equals("https://www.apple.com/wss/fonts/SF-Pro-Display/v1/sf-pro-display_semibold.ttf") || - spec.Equals("http://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_bold.woff") || - spec.Equals("http://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_bold.ttf") || - spec.Equals("http://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_medium.woff") || - spec.Equals("http://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_medium.ttf") || - spec.Equals("http://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_semibold.woff") || - spec.Equals("http://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_semibold.ttf") || - spec.Equals("http://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_regular.woff") || - spec.Equals("http://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_regular.ttf") || - spec.Equals("http://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_light.woff") || - spec.Equals("http://www.apple.com/wss/fonts/SF-Pro-Text/v1/sf-pro-text_light.ttf") || - spec.Equals("http://www.apple.com/wss/fonts/SF-Pro-Display/v1/sf-pro-display_medium.woff") || - spec.Equals("http://www.apple.com/wss/fonts/SF-Pro-Display/v1/sf-pro-display_medium.ttf") || - spec.Equals("http://www.apple.com/wss/fonts/SF-Pro-Display/v1/sf-pro-display_regular.woff") || - spec.Equals("http://www.apple.com/wss/fonts/SF-Pro-Display/v1/sf-pro-display_regular.ttf") || - spec.Equals("http://www.apple.com/wss/fonts/SF-Pro-Display/v1/sf-pro-display_light.woff") || - spec.Equals("http://www.apple.com/wss/fonts/SF-Pro-Display/v1/sf-pro-display_light.ttf") || - spec.Equals("http://www.apple.com/wss/fonts/SF-Pro-Display/v1/sf-pro-display_semibold.woff") || - spec.Equals("http://www.apple.com/wss/fonts/SF-Pro-Display/v1/sf-pro-display_semibold.ttf") || - 0) { - if (NS_SUCCEEDED(rv)) // Don't print if we couldn't get the URL. - fprintf(stderr, -"Warning: TenFourFox blocking ATSUI-incompatible webfont %s.\n", spec.get()); + 0) { + if (MOZ_LIKELY(NS_SUCCEEDED(rv))) // Don't print if we couldn't get the URL. + fprintf(stderr, "Warning: TenFourFox blocking ATSUI-incompatible webfont %s.\n", spec.get()); return false; } @@ -306,6 +293,8 @@ gfxPlatformMac::IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags) return true; } +#undef HTTP_OR_HTTPS_SUBDIR + // these will also move to gfxPlatform once all platforms support the fontlist nsresult gfxPlatformMac::GetFontList(nsIAtom *aLangGroup,