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

Richard Pospesel (@richard) git at gitlab.torproject.org
Wed Feb 22 11:25:31 UTC 2023



Richard Pospesel pushed to branch tor-browser-102.8.0esr-12.5-1 at The Tor Project / Applications / Tor Browser


Commits:
e4caa4f8 by Pier Angelo Vendrame at 2023-02-22T12:24:49+01:00
fixup! Bug 41116: Normalize system fonts.

Bug 41646: Fixes for the font normalization

- - - - -


1 changed file:

- layout/base/nsLayoutUtils.cpp


Changes:

=====================================
layout/base/nsLayoutUtils.cpp
=====================================
@@ -9565,10 +9565,44 @@ void nsLayoutUtils::ComputeSystemFont(nsFont* aSystemFont,
   gfxFontStyle fontStyle;
   nsAutoString systemFontName;
   if (aDocument->ShouldResistFingerprinting()) {
-#ifdef XP_MACOSX
+#if defined(XP_MACOSX)
     systemFontName = 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;
+        break;
+      case LookAndFeel::FontID::SmallCaption:
+        fontStyle.weight = gfxFontStyle::FontWeight(700);
+        // fall-through
+      case LookAndFeel::FontID::MessageBox:
+      case LookAndFeel::FontID::StatusBar:
+        fontStyle.size = 11;
+        break;
+      default:
+        fontStyle.size = 12;
+        break;
+    }
+#elif defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID)
+    // 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
+    // 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
+    // GNOME, too.
+    // 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;
 #endif
   } else if (!LookAndFeel::GetFont(aFontID, systemFontName, fontStyle)) {
     return;



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

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/e4caa4f866124f4b04ed3ec00447051a77e254f4
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/20230222/a53f197b/attachment-0001.htm>


More information about the tor-commits mailing list