Bug 1244017 - remove system font cascade for OSX. r=m_kato

This commit is contained in:
John Daggett 2016-02-08 15:26:50 +09:00
Родитель e100555d17
Коммит cb1a460415
5 изменённых файлов: 1 добавлений и 171 удалений

Просмотреть файл

@ -667,8 +667,7 @@ public:
mIsBadUnderlineFamily(false),
mFamilyCharacterMapInitialized(false),
mSkipDefaultFeatureSpaceCheck(false),
mCheckForFallbackFaces(false),
mLinkedSystemFamily(false)
mCheckForFallbackFaces(false)
{ }
const nsString& Name() { return mName; }
@ -797,9 +796,6 @@ public:
mSkipDefaultFeatureSpaceCheck = aSkipCheck;
}
bool LinkedSystemFamily() const { return mLinkedSystemFamily; }
void SetLinkedSystemFamily() { mLinkedSystemFamily = true; }
protected:
// Protected destructor, to discourage deletion outside of Release():
virtual ~gfxFontFamily()
@ -832,7 +828,6 @@ protected:
bool mFamilyCharacterMapInitialized : 1;
bool mSkipDefaultFeatureSpaceCheck : 1;
bool mCheckForFallbackFaces : 1; // check other faces for character
bool mLinkedSystemFamily : 1; // system fonts linked to other families
enum {
// for "simple" families, the faces are stored in mAvailableFonts

Просмотреть файл

@ -106,10 +106,6 @@ public:
gfxFontStyle &aFontStyle,
float aDevPixPerCSSPixel);
virtual void
AppendLinkedSystemFamilies(nsIAtom* aLanguage,
nsTArray<gfxFontFamily*>& aFamilyList) override;
private:
friend class gfxPlatformMac;
@ -125,10 +121,6 @@ private:
// initialize system fonts
void InitSystemFonts();
// helper function for looking up font cascades
void LookupFontCascadeForLang(const nsACString& aLang,
nsTArray<gfxFontFamily*>& aCascadeList);
// helper function to lookup in both hidden system fonts and normal fonts
gfxFontFamily* FindSystemFontFamily(const nsAString& aFamily);
@ -178,20 +170,6 @@ private:
bool mUseSizeSensitiveSystemFont;
RefPtr<gfxFontFamily> mSystemTextFontFamily;
RefPtr<gfxFontFamily> mSystemDisplayFontFamily; // only used on OSX 10.11
// system font cascade - under OSX, the system font is effectively
// not a single family but a fontlist with the Latin font at the end
// of the list (e.g. Lucida Grande, Helevetica Neue, San Francisco)
// most languages use a common default set of choices matching lang=en
PrefFontList mDefaultCascadeFamilies;
// for languages where the fontlist doesn't match the default list
// (e.g. zh-TW will prioritize the traditional Chinese font over the
// Japanese font)
nsBaseHashtable<nsCStringHashKey,
nsAutoPtr<PrefFontList>,
PrefFontList*> mNonDefaultCascadeFamilies;
};
#endif /* gfxMacPlatformFontList_H_ */

Просмотреть файл

@ -623,10 +623,6 @@ gfxSingleFaceMacFontFamily::ReadOtherFamilyNames(gfxPlatformFontList *aPlatformF
mOtherFamilyNamesInitialized = true;
}
typedef CFArrayRef (CTFontCopyDefaultCascadeListForLanguagesFunc)(CTFontRef font, CFArrayRef languagePrefList);
static CTFontCopyDefaultCascadeListForLanguagesFunc*
CTFontCopyDefaultCascadeListForLanguagesPtr = nullptr;
/* gfxMacPlatformFontList */
#pragma mark-
@ -649,11 +645,6 @@ gfxMacPlatformFontList::gfxMacPlatformFontList() :
// cache this in a static variable so that MacOSFontFamily objects
// don't have to repeatedly look it up
sFontManager = [NSFontManager sharedFontManager];
// available in 10.8 and above
CTFontCopyDefaultCascadeListForLanguagesPtr =
(CTFontCopyDefaultCascadeListForLanguagesFunc*)
dlsym(RTLD_DEFAULT, "CTFontCopyDefaultCascadeListForLanguages");
}
gfxMacPlatformFontList::~gfxMacPlatformFontList()
@ -791,63 +782,6 @@ static NSString* GetRealFamilyName(NSFont* aFont)
const CGFloat kTextDisplayCrossover = 20.0; // use text family below this size
void
gfxMacPlatformFontList::LookupFontCascadeForLang(const nsACString& aLang,
nsTArray<gfxFontFamily*>& aCascadeList)
{
// if cascade not available just return empty list
if (!CTFontCopyDefaultCascadeListForLanguagesPtr) {
return;
}
// get the system font (note: the lang parameter doesn't affect the result)
CTFontRef systemFont =
CTFontCreateUIFontForLanguage(kCTFontSystemFontType, 12.0,
CFSTR("en-US"));
// fetch cascade list
CFStringRef langStr =
CFStringCreateWithCString(kCFAllocatorDefault,
PromiseFlatCString(aLang).get(),
kCFStringEncodingUTF8);
CFStringRef languages[1] = { langStr };
CFArrayRef langList = CFArrayCreate(kCFAllocatorDefault,
(const void **) languages, 1,
&kCFTypeArrayCallBacks);
CFRelease(langStr);
CFArrayRef cascade =
CTFontCopyDefaultCascadeListForLanguagesPtr(systemFont, langList);
CFRelease(systemFont);
CFRelease(langList);
// iterate over font descriptors in cascade array
for (NSFontDescriptor* fontDesc in (NSArray*) cascade) {
// First, determine the font family name. Since font cascades
// sometimes include weird "meta" names, need to determine the
// family name using the CGFont object
CTFontDescriptorRef fd = (CTFontDescriptorRef) fontDesc;
CTFontRef fontRef = CTFontCreateWithFontDescriptor(fd, 0.0, 0);
CFRelease(fd);
CGFontRef cgFontRef = CTFontCopyGraphicsFont(fontRef, NULL);
CFRelease(fontRef);
CFStringRef psname = CGFontCopyPostScriptName(cgFontRef);
CFRelease(cgFontRef);
fontRef = CTFontCreateWithName(psname, 0.0, NULL);
CFRelease(psname);
CFStringRef name = CTFontCopyFamilyName(fontRef);
CFRelease(fontRef);
// lookup the family and append it to the list
nsAutoString familyStr;
GetStringForNSString((NSString*) name, familyStr);
CFRelease(name);
gfxFontFamily* family = FindFamily(familyStr);
if (family) {
aCascadeList.AppendElement(family);
}
}
}
void
gfxMacPlatformFontList::InitSystemFonts()
{
@ -863,7 +797,6 @@ gfxMacPlatformFontList::InitSystemFonts()
nsCocoaUtils::GetStringForNSString(textFamilyName, familyName);
mSystemTextFontFamily = FindSystemFontFamily(familyName);
NS_ASSERTION(mSystemTextFontFamily, "null system display font family");
mSystemTextFontFamily->SetLinkedSystemFamily();
// display font family, if on OSX 10.11
if (mUseSizeSensitiveSystemFont) {
@ -872,7 +805,6 @@ gfxMacPlatformFontList::InitSystemFonts()
nsCocoaUtils::GetStringForNSString(displayFamilyName, familyName);
mSystemDisplayFontFamily = FindSystemFontFamily(familyName);
NS_ASSERTION(mSystemDisplayFontFamily, "null system display font family");
mSystemDisplayFontFamily->SetLinkedSystemFamily();
#if DEBUG
// confirm that the optical size switch is at 20.0
@ -900,11 +832,6 @@ gfxMacPlatformFontList::InitSystemFonts()
" -- please log a bug!!");
}
#endif
nsAutoCString en("en");
AutoTArray<gfxFontFamily*,10> list;
LookupFontCascadeForLang(en, list);
mDefaultCascadeFamilies.AppendElements(list);
}
gfxFontFamily*
@ -1252,66 +1179,6 @@ gfxMacPlatformFontList::LookupSystemFont(LookAndFeel::FontID aSystemFontID,
aFontStyle.systemFont = true;
}
void
gfxMacPlatformFontList::AppendLinkedSystemFamilies(nsIAtom* aLanguage,
nsTArray<gfxFontFamily*>& aFamilyList)
{
// map lang atom to lang string
nsAutoCString lang;
GetSampleLangForGroup(aLanguage, lang, false);
ToLowerCase(lang);
// quick exit for older versions of OSX
if (mDefaultCascadeFamilies.IsEmpty()) {
return;
}
// assume default cascade except for CJK locales
bool defaultCascade = true;
if (lang.Length() >= 2) {
const nsACString& langTag = Substring(lang, 0, 2);
if (langTag.EqualsLiteral("zh")) {
defaultCascade = false;
// the font cascade code is fussy about the hyphen/underbar before
// the region code, so zh_TW is recognized, zh-TW is ignored
if (lang.EqualsLiteral("zh-tw")) {
lang.AssignLiteral("zh_tw");
} else if (lang.EqualsLiteral("zh-cn")) {
lang.AssignLiteral("zh_cn");
} else if (lang.EqualsLiteral("zh-hk")) {
lang.AssignLiteral("zh_hk");
}
} else if (langTag.EqualsLiteral("ja") ||
langTag.EqualsLiteral("ko")) {
defaultCascade = false;
}
}
if (defaultCascade) {
aFamilyList.AppendElements(mDefaultCascadeFamilies);
return;
}
// check to see if cached already
PrefFontList* fontsForLang = mNonDefaultCascadeFamilies.Get(lang);
if (fontsForLang) {
aFamilyList.AppendElements(*fontsForLang);
return;
}
// lookup the cascade fonts
AutoTArray<gfxFontFamily*,30> list;
LookupFontCascadeForLang(lang, list);
// add cascade to cascade cache
fontsForLang = new PrefFontList;
fontsForLang->AppendElements(list);
mNonDefaultCascadeFamilies.Put(lang, fontsForLang);
// use the new list
aFamilyList.AppendElements(list);
}
// used to load system-wide font info on off-main thread
class MacFontInfo : public FontInfoData {
public:

Просмотреть файл

@ -200,10 +200,6 @@ public:
aLoaderState = (uint32_t) mState;
}
// for platforms that use linked system fontlists, append these
virtual void
AppendLinkedSystemFamilies(nsIAtom* aLanguage,
nsTArray<gfxFontFamily*>& aFamilyList) {}
virtual void
AddGenericFonts(mozilla::FontFamilyType aGenericType,
nsIAtom* aLanguage,

Просмотреть файл

@ -1669,12 +1669,6 @@ gfxFontGroup::AddPlatformFont(const nsAString& aName,
if (family) {
aFamilyList.AppendElement(family);
// In some cases, system generic fonts are linked to a set of
// families, so include these if that's the case
if (family->LinkedSystemFamily()) {
fontList->AppendLinkedSystemFamilies(mStyle.language,
aFamilyList);
}
}
}