Skip to content
Snippets Groups Projects
Verified Commit 43cb46cb authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame :jack_o_lantern:
Browse files

fixup! Bug 41116: Normalize system fonts.

Update to the latest proposal to upstream.
It fixes build issues on macOS.
parent 01637eae
Branches
Tags
1 merge request!694Bug 41796: Rebased on top of FIREFOX_ESR_115_BASE
......@@ -9676,43 +9676,37 @@ already_AddRefed<nsFontMetrics> nsLayoutUtils::GetMetricsFor(
return aPresContext->GetMetricsFor(font, params);
}
/* static */
void nsLayoutUtils::ComputeSystemFont(nsFont* aSystemFont,
LookAndFeel::FontID aFontID,
const nsFont& aDefaultVariableFont,
const Document* aDocument) {
gfxFontStyle fontStyle;
nsAutoString systemFontName;
if (aDocument->ShouldResistFingerprinting()) {
static void GetSpoofedSystemFontForRFP(LookAndFeel::FontID aFontID,
gfxFontStyle& aStyle, nsAString& aName) {
#if defined(XP_MACOSX)
systemFontName = u"-apple-system"_ns;
aName = u"-apple-system"_ns;
// Values taken from a macOS 10.15 system.
switch (aFontID) {
case LookAndFeel::FontID::Caption:
case LookAndFeel::FontID::Menu:
fontStyle.size = 13;
aStyle.size = 13;
break;
case LookAndFeel::FontID::SmallCaption:
fontStyle.weight = gfxFontStyle::FontWeight(700);
aStyle.weight = gfxFontStyle::FontWeight::BOLD;
// fall-through
case LookAndFeel::FontID::MessageBox:
case LookAndFeel::FontID::StatusBar:
fontStyle.size = 11;
aStyle.size = 11;
break;
default:
fontStyle.size = 12;
aStyle.size = 12;
break;
}
#elif defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID)
#elif defined(XP_WIN)
// Windows uses Segoe UI for Latin alphabets, but other fonts for some RTL
// languages, so we fallback to sans-serif to fall back to the user's
// default sans-serif. Size is 12px for all system fonts (tried in an en-US
// system).
// Several Android systems reported Roboto 12px, so similar to what Windows
// does.
systemFontName = u"sans-serif"_ns;
fontStyle.size = 12;
#else
aName = u"sans-serif"_ns;
aStyle.size = 12;
#elif !defined(MOZ_WIDGET_ANDROID)
// On Linux, there is not a default. For example, GNOME on Debian uses
// Cantarell, 14.667px. Ubuntu Mate uses the Ubuntu font, but also 14.667px.
// Fedora with KDE uses Noto Sans, 13.3333px, but it uses Noto Sans on
......@@ -9720,9 +9714,21 @@ void nsLayoutUtils::ComputeSystemFont(nsFont* aSystemFont,
// In general, Linux uses some sans-serif, but its size can vary between
// 12px and 16px. We chose 15px because it is what Firefox is doing for the
// UI font-size.
systemFontName = u"sans-serif"_ns;
fontStyle.size = 15;
aName = u"sans-serif"_ns;
aStyle.size = 15;
#endif
// No need to do anything on Android, as font and sizes are already fixed.
}
/* static */
void nsLayoutUtils::ComputeSystemFont(nsFont* aSystemFont,
LookAndFeel::FontID aFontID,
const nsFont& aDefaultVariableFont,
const Document* aDocument) {
gfxFontStyle fontStyle;
nsAutoString systemFontName;
if (aDocument->ShouldResistFingerprinting()) {
GetSpoofedSystemFontForRFP(aFontID, fontStyle, systemFontName);
} else if (!LookAndFeel::GetFont(aFontID, systemFontName, fontStyle)) {
return;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment