Bug 1902570: Enable "Stix Two Math" on macOS 13 and above. r=tjr

Differential Revision: https://phabricator.services.mozilla.com/D226945
This commit is contained in:
Fatih
2024-11-07 13:08:10 +00:00
parent 7c7c0a7f51
commit 7e1473d078
4 changed files with 52 additions and 3 deletions

View File

@@ -293,3 +293,7 @@ static const char* kBaseFonts[] = {
"Zapf Dingbats", "Zapf Dingbats",
"Zapfino", "Zapfino",
}; };
static const char* kBaseFonts_13_Higher[] = {
"Stix Two Math",
};

View File

@@ -3,6 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/Components.h"
#include "mozilla/Logging.h" #include "mozilla/Logging.h"
#include <algorithm> #include <algorithm>
@@ -152,6 +153,7 @@ void gfxSingleFaceMacFontFamily::ReadOtherFamilyNames(
gfxMacPlatformFontList::gfxMacPlatformFontList() : CoreTextFontList() { gfxMacPlatformFontList::gfxMacPlatformFontList() : CoreTextFontList() {
CheckFamilyList(kBaseFonts); CheckFamilyList(kBaseFonts);
CheckFamilyList(kBaseFonts_13_Higher);
// cache this in a static variable so that gfxMacFontFamily objects // cache this in a static variable so that gfxMacFontFamily objects
// don't have to repeatedly look it up // don't have to repeatedly look it up
@@ -162,6 +164,22 @@ gfxMacPlatformFontList::gfxMacPlatformFontList() : CoreTextFontList() {
gfxFontUtils::GetPrefsFontList("font.single-face-list", mSingleFaceFonts); gfxFontUtils::GetPrefsFontList("font.single-face-list", mSingleFaceFonts);
} }
using Device = nsIGfxInfo::FontVisibilityDeviceDetermination;
Device GetFontVisibilityDevice() {
if (!NS_IsMainThread()) {
return Device::MacOS_Unknown;
}
static Device fontVisibilityDevice = Device::Unassigned;
if (fontVisibilityDevice == Device::Unassigned) {
nsCOMPtr<nsIGfxInfo> gfxInfo = components::GfxInfo::Service();
NS_ENSURE_SUCCESS(
gfxInfo->GetFontVisibilityDetermination(&fontVisibilityDevice),
Device::MacOS_Unknown);
}
return fontVisibilityDevice;
}
FontVisibility gfxMacPlatformFontList::GetVisibilityForFamily( FontVisibility gfxMacPlatformFontList::GetVisibilityForFamily(
const nsACString& aName) const { const nsACString& aName) const {
if (aName[0] == '.' || aName.LowerCaseEqualsLiteral("lastresort")) { if (aName[0] == '.' || aName.LowerCaseEqualsLiteral("lastresort")) {
@@ -170,6 +188,10 @@ FontVisibility gfxMacPlatformFontList::GetVisibilityForFamily(
if (FamilyInList(aName, kBaseFonts)) { if (FamilyInList(aName, kBaseFonts)) {
return FontVisibility::Base; return FontVisibility::Base;
} }
if (GetFontVisibilityDevice() == Device::MacOS_13_plus &&
FamilyInList(aName, kBaseFonts_13_Higher)) {
return FontVisibility::Base;
}
#ifdef MOZ_BUNDLED_FONTS #ifdef MOZ_BUNDLED_FONTS
if (mBundledFamilies.Contains(aName)) { if (mBundledFamilies.Contains(aName)) {
return FontVisibility::Base; return FontVisibility::Base;
@@ -184,6 +206,11 @@ gfxMacPlatformFontList::GetFilteredPlatformFontLists() {
fontLists.AppendElement(std::make_pair(kBaseFonts, std::size(kBaseFonts))); fontLists.AppendElement(std::make_pair(kBaseFonts, std::size(kBaseFonts)));
if (GetFontVisibilityDevice() == Device::MacOS_13_plus) {
fontLists.AppendElement(
std::make_pair(kBaseFonts_13_Higher, std::size(kBaseFonts_13_Higher)));
}
return fontLists; return fontLists;
} }

View File

@@ -16,6 +16,7 @@
#include "js/PropertyAndElement.h" // JS_SetElement, JS_SetProperty #include "js/PropertyAndElement.h" // JS_SetElement, JS_SetProperty
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsCOMArray.h" #include "nsCOMArray.h"
#include "nsIPropertyBag2.h"
#include "nsString.h" #include "nsString.h"
#include "nsUnicharUtils.h" #include "nsUnicharUtils.h"
#include "nsVersionComparator.h" #include "nsVersionComparator.h"
@@ -50,6 +51,10 @@
# include "AndroidBuild.h" # include "AndroidBuild.h"
#endif #endif
#if defined(XP_MACOSX)
# include "nsCocoaFeatures.h"
#endif
using namespace mozilla::widget; using namespace mozilla::widget;
using namespace mozilla; using namespace mozilla;
using mozilla::MutexAutoLock; using mozilla::MutexAutoLock;
@@ -1758,8 +1763,19 @@ std::pair<Device, nsString>* GfxInfoBase::GetFontVisibilityDeterminationPair() {
} }
#elif defined(XP_MACOSX) #elif defined(XP_MACOSX)
ret->first = Device::MacOS_Platform; ret->first = Device::MacOS_Unknown;
ret->second.AppendASCII("macOS Platform"); ret->second.AppendASCII("macOS Platform");
int major = 0;
int minor = 0;
int bugfix = 0;
nsCocoaFeatures::GetSystemVersion(major, minor, bugfix);
if (major == 0) {
return ret;
}
ret->first = major >= 13 ? Device::MacOS_13_plus : Device::MacOS_sub_13;
ret->second.AppendPrintf("macOS %d.%d.%d", major, minor, bugfix);
#elif defined(XP_WIN) #elif defined(XP_WIN)
ret->first = Device::Windows_Platform; ret->first = Device::Windows_Platform;
ret->second.AppendASCII("Windows Platform"); ret->second.AppendASCII("Windows Platform");

View File

@@ -47,7 +47,7 @@ interface nsIGfxInfo : nsISupports
Unassigned = 0, Unassigned = 0,
Unknown_Platform = 1, Unknown_Platform = 1,
Windows_Platform = 2, Windows_Platform = 2,
MacOS_Platform = 3, MacOS_Unknown = 3,
Android_Unknown_Release_Version = 4, Android_Unknown_Release_Version = 4,
Android_Unknown_Peloton = 5, Android_Unknown_Peloton = 5,
Android_Unknown_vbox = 6, Android_Unknown_vbox = 6,
@@ -63,7 +63,9 @@ interface nsIGfxInfo : nsISupports
Linux_Ubuntu_22 = 16, Linux_Ubuntu_22 = 16,
Linux_Fedora_any = 17, Linux_Fedora_any = 17,
Linux_Fedora_38 = 18, Linux_Fedora_38 = 18,
Linux_Fedora_39 = 19 Linux_Fedora_39 = 19,
MacOS_13_plus = 20,
MacOS_sub_13 = 21
}; };
readonly attribute nsIGfxInfo_FontVisibilityDeviceDetermination fontVisibilityDetermination; readonly attribute nsIGfxInfo_FontVisibilityDeviceDetermination fontVisibilityDetermination;
readonly attribute AString fontVisibilityDeterminationStr; readonly attribute AString fontVisibilityDeterminationStr;