tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 0d7541332615737a7afb4f479c6db02e83edb4ba
parent b51c2770abcc9d5e3fcd5989ac6a5baa613ebd7d
Author: Pier Angelo Vendrame <pierov@torproject.org>
Date:   Tue, 26 Nov 2024 19:37:25 +0100

BB 43322: Customize the font visibility lists.

Customize the lists of fonts to assign base visibility to in
base browser and derivatives.

Also, rename the files with the upstream lists, to make sure we do not
use them by mistake.

Diffstat:
Agfx/thebes/StandardFonts-macos-bb.inc | 33+++++++++++++++++++++++++++++++++
Mgfx/thebes/StandardFonts-macos.inc | 2+-
Agfx/thebes/StandardFonts-win10-bb.inc | 25+++++++++++++++++++++++++
Mgfx/thebes/StandardFonts-win10.inc | 3+++
Mgfx/thebes/gfxDWriteFontList.cpp | 7+++++++
Mgfx/thebes/gfxFcPlatformFontList.cpp | 18++++++++++++++----
Mgfx/thebes/gfxMacPlatformFontList.mm | 8+++++++-
7 files changed, 90 insertions(+), 6 deletions(-)

diff --git a/gfx/thebes/StandardFonts-macos-bb.inc b/gfx/thebes/StandardFonts-macos-bb.inc @@ -0,0 +1,33 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +static const char* kBaseFonts[] = { + "Apple Color Emoji", + "AppleGothic", + "Arial", + "Arial Black", + "Arial Narrow", + "Courier", + "Courier New", + "Geneva", + "Georgia", + "Heiti TC", + "Helvetica", + "Helvetica Neue", + "Hiragino Kaku Gothic ProN", + "Kailasa", + "Lucida Grande", + "Menlo", + "Monaco", + "PingFang HK", + "PingFang SC", + "PingFang TC", + "Songti SC", + "Songti TC", + "Tahoma", + "Thonburi", + "Times", + "Times New Roman", + "Verdana", +}; diff --git a/gfx/thebes/StandardFonts-macos.inc b/gfx/thebes/StandardFonts-macos.inc @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifdef StandardFonts +#if defined(StandardFonts) && !defined(BASE_BROWSER_VERSION) // List of standard font families installed as part of macOS 10.15 "Catalina" // from https://developer.apple.com/fonts/system-fonts/ diff --git a/gfx/thebes/StandardFonts-win10-bb.inc b/gfx/thebes/StandardFonts-win10-bb.inc @@ -0,0 +1,25 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +static const char* kBaseFonts[] = { + "Arial", + "Cambria Math", + "Consolas", + "Courier New", + "Georgia", + "Lucida Console", + "Malgun Gothic", + "Microsoft Himalaya", + "Microsoft JhengHei", + "Microsoft YaHei", + "MS Gothic", + "MS PGothic", + "MV Boli", + "Segoe UI", + "SimSun", + "Sylfaen", + "Tahoma", + "Times New Roman", + "Verdana", +}; diff --git a/gfx/thebes/StandardFonts-win10.inc b/gfx/thebes/StandardFonts-win10.inc @@ -4,6 +4,8 @@ #ifdef StandardFonts +# ifndef BASE_BROWSER_VERSION + // List of standard font families installed as part of Windows 10 // from https://docs.microsoft.com/en-us/typography/fonts/windows_10_font_list // TODO: check whether we need to list legacy styled family names like "... @@ -208,6 +210,7 @@ // EXCLUDED "Rockwell Nova", // Pan-European Supplemental Fonts - EXCLUDED // "Verdana Pro", // Pan-European Supplemental Fonts - EXCLUDED }; +# endif struct FontSubstitute { const char* substituteName; diff --git a/gfx/thebes/gfxDWriteFontList.cpp b/gfx/thebes/gfxDWriteFontList.cpp @@ -36,6 +36,7 @@ #define StandardFonts #include "StandardFonts-win10.inc" #undef StandardFonts +#include "StandardFonts-win10-bb.inc" using namespace mozilla; using namespace mozilla::gfx; @@ -922,7 +923,9 @@ size_t gfxDWriteFontEntry::ComputedSizeOfExcludingThis( gfxDWriteFontList::gfxDWriteFontList() : mForceGDIClassicMaxFontSize(0.0) { CheckFamilyList(kBaseFonts); +#ifndef BASE_BROWSER_VERSION CheckFamilyList(kLangPackFonts); +#endif } // bug 602792 - CJK systems default to large CJK fonts which cause excessive @@ -1165,12 +1168,14 @@ FontVisibility gfxDWriteFontList::GetVisibilityForFamily( if (FamilyInList(aName, kBaseFonts)) { return FontVisibility::Base; } +#ifndef BASE_BROWSER_VERSION if (FamilyInList(aName, kLangPackFonts)) { return FontVisibility::LangPack; } if (nsRFPService::FontIsAllowedByLocale(aName)) { return FontVisibility::LangPack; } +#endif return FontVisibility::User; } @@ -1179,8 +1184,10 @@ gfxDWriteFontList::GetFilteredPlatformFontLists() { nsTArray<std::pair<const char**, uint32_t>> fontLists; fontLists.AppendElement(std::make_pair(kBaseFonts, std::size(kBaseFonts))); +#ifndef BASE_BROWSER_VERSION fontLists.AppendElement( std::make_pair(kLangPackFonts, std::size(kLangPackFonts))); +#endif return fontLists; } diff --git a/gfx/thebes/gfxFcPlatformFontList.cpp b/gfx/thebes/gfxFcPlatformFontList.cpp @@ -32,9 +32,11 @@ #include "nsCharSeparatedTokenizer.h" #include "nsXULAppAPI.h" #include "SharedFontList-impl.h" -#define StandardFonts -#include "StandardFonts-linux.inc" -#undef StandardFonts +#ifndef BASE_BROWSER_VERSION +# define StandardFonts +# include "StandardFonts-linux.inc" +# undef StandardFonts +#endif #include "mozilla/intl/Locale.h" #include "mozilla/gfx/HelpersCairo.h" @@ -1363,12 +1365,14 @@ gfxFcPlatformFontList::gfxFcPlatformFontList() mFcSubstituteCache(64), mLastConfig(nullptr), mAlwaysUseFontconfigGenerics(true) { +#ifndef BASE_BROWSER_VERSION CheckFamilyList(kBaseFonts_Ubuntu_22_04); CheckFamilyList(kLangFonts_Ubuntu_22_04); CheckFamilyList(kBaseFonts_Ubuntu_20_04); CheckFamilyList(kLangFonts_Ubuntu_20_04); CheckFamilyList(kBaseFonts_Fedora_39); CheckFamilyList(kBaseFonts_Fedora_38); +#endif mLastConfig = FcConfigGetCurrent(); if (XRE_IsParentProcess()) { // if the rescan interval is set, start the timer @@ -1705,11 +1709,14 @@ using Device = nsIGfxInfo::FontVisibilityDeviceDetermination; static Device sFontVisibilityDevice = Device::Unassigned; void AssignFontVisibilityDevice() { + sFontVisibilityDevice = Device::Linux_Unknown; +#ifndef BASE_BROWSER_VERSION if (sFontVisibilityDevice == Device::Unassigned) { nsCOMPtr<nsIGfxInfo> gfxInfo = components::GfxInfo::Service(); NS_ENSURE_SUCCESS_VOID( gfxInfo->GetFontVisibilityDetermination(&sFontVisibilityDevice)); } +#endif } // Per family array of faces. @@ -2032,6 +2039,7 @@ FontVisibility gfxFcPlatformFontList::GetVisibilityForFamily( AssignFontVisibilityDevice(); switch (sFontVisibilityDevice) { +#ifndef BASE_BROWSER_VERSION case Device::Linux_Ubuntu_any: case Device::Linux_Ubuntu_22: if (FamilyInList(aName, kBaseFonts_Ubuntu_22_04)) { @@ -2071,7 +2079,7 @@ FontVisibility gfxFcPlatformFontList::GetVisibilityForFamily( return FontVisibility::Base; } return FontVisibility::User; - +#endif default: // We don't know how to categorize fonts on this system return FontVisibility::Unknown; @@ -2084,6 +2092,7 @@ gfxFcPlatformFontList::GetFilteredPlatformFontLists() { nsTArray<std::pair<const char**, uint32_t>> fontLists; +#ifndef BASE_BROWSER_VERSION switch (sFontVisibilityDevice) { case Device::Linux_Ubuntu_any: case Device::Linux_Ubuntu_22: @@ -2117,6 +2126,7 @@ gfxFcPlatformFontList::GetFilteredPlatformFontLists() { // We don't know how to categorize fonts on this system break; } +#endif return fontLists; } diff --git a/gfx/thebes/gfxMacPlatformFontList.mm b/gfx/thebes/gfxMacPlatformFontList.mm @@ -46,7 +46,7 @@ #include <dlfcn.h> #define StandardFonts -#include "StandardFonts-macos.inc" +#include "StandardFonts-macos-bb.inc" #undef StandardFonts using namespace mozilla; @@ -154,7 +154,9 @@ void gfxSingleFaceMacFontFamily::ReadOtherFamilyNames( gfxMacPlatformFontList::gfxMacPlatformFontList() : CoreTextFontList() { CheckFamilyList(kBaseFonts); +#ifndef BASE_BROWSER_VERSION CheckFamilyList(kBaseFonts_13_Higher); +#endif // cache this in a static variable so that gfxMacFontFamily objects // don't have to repeatedly look it up @@ -189,10 +191,12 @@ FontVisibility gfxMacPlatformFontList::GetVisibilityForFamily( if (FamilyInList(aName, kBaseFonts)) { return FontVisibility::Base; } +#ifndef BASE_BROWSER_VERSION if (GetFontVisibilityDevice() == Device::MacOS_13_plus && FamilyInList(aName, kBaseFonts_13_Higher)) { return FontVisibility::Base; } +#endif #ifdef MOZ_BUNDLED_FONTS if (mBundledFamilies.Contains(aName)) { return FontVisibility::Base; @@ -207,10 +211,12 @@ gfxMacPlatformFontList::GetFilteredPlatformFontLists() { fontLists.AppendElement(std::make_pair(kBaseFonts, std::size(kBaseFonts))); +#ifndef BASE_BROWSER_VERSION if (GetFontVisibilityDevice() == Device::MacOS_13_plus) { fontLists.AppendElement( std::make_pair(kBaseFonts_13_Higher, std::size(kBaseFonts_13_Higher))); } +#endif return fontLists; }