Pier Angelo Vendrame pushed to branch tor-browser-152.0a1-16.0-2 at The Tor Project / Applications / Tor Browser Commits: c6615d45 by Jonathan Kew at 2026-06-25T08:38:06+02:00 BB 44728: Activate app-bundled fonts in the GPU process on macOS. Bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=2032466 Differential Revision: https://phabricator.services.mozilla.com/D308045 - - - - - 5 changed files: - gfx/ipc/GPUProcessImpl.cpp - gfx/thebes/CoreTextFontList.h - gfx/thebes/gfxPlatformMac.cpp - gfx/thebes/gfxPlatformMac.h - security/sandbox/mac/SandboxPolicyGPU.h Changes: ===================================== gfx/ipc/GPUProcessImpl.cpp ===================================== @@ -11,6 +11,8 @@ # include "mozilla/sandboxTarget.h" #elif defined(__OpenBSD__) && defined(MOZ_SANDBOX) # include "mozilla/SandboxSettings.h" +#elif defined(XP_MACOSX) && defined(MOZ_BUNDLED_FONTS) +# include "gfxPlatformMac.h" #endif namespace mozilla { @@ -34,6 +36,35 @@ bool GPUProcessImpl::Init(int aArgc, char* aArgv[]) { return false; } +#if defined(XP_MACOSX) && defined(MOZ_BUNDLED_FONTS) + // On macOS, bundled fonts shipped with the application need to be activated + // in the GPU process, otherwise they will fail to render (and fall back to + // garbage glyphs from another font). + // The bundled fonts directory is a sibling of the appDir, so we use the + // sAppDir arg as a starting-point to locate it. + nsCOMPtr<nsIFile> appDirArg; + Maybe<const char*> appDir = geckoargs::sAppDir.Get(aArgc, aArgv); + if (appDir.isSome()) { + bool flag; + if (NS_FAILED(XRE_GetFileFromPath(*appDir, getter_AddRefs(appDirArg))) || + NS_FAILED(appDirArg->Exists(&flag)) || !flag) { + NS_WARNING("Invalid application directory passed to GPU process."); + appDirArg = nullptr; + } + } + if (appDirArg) { + // appDirArg is the <app package>/Contents/Resources/browser directory. + // Get its parent (/Resources), and then append /fonts. + nsCOMPtr<nsIFile> fontsDir; + bool flag; + if (NS_SUCCEEDED(appDirArg->GetParent(getter_AddRefs(fontsDir))) && + NS_SUCCEEDED(fontsDir->AppendRelativeNativePath("fonts"_ns)) && + NS_SUCCEEDED(fontsDir->Exists(&flag)) && flag) { + gfxPlatformMac::ActivateFontsFromDir(fontsDir->NativePath()); + } + } +#endif + if (!ProcessChild::InitPrefs(aArgc, aArgv)) { return false; } ===================================== gfx/thebes/CoreTextFontList.h ===================================== @@ -193,6 +193,10 @@ class CoreTextFontList : public gfxPlatformFontList { }; void ReadSystemFontList(mozilla::dom::SystemFontList*); + static void ActivateFontsFromDir( + const nsACString& aDir, + nsTHashSet<nsCStringHashKey>* aLoadedFamilies = nullptr); + protected: CoreTextFontList(); virtual ~CoreTextFontList(); @@ -251,10 +255,6 @@ class CoreTextFontList : public gfxPlatformFontList { void AddFamily(const nsACString& aFamilyName, FontVisibility aVisibility) MOZ_REQUIRES(mLock); - static void ActivateFontsFromDir( - const nsACString& aDir, - nsTHashSet<nsCStringHashKey>* aLoadedFamilies = nullptr); - gfxFontEntry* CreateFontEntry( mozilla::fontlist::Face* aFace, const mozilla::fontlist::Family* aFamily) override; ===================================== gfx/thebes/gfxPlatformMac.cpp ===================================== @@ -1073,3 +1073,9 @@ nsTArray<uint8_t> gfxPlatformMac::GetPlatformCMSOutputProfileData() { } bool gfxPlatformMac::CheckVariationFontSupport() { return true; } + +#ifdef MOZ_BUNDLED_FONTS +void gfxPlatformMac::ActivateFontsFromDir(const nsACString& aPath) { + CoreTextFontList::ActivateFontsFromDir(aPath); +} +#endif ===================================== gfx/thebes/gfxPlatformMac.h ===================================== @@ -80,6 +80,10 @@ class gfxPlatformMac : public gfxPlatform { static bool CheckVariationFontSupport(); +#ifdef MOZ_BUNDLED_FONTS + static void ActivateFontsFromDir(const nsACString& aPath); +#endif + protected: bool AccelerateLayersByDefault() override; ===================================== security/sandbox/mac/SandboxPolicyGPU.h ===================================== @@ -232,6 +232,7 @@ static const char SandboxPolicyGPU[] = R"SANDBOX_LITERAL( (allow file-read* (subpath "/Library/Fonts") (subpath "/Library/Application Support/Apple/Fonts") + (subpath (string-append appPath "/Contents/Resources/fonts")) (home-subpath "/Library/Fonts") ; Allow read access to paths allowed via sandbox extensions. ; This is needed for fonts in non-standard locations normally View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/c6615d45... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/c6615d45... You're receiving this email because of your account on gitlab.torproject.org. Manage all notifications: https://gitlab.torproject.org/-/profile/notifications | Help: https://gitlab.torproject.org/help
participants (1)
-
Pier Angelo Vendrame (@pierov)