[tor-commits] [Git][tpo/applications/mullvad-browser][mullvad-browser-115.10.0esr-13.5-1] fixup! Bug 41116: Normalize system fonts.

richard (@richard) git at gitlab.torproject.org
Wed Apr 17 20:04:36 UTC 2024



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


Commits:
308ea305 by Pier Angelo Vendrame at 2024-04-17T20:03:35+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/mullvad-browser/-/commit/308ea3055049209720a037a3b8805bf70d31f6e4

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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tor-commits/attachments/20240417/628bb60e/attachment-0001.htm>


More information about the tor-commits mailing list