richard pushed to branch base-browser-115.10.0esr-13.5-1 at The Tor Project / 
Applications / Tor Browser


Commits:
cf32ac1d by Pier Angelo Vendrame at 2024-04-17T20:02:25+00:00
fixup! Bug 41116: Normalize system fonts.

Bug 42529: Fix the breakage of this patch on Android.

Also, improve the patch hoping I can finally uplift it.

- - - - -


2 changed files:

- gfx/thebes/gfxPlatformFontList.cpp
- layout/base/nsLayoutUtils.cpp


Changes:

=====================================
gfx/thebes/gfxPlatformFontList.cpp
=====================================
@@ -38,6 +38,7 @@
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/ContentProcessMessageManager.h"
+#include "mozilla/dom/Document.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/ipc/FileDescriptorUtils.h"
 #include "mozilla/ResultExtensions.h"
@@ -1964,20 +1965,27 @@ void 
gfxPlatformFontList::MaybeRemoveCmap(gfxCharacterMap* aCharMap) {
   }
 }
 
-static void GetSystemUIFontFamilies([[maybe_unused]] nsAtom* aLangGroup,
+static void GetSystemUIFontFamilies(const nsPresContext* aPresContext,
+                                    [[maybe_unused]] nsAtom* aLangGroup,
                                     nsTArray<nsCString>& aFamilies) {
   // TODO: On macOS, use CTCreateUIFontForLanguage or such thing (though the
   // code below ends up using [NSFont systemFontOfSize: 0.0].
   nsFont systemFont;
   gfxFontStyle fontStyle;
   nsAutoString systemFontName;
-  if (nsContentUtils::ShouldResistFingerprinting()) {
+  if (aPresContext && aPresContext->Document()
+                 ? aPresContext->Document()->ShouldResistFingerprinting(
+                       RFPTarget::Unknown)
+                 : nsContentUtils::ShouldResistFingerprinting(
+                       "aPresContext not available", RFPTarget::Unknown)) {
 #ifdef XP_MACOSX
     *aFamilies.AppendElement() = "-apple-system"_ns;
-#else
+    return;
+#elif !defined(MOZ_WIDGET_ANDROID)
     *aFamilies.AppendElement() = "sans-serif"_ns;
-#endif
     return;
+#endif
+    // Android uses already fixed fonts.
   }
   if (!LookAndFeel::GetFont(StyleSystemFont::Menu, systemFontName, fontStyle)) 
{
     return;
@@ -2014,7 +2022,7 @@ void gfxPlatformFontList::ResolveGenericFontNames(
   MOZ_ASSERT(langGroup, "null lang group for pref lang");
 
   if (aGenericType == StyleGenericFontFamily::SystemUi) {
-    GetSystemUIFontFamilies(langGroup, genericFamilies);
+    GetSystemUIFontFamilies(aPresContext, langGroup, genericFamilies);
   }
 
   GetFontFamiliesFromGenericFamilies(


=====================================
layout/base/nsLayoutUtils.cpp
=====================================
@@ -9708,7 +9708,10 @@ static void 
GetSpoofedSystemFontForRFP(LookAndFeel::FontID aFontID,
   // does.
   aName = u"sans-serif"_ns;
   aStyle.size = 12;
-#elif !defined(MOZ_WIDGET_ANDROID)
+#elif defined(MOZ_WIDGET_ANDROID)
+  aName = u"Roboto"_ns;
+  aStyle.size = 12;
+#else
   // 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
@@ -9719,7 +9722,6 @@ static void 
GetSpoofedSystemFontForRFP(LookAndFeel::FontID aFontID,
   aName = u"sans-serif"_ns;
   aStyle.size = 15;
 #endif
-  // No need to do anything on Android, as font and sizes are already fixed.
 }
 
 /* static */



View it on GitLab: 
https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/cf32ac1da8c9636c1ab6a93bf117053960802079

-- 
View it on GitLab: 
https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/cf32ac1da8c9636c1ab6a93bf117053960802079
You're receiving this email because of your account on gitlab.torproject.org.


_______________________________________________
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits

Reply via email to