Bug 1803406 - Backout 2 changesets (6a82f1f120aa, 87d83c56fbe5) due to regression reported in bug 1858869.
Differential Revision: https://phabricator.services.mozilla.com/D190908
This commit is contained in:
@@ -112,8 +112,7 @@ already_AddRefed<NativeFontResourceMac> NativeFontResourceMac::Create(
|
|||||||
|
|
||||||
// creating the CGFontRef via the CTFont avoids the data being held alive
|
// creating the CGFontRef via the CTFont avoids the data being held alive
|
||||||
// in a cache.
|
// in a cache.
|
||||||
CTFontRef ctFont = CTFontCreateWithFontDescriptorAndOptions(
|
CTFontRef ctFont = CTFontCreateWithFontDescriptor(ctFontDesc, 0, NULL);
|
||||||
ctFontDesc, 0, NULL, kCTFontOptionsPreferSystemFont);
|
|
||||||
|
|
||||||
// Creating the CGFont from the CTFont prevents the font data from being
|
// Creating the CGFont from the CTFont prevents the font data from being
|
||||||
// held in the TDescriptorSource cache. This appears to be true even
|
// held in the TDescriptorSource cache. This appears to be true even
|
||||||
|
|||||||
@@ -713,8 +713,8 @@ already_AddRefed<ScaledFont> UnscaledFontMac::CreateScaledFont(
|
|||||||
*reinterpret_cast<const ScaledFontMac::InstanceData*>(aInstanceData);
|
*reinterpret_cast<const ScaledFontMac::InstanceData*>(aInstanceData);
|
||||||
RefPtr<ScaledFontMac> scaledFont;
|
RefPtr<ScaledFontMac> scaledFont;
|
||||||
if (mFontDesc) {
|
if (mFontDesc) {
|
||||||
AutoRelease<CTFontRef> font(CTFontCreateWithFontDescriptorAndOptions(
|
AutoRelease<CTFontRef> font(
|
||||||
mFontDesc, aGlyphSize, nullptr, kCTFontOptionsPreferSystemFont));
|
CTFontCreateWithFontDescriptor(mFontDesc, aGlyphSize, nullptr));
|
||||||
if (aNumVariations > 0) {
|
if (aNumVariations > 0) {
|
||||||
AutoRelease<CFDictionaryRef> varDict(CreateVariationTagDictionaryOrNull(
|
AutoRelease<CFDictionaryRef> varDict(CreateVariationTagDictionaryOrNull(
|
||||||
font, aNumVariations, aVariations));
|
font, aNumVariations, aVariations));
|
||||||
@@ -728,8 +728,7 @@ already_AddRefed<ScaledFont> UnscaledFontMac::CreateScaledFont(
|
|||||||
if (!fontDesc) {
|
if (!fontDesc) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
font = CTFontCreateWithFontDescriptorAndOptions(
|
font = CTFontCreateWithFontDescriptor(fontDesc, aGlyphSize, nullptr);
|
||||||
fontDesc, aGlyphSize, nullptr, kCTFontOptionsPreferSystemFont);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scaledFont = new ScaledFontMac(
|
scaledFont = new ScaledFontMac(
|
||||||
|
|||||||
@@ -1503,8 +1503,8 @@ void CTFontInfo::LoadFontFamilyData(const nsACString& aFamilyName) {
|
|||||||
}
|
}
|
||||||
prevFace = faceDesc;
|
prevFace = faceDesc;
|
||||||
|
|
||||||
AutoCFRelease<CTFontRef> fontRef = CTFontCreateWithFontDescriptorAndOptions(
|
AutoCFRelease<CTFontRef> fontRef =
|
||||||
faceDesc, 0.0, nullptr, kCTFontOptionsPreferSystemFont);
|
CTFontCreateWithFontDescriptor(faceDesc, 0.0, nullptr);
|
||||||
if (!fontRef) {
|
if (!fontRef) {
|
||||||
NS_WARNING("failed to create a CTFontRef");
|
NS_WARNING("failed to create a CTFontRef");
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -34,10 +34,7 @@ class gfxMacPlatformFontList final : public CoreTextFontList {
|
|||||||
friend class gfxPlatformMac;
|
friend class gfxPlatformMac;
|
||||||
|
|
||||||
gfxMacPlatformFontList();
|
gfxMacPlatformFontList();
|
||||||
virtual ~gfxMacPlatformFontList() {
|
virtual ~gfxMacPlatformFontList() = default;
|
||||||
// Don't leak the name that was cached during startup.
|
|
||||||
sSystemFontName.~nsCString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Special-case font faces treated as font families (set via prefs)
|
// Special-case font faces treated as font families (set via prefs)
|
||||||
void InitSingleFaceList() MOZ_REQUIRES(mLock) override;
|
void InitSingleFaceList() MOZ_REQUIRES(mLock) override;
|
||||||
@@ -46,11 +43,6 @@ class gfxMacPlatformFontList final : public CoreTextFontList {
|
|||||||
// initialize system fonts
|
// initialize system fonts
|
||||||
void InitSystemFontNames() override MOZ_REQUIRES(mLock);
|
void InitSystemFontNames() override MOZ_REQUIRES(mLock);
|
||||||
|
|
||||||
// Static, so that the startup RegisterFonts thread can call it before the
|
|
||||||
// platform font list is created, to initialize & cache the name.
|
|
||||||
static const nsCString& GetSystemFontName();
|
|
||||||
static nsCString sSystemFontName;
|
|
||||||
|
|
||||||
nsTArray<nsCString> mSingleFaceFonts;
|
nsTArray<nsCString> mSingleFaceFonts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -433,26 +433,18 @@ static NSString* GetRealFamilyName(NSFont* aFont) {
|
|||||||
return [familyName autorelease];
|
return [familyName autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
|
||||||
const nsCString& gfxMacPlatformFontList::GetSystemFontName() {
|
|
||||||
if (sSystemFontName.IsEmpty()) {
|
|
||||||
NSString* name = GetRealFamilyName([NSFont systemFontOfSize:0.0]);
|
|
||||||
nsAutoString familyName;
|
|
||||||
nsCocoaUtils::GetStringForNSString(name, familyName);
|
|
||||||
CopyUTF16toUTF8(familyName, sSystemFontName);
|
|
||||||
}
|
|
||||||
return sSystemFontName;
|
|
||||||
}
|
|
||||||
nsCString gfxMacPlatformFontList::sSystemFontName;
|
|
||||||
|
|
||||||
void gfxMacPlatformFontList::InitSystemFontNames() {
|
void gfxMacPlatformFontList::InitSystemFontNames() {
|
||||||
mSystemFontFamilyName = GetSystemFontName();
|
// text font family
|
||||||
|
NSFont* sys = [NSFont systemFontOfSize:0.0];
|
||||||
|
NSString* textFamilyName = GetRealFamilyName(sys);
|
||||||
|
nsAutoString familyName;
|
||||||
|
nsCocoaUtils::GetStringForNSString(textFamilyName, familyName);
|
||||||
|
CopyUTF16toUTF8(familyName, mSystemFontFamilyName);
|
||||||
|
|
||||||
// We store an in-process gfxFontFamily for the system font even if using the
|
// We store an in-process gfxFontFamily for the system font even if using the
|
||||||
// shared fontlist to manage "normal" fonts, because the hidden system fonts
|
// shared fontlist to manage "normal" fonts, because the hidden system fonts
|
||||||
// may be excluded from the font list altogether. This family will be
|
// may be excluded from the font list altogether. This family will be
|
||||||
// populated based on the given NSFont.
|
// populated based on the given NSFont.
|
||||||
NSFont* sys = [NSFont systemFontOfSize:0.0];
|
|
||||||
RefPtr<gfxFontFamily> fam = new gfxMacFontFamily(mSystemFontFamilyName, sys);
|
RefPtr<gfxFontFamily> fam = new gfxMacFontFamily(mSystemFontFamilyName, sys);
|
||||||
if (fam) {
|
if (fam) {
|
||||||
nsAutoCString key;
|
nsAutoCString key;
|
||||||
|
|||||||
@@ -64,8 +64,6 @@ void gfxPlatformMac::FontRegistrationCallback(void* aUnused) {
|
|||||||
for (const auto& dir : kLangFontsDirs) {
|
for (const auto& dir : kLangFontsDirs) {
|
||||||
gfxMacPlatformFontList::ActivateFontsFromDir(dir);
|
gfxMacPlatformFontList::ActivateFontsFromDir(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfxMacPlatformFontList::GetSystemFontName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PRThread* gfxPlatformMac::sFontRegistrationThread = nullptr;
|
PRThread* gfxPlatformMac::sFontRegistrationThread = nullptr;
|
||||||
@@ -76,21 +74,12 @@ PRThread* gfxPlatformMac::sFontRegistrationThread = nullptr;
|
|||||||
our font list. */
|
our font list. */
|
||||||
/* static */
|
/* static */
|
||||||
void gfxPlatformMac::RegisterSupplementalFonts() {
|
void gfxPlatformMac::RegisterSupplementalFonts() {
|
||||||
switch (XRE_GetProcessType()) {
|
// On Catalina+, it appears to be sufficient to activate fonts in the parent
|
||||||
case GeckoProcessType_Default:
|
// process; they are then also usable in child processes.
|
||||||
case GeckoProcessType_Content:
|
if (XRE_IsParentProcess()) {
|
||||||
// TODO: figure out if this matters to any other processes (e.g. GPU?)
|
|
||||||
//
|
|
||||||
// We activate the fonts on a separate thread, to minimize the startup-
|
|
||||||
// time cost.
|
|
||||||
sFontRegistrationThread = PR_CreateThread(
|
sFontRegistrationThread = PR_CreateThread(
|
||||||
PR_USER_THREAD, FontRegistrationCallback, nullptr, PR_PRIORITY_NORMAL,
|
PR_USER_THREAD, FontRegistrationCallback, nullptr, PR_PRIORITY_NORMAL,
|
||||||
PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);
|
PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
// Assume other process types don't actually need the full font list.
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,6 @@ class gfxPlatformMac : public gfxPlatform {
|
|||||||
|
|
||||||
static void FontRegistrationCallback(void* aUnused);
|
static void FontRegistrationCallback(void* aUnused);
|
||||||
|
|
||||||
nsCString mSystemFontName;
|
|
||||||
uint32_t mFontAntiAliasingThreshold;
|
uint32_t mFontAntiAliasingThreshold;
|
||||||
|
|
||||||
static PRThread* sFontRegistrationThread;
|
static PRThread* sFontRegistrationThread;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use core_graphics::font::{CGFont, CGGlyph};
|
|||||||
use core_graphics::geometry::{CGAffineTransform, CGPoint, CGSize};
|
use core_graphics::geometry::{CGAffineTransform, CGPoint, CGSize};
|
||||||
use core_graphics::geometry::{CG_AFFINE_TRANSFORM_IDENTITY, CGRect};
|
use core_graphics::geometry::{CG_AFFINE_TRANSFORM_IDENTITY, CGRect};
|
||||||
use core_text;
|
use core_text;
|
||||||
use core_text::font::{CTFont, kCTFontOptionsPreferSystemFont};
|
use core_text::font::CTFont;
|
||||||
use core_text::font_descriptor::{CTFontDescriptor, kCTFontDefaultOrientation, kCTFontVariationAttribute};
|
use core_text::font_descriptor::{CTFontDescriptor, kCTFontDefaultOrientation, kCTFontVariationAttribute};
|
||||||
use core_text::font_manager;
|
use core_text::font_manager;
|
||||||
use euclid::default::Size2D;
|
use euclid::default::Size2D;
|
||||||
@@ -206,7 +206,7 @@ fn get_glyph_metrics(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn new_ct_font_with_variations(ct_font_desc: &CTFontDescriptor, size: f64, variations: &[FontVariation]) -> CTFont {
|
fn new_ct_font_with_variations(ct_font_desc: &CTFontDescriptor, size: f64, variations: &[FontVariation]) -> CTFont {
|
||||||
let ct_font = core_text::font::new_from_descriptor_and_options(ct_font_desc, size, kCTFontOptionsPreferSystemFont);
|
let ct_font = core_text::font::new_from_descriptor(ct_font_desc, size);
|
||||||
if variations.is_empty() {
|
if variations.is_empty() {
|
||||||
return ct_font;
|
return ct_font;
|
||||||
}
|
}
|
||||||
@@ -221,7 +221,7 @@ fn new_ct_font_with_variations(ct_font_desc: &CTFontDescriptor, size: f64, varia
|
|||||||
let variation_attribute = unsafe { CFString::wrap_under_get_rule(kCTFontVariationAttribute) };
|
let variation_attribute = unsafe { CFString::wrap_under_get_rule(kCTFontVariationAttribute) };
|
||||||
let attrs_dict = CFDictionary::from_CFType_pairs(&[(variation_attribute, vals_dict)]);
|
let attrs_dict = CFDictionary::from_CFType_pairs(&[(variation_attribute, vals_dict)]);
|
||||||
let ct_var_font_desc = ct_font.copy_descriptor().create_copy_with_attributes(attrs_dict.to_untyped()).unwrap();
|
let ct_var_font_desc = ct_font.copy_descriptor().create_copy_with_attributes(attrs_dict.to_untyped()).unwrap();
|
||||||
core_text::font::new_from_descriptor_and_options(&ct_var_font_desc, size, kCTFontOptionsPreferSystemFont)
|
core_text::font::new_from_descriptor(&ct_var_font_desc, size)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user