[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



Title: GitLab

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

Commits:

  • 4e14cbf3
    by Pier Angelo Vendrame at 2024-10-29T14:56:34+01: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.
    

3 changed files:

Changes:

  • browser/fonts/fonts.conf
    1
    +<?xml version="1.0"?>
    
    2
    +<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
    
    3
    +<!--
    
    4
    +**DO NOT EDIT THIS FILE!**
    
    5
    +This file sets Tor Browser's bundled fonts as the only available system fonts
    
    6
    +and standardizes rendering settings.
    
    7
    +Any changes might deanonymize you, or expose you to fingerprinting vectors.
    
    8
    +-->
    
    9
    +<!--
    
    10
    +Derived from fonts.conf.in of Fontconfig.
    
    11
    +
    
    12
    +Copyright © 2000,2001,2002,2003,2004,2006,2007 Keith Packard
    
    13
    +Copyright © 2005 Patrick Lam
    
    14
    +Copyright © 2009 Roozbeh Pournader
    
    15
    +Copyright © 2008,2009 Red Hat, Inc.
    
    16
    +Copyright © 2008 Danilo Šegan
    
    17
    +Copyright © 2012 Google, Inc.
    
    18
    +
    
    19
    +
    
    20
    +Permission to use, copy, modify, distribute, and sell this software and its
    
    21
    +documentation for any purpose is hereby granted without fee, provided that
    
    22
    +the above copyright notice appear in all copies and that both that
    
    23
    +copyright notice and this permission notice appear in supporting
    
    24
    +documentation, and that the name of the author(s) not be used in
    
    25
    +advertising or publicity pertaining to distribution of the software without
    
    26
    +specific, written prior permission.  The authors make no
    
    27
    +representations about the suitability of this software for any purpose.  It
    
    28
    +is provided "as is" without express or implied warranty.
    
    29
    +
    
    30
    +THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
    
    31
    +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
    
    32
    +EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
    
    33
    +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
    
    34
    +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
    
    35
    +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    
    36
    +PERFORMANCE OF THIS SOFTWARE.
    
    37
    +-->
    
    38
    +<fontconfig>
    
    39
    +
    
    40
    +<!-- Font directory list -->
    
    41
    +
    
    42
    +	<dir prefix="cwd">fonts</dir>
    
    43
    +
    
    44
    +<!--
    
    45
    +  Accept deprecated 'mono' alias, replacing it with 'monospace'
    
    46
    +-->
    
    47
    +	<match target="pattern">
    
    48
    +		<test qual="any" name="family">
    
    49
    +			<string>mono</string>
    
    50
    +		</test>
    
    51
    +		<edit name="family" mode="assign" binding="same">
    
    52
    +			<string>monospace</string>
    
    53
    +		</edit>
    
    54
    +	</match>
    
    55
    +
    
    56
    +<!--
    
    57
    +  Accept alternate 'sans serif' spelling, replacing it with 'sans-serif'
    
    58
    +-->
    
    59
    +	<match target="pattern">
    
    60
    +		<test qual="any" name="family">
    
    61
    +			<string>sans serif</string>
    
    62
    +		</test>
    
    63
    +		<edit name="family" mode="assign" binding="same">
    
    64
    +			<string>sans-serif</string>
    
    65
    +		</edit>
    
    66
    +	</match>
    
    67
    +
    
    68
    +<!--
    
    69
    +  Accept deprecated 'sans' alias, replacing it with 'sans-serif'
    
    70
    +-->
    
    71
    +	<match target="pattern">
    
    72
    +		<test qual="any" name="family">
    
    73
    +			<string>sans</string>
    
    74
    +		</test>
    
    75
    +		<edit name="family" mode="assign" binding="same">
    
    76
    +			<string>sans-serif</string>
    
    77
    +		</edit>
    
    78
    +	</match>
    
    79
    +
    
    80
    +<!--
    
    81
    +  Set our default generic families.
    
    82
    +-->
    
    83
    +	<match target="pattern">
    
    84
    +		<test qual="any" name="family">
    
    85
    +			<string>sans-serif</string>
    
    86
    +		</test>
    
    87
    +		<edit name="family" mode="assign" binding="same">
    
    88
    +			<string>Arimo</string>
    
    89
    +		</edit>
    
    90
    +	</match>
    
    91
    +	<match target="pattern">
    
    92
    +		<test qual="any" name="family">
    
    93
    +			<string>serif</string>
    
    94
    +		</test>
    
    95
    +		<edit name="family" mode="assign" binding="same">
    
    96
    +			<string>Tinos</string>
    
    97
    +		</edit>
    
    98
    +	</match>
    
    99
    +	<match target="pattern">
    
    100
    +		<test qual="any" name="family">
    
    101
    +			<string>monospace</string>
    
    102
    +		</test>
    
    103
    +		<edit name="family" mode="assign" binding="same">
    
    104
    +			<string>Cousine</string>
    
    105
    +		</edit>
    
    106
    +	</match>
    
    107
    +
    
    108
    +<!--
    
    109
    +  tor-browser#41799, tor-browser-build#41237: Add some aliases for
    
    110
    +  compatibility.
    
    111
    +-->
    
    112
    +	<match target="pattern">
    
    113
    +		<test qual="any" name="family">
    
    114
    +			<string>Arial</string>
    
    115
    +		</test>
    
    116
    +		<edit name="family" mode="assign" binding="same">
    
    117
    +			<string>Arimo</string>
    
    118
    +		</edit>
    
    119
    +	</match>
    
    120
    +	<match target="pattern">
    
    121
    +		<test qual="any" name="family">
    
    122
    +			<string>Times New Roman</string>
    
    123
    +		</test>
    
    124
    +		<edit name="family" mode="assign" binding="same">
    
    125
    +			<string>Tinos</string>
    
    126
    +		</edit>
    
    127
    +	</match>
    
    128
    +	<match target="pattern">
    
    129
    +		<test qual="any" name="family">
    
    130
    +			<string>Courier New</string>
    
    131
    +		</test>
    
    132
    +		<edit name="family" mode="assign" binding="same">
    
    133
    +			<string>Cousine</string>
    
    134
    +		</edit>
    
    135
    +	</match>
    
    136
    +	<match target="pattern">
    
    137
    +		<test qual="any" name="family">
    
    138
    +			<string>Helvetica</string>
    
    139
    +		</test>
    
    140
    +		<edit name="family" mode="assign" binding="same">
    
    141
    +			<string>Arimo</string>
    
    142
    +		</edit>
    
    143
    +	</match>
    
    144
    +	<match target="pattern">
    
    145
    +		<test qual="any" name="family">
    
    146
    +			<string>Times</string>
    
    147
    +		</test>
    
    148
    +		<edit name="family" mode="assign" binding="same">
    
    149
    +			<string>Tinos</string>
    
    150
    +		</edit>
    
    151
    +	</match>
    
    152
    +	<match target="pattern">
    
    153
    +		<test qual="any" name="family">
    
    154
    +			<string>Courier</string>
    
    155
    +		</test>
    
    156
    +		<edit name="family" mode="assign" binding="same">
    
    157
    +			<string>Cousine</string>
    
    158
    +		</edit>
    
    159
    +	</match>
    
    160
    +
    
    161
    +<!-- Font cache directory list -->
    
    162
    +
    
    163
    +	<cachedir prefix="xdg">fontconfig</cachedir>
    
    164
    +
    
    165
    +	<config>
    
    166
    +<!--
    
    167
    +  Rescan configuration every 30 seconds when FcFontSetList is called
    
    168
    + -->
    
    169
    +		<rescan>
    
    170
    +			<int>30</int>
    
    171
    +		</rescan>
    
    172
    +	</config>
    
    173
    +
    
    174
    +	<!-- Standardize rendering settings. -->
    
    175
    +	<match target="pattern">
    
    176
    +		<edit name="antialias" mode="assign"><bool>true</bool></edit>
    
    177
    +		<edit name="autohint" mode="assign"><bool>false</bool></edit>
    
    178
    +		<edit name="hinting" mode="assign"><bool>true</bool></edit>
    
    179
    +		<edit name="hintstyle" mode="assign"><const>hintfull</const></edit>
    
    180
    +		<edit name="lcdfilter" mode="assign"><const>lcddefault</const></edit>
    
    181
    +		<edit name="rgba" mode="assign"><const>none</const></edit>
    
    182
    +	</match>
    
    183
    +</fontconfig>

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

  • gfx/thebes/gfxFcPlatformFontList.cpp
    ... ... @@ -1352,12 +1352,39 @@ bool gfxFontconfigFont::ShouldHintMetrics() const {
    1352 1352
       return !GetStyle()->printerFont;
    
    1353 1353
     }
    
    1354 1354
     
    
    1355
    +static nsresult SetFontconfigConfigFile() {
    
    1356
    +  nsCOMPtr<nsIProperties> dirSvc(
    
    1357
    +      do_GetService("@mozilla.org/file/directory_service;1"));
    
    1358
    +  NS_ENSURE_TRUE(dirSvc, NS_ERROR_NOT_AVAILABLE);
    
    1359
    +  nsCOMPtr<nsIFile> appFile, confFile;
    
    1360
    +  nsresult rv = dirSvc->Get(XRE_EXECUTABLE_FILE, NS_GET_IID(nsIFile),
    
    1361
    +                            getter_AddRefs(appFile));
    
    1362
    +  NS_ENSURE_SUCCESS(rv, rv);
    
    1363
    +  rv = appFile->GetParent(getter_AddRefs(confFile));
    
    1364
    +  NS_ENSURE_SUCCESS(rv, rv);
    
    1365
    +  rv = confFile->AppendNative("fonts"_ns);
    
    1366
    +  NS_ENSURE_SUCCESS(rv, rv);
    
    1367
    +  rv = confFile->AppendNative("fonts.conf"_ns);
    
    1368
    +  NS_ENSURE_SUCCESS(rv, rv);
    
    1369
    +
    
    1370
    +  nsAutoCString confPath;
    
    1371
    +  rv = confFile->GetNativePath(confPath);
    
    1372
    +  if (setenv("FONTCONFIG_FILE", confPath.BeginReading(), 1) != 0) {
    
    1373
    +    return NS_ERROR_FAILURE;
    
    1374
    +  }
    
    1375
    +  return NS_OK;
    
    1376
    +}
    
    1377
    +
    
    1355 1378
     gfxFcPlatformFontList::gfxFcPlatformFontList()
    
    1356 1379
         : mLocalNames(64),
    
    1357 1380
           mGenericMappings(32),
    
    1358 1381
           mFcSubstituteCache(64),
    
    1359 1382
           mLastConfig(nullptr),
    
    1360 1383
           mAlwaysUseFontconfigGenerics(true) {
    
    1384
    +  if (NS_FAILED(SetFontconfigConfigFile())) {
    
    1385
    +    NS_WARNING("Failed to set the fontconfig config file!");
    
    1386
    +  }
    
    1387
    +
    
    1361 1388
       CheckFamilyList(kBaseFonts_Ubuntu_22_04);
    
    1362 1389
       CheckFamilyList(kLangFonts_Ubuntu_22_04);
    
    1363 1390
       CheckFamilyList(kBaseFonts_Ubuntu_20_04);
    

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