[tor-commits] [Git][tpo/applications/tor-browser][tor-browser-128.4.0esr-14.5-1] 2 commits: amend! Bug 41043: Hardcode the UI font on Linux

Pier Angelo Vendrame (@pierov) git at gitlab.torproject.org
Tue Oct 29 13:52:43 UTC 2024



Pier Angelo Vendrame pushed to branch tor-browser-128.4.0esr-14.5-1 at The Tor Project / Applications / Tor Browser


Commits:
7fdefc8e by Pier Angelo Vendrame at 2024-10-25T01:13:30+00:00
amend! Bug 41043: Hardcode the UI font on Linux

Bug 43140: Tighten up fonts on Linux.

We ship a fontconfig configuration to esnure all Linux users have the
same defaults and reduce the chances of fingerprinting.
We used to add this file in tor-browser-build, but some users might
skip it by using the browser executable without the wrapper script.
Therefore, we decided to activate the file with the FontConfig API
instead of the environment variables.

Bug 41043: Hardcode the UI font on Linux

The mechanism to choose the UI font does not play well with our
fontconfig configuration. As a result, the final criterion to choose
the font for the UI was its version.

Since we hardcode Arimo as a default sans-serif on preferences, we use
it also for the UI. FontConfig will fall back to some other font for
scripts Arimo does not cover as expected (we tested with Japanese).

Bug 43141: Hardcode system-ui to Arimo.

- - - - -
70283a2f by Pier Angelo Vendrame at 2024-10-28T09:11:14+01:00
fixup! Bug 41668: Tweaks to the Base Browser updater for Tor Browser

Bug 41786: Remove the add_if command we added for fontconfig.

We do not need it anymore, as we had the watershed update and, in any
case, we are movign the fonts.conf in tor-browser.git.

- - - - -


6 changed files:

- + browser/fonts/fonts.conf
- browser/fonts/moz.build
- gfx/thebes/gfxFcPlatformFontList.cpp
- tools/update-packaging/common.sh
- tools/update-packaging/make_full_update.sh
- tools/update-packaging/make_incremental_update.sh


Changes:

=====================================
browser/fonts/fonts.conf
=====================================
@@ -0,0 +1,183 @@
+<?xml version="1.0"?>
+<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
+<!--
+**DO NOT EDIT THIS FILE!**
+This file sets Tor Browser's bundled fonts as the only available system fonts
+and standardizes rendering settings.
+Any changes might deanonymize you, or expose you to fingerprinting vectors.
+-->
+<!--
+Derived from fonts.conf.in of Fontconfig.
+
+Copyright © 2000,2001,2002,2003,2004,2006,2007 Keith Packard
+Copyright © 2005 Patrick Lam
+Copyright © 2009 Roozbeh Pournader
+Copyright © 2008,2009 Red Hat, Inc.
+Copyright © 2008 Danilo Šegan
+Copyright © 2012 Google, Inc.
+
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation, and that the name of the author(s) not be used in
+advertising or publicity pertaining to distribution of the software without
+specific, written prior permission.  The authors make no
+representations about the suitability of this software for any purpose.  It
+is provided "as is" without express or implied warranty.
+
+THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+-->
+<fontconfig>
+
+<!-- Font directory list -->
+
+	<dir prefix="cwd">fonts</dir>
+
+<!--
+  Accept deprecated 'mono' alias, replacing it with 'monospace'
+-->
+	<match target="pattern">
+		<test qual="any" name="family">
+			<string>mono</string>
+		</test>
+		<edit name="family" mode="assign" binding="same">
+			<string>monospace</string>
+		</edit>
+	</match>
+
+<!--
+  Accept alternate 'sans serif' spelling, replacing it with 'sans-serif'
+-->
+	<match target="pattern">
+		<test qual="any" name="family">
+			<string>sans serif</string>
+		</test>
+		<edit name="family" mode="assign" binding="same">
+			<string>sans-serif</string>
+		</edit>
+	</match>
+
+<!--
+  Accept deprecated 'sans' alias, replacing it with 'sans-serif'
+-->
+	<match target="pattern">
+		<test qual="any" name="family">
+			<string>sans</string>
+		</test>
+		<edit name="family" mode="assign" binding="same">
+			<string>sans-serif</string>
+		</edit>
+	</match>
+
+<!--
+  Set our default generic families.
+-->
+	<match target="pattern">
+		<test qual="any" name="family">
+			<string>sans-serif</string>
+		</test>
+		<edit name="family" mode="assign" binding="same">
+			<string>Arimo</string>
+		</edit>
+	</match>
+	<match target="pattern">
+		<test qual="any" name="family">
+			<string>serif</string>
+		</test>
+		<edit name="family" mode="assign" binding="same">
+			<string>Tinos</string>
+		</edit>
+	</match>
+	<match target="pattern">
+		<test qual="any" name="family">
+			<string>monospace</string>
+		</test>
+		<edit name="family" mode="assign" binding="same">
+			<string>Cousine</string>
+		</edit>
+	</match>
+
+<!--
+  tor-browser#41799, tor-browser-build#41237: Add some aliases for
+  compatibility.
+-->
+	<match target="pattern">
+		<test qual="any" name="family">
+			<string>Arial</string>
+		</test>
+		<edit name="family" mode="assign" binding="same">
+			<string>Arimo</string>
+		</edit>
+	</match>
+	<match target="pattern">
+		<test qual="any" name="family">
+			<string>Times New Roman</string>
+		</test>
+		<edit name="family" mode="assign" binding="same">
+			<string>Tinos</string>
+		</edit>
+	</match>
+	<match target="pattern">
+		<test qual="any" name="family">
+			<string>Courier New</string>
+		</test>
+		<edit name="family" mode="assign" binding="same">
+			<string>Cousine</string>
+		</edit>
+	</match>
+	<match target="pattern">
+		<test qual="any" name="family">
+			<string>Helvetica</string>
+		</test>
+		<edit name="family" mode="assign" binding="same">
+			<string>Arimo</string>
+		</edit>
+	</match>
+	<match target="pattern">
+		<test qual="any" name="family">
+			<string>Times</string>
+		</test>
+		<edit name="family" mode="assign" binding="same">
+			<string>Tinos</string>
+		</edit>
+	</match>
+	<match target="pattern">
+		<test qual="any" name="family">
+			<string>Courier</string>
+		</test>
+		<edit name="family" mode="assign" binding="same">
+			<string>Cousine</string>
+		</edit>
+	</match>
+
+<!-- Font cache directory list -->
+
+	<cachedir prefix="xdg">fontconfig</cachedir>
+
+	<config>
+<!--
+  Rescan configuration every 30 seconds when FcFontSetList is called
+ -->
+		<rescan>
+			<int>30</int>
+		</rescan>
+	</config>
+
+	<!-- Standardize rendering settings. -->
+	<match target="pattern">
+		<edit name="antialias" mode="assign"><bool>true</bool></edit>
+		<edit name="autohint" mode="assign"><bool>false</bool></edit>
+		<edit name="hinting" mode="assign"><bool>true</bool></edit>
+		<edit name="hintstyle" mode="assign"><const>hintfull</const></edit>
+		<edit name="lcdfilter" mode="assign"><const>lcddefault</const></edit>
+		<edit name="rgba" mode="assign"><const>none</const></edit>
+	</match>
+</fontconfig>


=====================================
browser/fonts/moz.build
=====================================
@@ -7,3 +7,6 @@
 if CONFIG["MOZ_WIDGET_TOOLKIT"] in ("windows", "gtk"):
     DIST_SUBDIR = ""
     FINAL_TARGET_FILES.fonts += ["TwemojiMozilla.ttf"]
+
+if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
+    FINAL_TARGET_FILES.fonts += ["fonts.conf"]


=====================================
gfx/thebes/gfxFcPlatformFontList.cpp
=====================================
@@ -1352,12 +1352,39 @@ bool gfxFontconfigFont::ShouldHintMetrics() const {
   return !GetStyle()->printerFont;
 }
 
+static nsresult SetFontconfigConfigFile() {
+  nsCOMPtr<nsIProperties> dirSvc(
+      do_GetService("@mozilla.org/file/directory_service;1"));
+  NS_ENSURE_TRUE(dirSvc, NS_ERROR_NOT_AVAILABLE);
+  nsCOMPtr<nsIFile> appFile, confFile;
+  nsresult rv = dirSvc->Get(XRE_EXECUTABLE_FILE, NS_GET_IID(nsIFile),
+                            getter_AddRefs(appFile));
+  NS_ENSURE_SUCCESS(rv, rv);
+  rv = appFile->GetParent(getter_AddRefs(confFile));
+  NS_ENSURE_SUCCESS(rv, rv);
+  rv = confFile->AppendNative("fonts"_ns);
+  NS_ENSURE_SUCCESS(rv, rv);
+  rv = confFile->AppendNative("fonts.conf"_ns);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  nsAutoCString confPath;
+  rv = confFile->GetNativePath(confPath);
+  if (NS_WARN_IF(setenv("FONTCONFIG_FILE", confPath.BeginReading(), 1) != 0)) {
+    return NS_ERROR_FAILURE;
+  }
+  return NS_OK;
+}
+
 gfxFcPlatformFontList::gfxFcPlatformFontList()
     : mLocalNames(64),
       mGenericMappings(32),
       mFcSubstituteCache(64),
       mLastConfig(nullptr),
       mAlwaysUseFontconfigGenerics(true) {
+  if (NS_FAILED(SetFontconfigConfigFile())) {
+    NS_WARNING("Failed to set the fontconfig config file!");
+  }
+
   CheckFamilyList(kBaseFonts_Ubuntu_22_04);
   CheckFamilyList(kLangFonts_Ubuntu_22_04);
   CheckFamilyList(kBaseFonts_Ubuntu_20_04);


=====================================
tools/update-packaging/common.sh
=====================================
@@ -115,28 +115,6 @@ make_add_if_not_instruction() {
   echo "add-if-not \"$f\" \"$f\"" >> "$filev3"
 }
 
-check_for_add_if_update() {
-  add_if_file_chk="$1"
-
-  # tor-browser#41776: We will remove with the old fontconfig file manually
-  # outside the update process. So, let the updater add the file if there.
-  # TODO: Remove once we do a watershed release.
-  if [ "$add_if_file_chk" = "TorBrowser/Data/fontconfig/fonts.conf" ]; then
-    ## "true" *giggle*
-    return 0;
-  fi
-  ## 'false'... because this is bash. Oh yay!
-  return 1;
-}
-
-make_add_if_instruction() {
-  f="$1"
-  filev3="$2"
-
-  verbose_notice " add-if \"$f\" \"$f\""
-  echo "add-if \"$f\" \"$f\"" >> "$filev3"
-}
-
 make_addsymlink_instruction() {
   link="$1"
   target="$2"


=====================================
tools/update-packaging/make_full_update.sh
=====================================
@@ -106,9 +106,6 @@ for ((i=0; $i<$num_files; i=$i+1)); do
 
   if check_for_add_if_not_update "$f"; then
     make_add_if_not_instruction "$f" "$updatemanifestv3"
-  elif check_for_add_if_update "$f"; then
-    # TODO: Remove once we do a watershed release
-    make_add_if_instruction "$f" "$updatemanifestv3"
   else
     make_add_instruction "$f" "$updatemanifestv3"
   fi


=====================================
tools/update-packaging/make_incremental_update.sh
=====================================
@@ -216,17 +216,6 @@ for ((i=0; $i<$num_oldfiles; i=$i+1)); do
       continue 1
     fi
 
-    if check_for_add_if_update "$f"; then
-      # TODO: Remove once we do a watershed release
-      # The full workdir may not exist yet, so create it if necessary.
-      mkdir -p `dirname "$workdir/$f"`
-      $XZ $XZ_OPT --compress $BCJ_OPTIONS --lzma2 --format=xz --check=crc64 --force --stdout "$newdir/$f" > "$workdir/$f"
-      copy_perm "$newdir/$f" "$workdir/$f"
-      make_add_if_instruction "$f" "$updatemanifestv3"
-      archivefiles="$archivefiles \"$f\""
-      continue 1
-    fi
-
     if check_for_forced_update "$requested_forced_updates" "$f"; then
       # The full workdir may not exist yet, so create it if necessary.
       mkdir -p "$(dirname "$workdir/$f")"
@@ -335,9 +324,6 @@ for ((i=0; $i<$num_newfiles; i=$i+1)); do
 
   if check_for_add_if_not_update "$f"; then
     make_add_if_not_instruction "$f" "$updatemanifestv3"
-  elif check_for_add_if_update "$f"; then
-    # TODO: Remove once we do a watershed release
-    make_add_if_instruction "$f" "$updatemanifestv3"
   else
     make_add_instruction "$f" "$updatemanifestv3"
   fi



View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/cc1f52a56a3c2dce293c4da6edfef31fc7a1c3e0...70283a2f2939955e4a3c442825c6427390f956a4

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/cc1f52a56a3c2dce293c4da6edfef31fc7a1c3e0...70283a2f2939955e4a3c442825c6427390f956a4
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/20241029/66078f6f/attachment-0001.htm>


More information about the tor-commits mailing list