Commit a0891082 authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame 🎃
Browse files

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.
parent e73cb080
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -2189,11 +2189,12 @@ void gfxFcPlatformFontList::GetFontList(nsAtom* aLangGroup,
FontFamily gfxFcPlatformFontList::GetDefaultFontForPlatform(
    nsPresContext* aPresContext, const gfxFontStyle* aStyle,
    nsAtom* aLanguage) {
  // Get the default font by using a fake name to retrieve the first
  // scalable font that fontconfig suggests for the given language.
  PrefFontList* prefFonts =
      FindGenericFamilies(aPresContext, "-moz-default"_ns,
                          aLanguage ? aLanguage : nsGkAtoms::x_western);
  // We hardcode Arimo also in preferences, and using the original code that
  // tried to resolve a non-existing font did not play well with our fontconfig
  // configuration. See
  // https://gitlab.torproject.org/tpo/applications/tor-browser/-/issues/41043
  PrefFontList* prefFonts = FindGenericFamilies(
      aPresContext, "Arimo"_ns, aLanguage ? aLanguage : nsGkAtoms::x_western);
  NS_ASSERTION(prefFonts, "null list of generic fonts");
  if (prefFonts && !prefFonts->IsEmpty()) {
    return (*prefFonts)[0];
+5 −0
Original line number Diff line number Diff line
@@ -2055,6 +2055,11 @@ static void GetSystemUIFontFamilies(const nsPresContext* aPresContext,
#if defined(XP_MACOSX) || defined(MOZ_WIDGET_UIKIT)
    *aFamilies.AppendElement() = "-apple-system"_ns;
    return;
#elif defined(MOZ_WIDGET_GTK)
    // tor-browser#43141: Hardcode Arimo in case our custom fontconfig is
    // missing.
    *aFamilies.AppendElement() = "Arimo"_ns;
    return;
#elif !defined(MOZ_WIDGET_ANDROID)
    *aFamilies.AppendElement() = "sans-serif"_ns;
    return;
+3 −1
Original line number Diff line number Diff line
@@ -9715,7 +9715,9 @@ static void GetSpoofedSystemFontForRFP(LookAndFeel::FontID aFontID,
  // 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.
  aName = u"sans-serif"_ns;
  // tor-browser#43141: Hardcode Arimo in case our custom fontconfig is
  // missing.
  aName = u"Arimo"_ns;
  aStyle.size = 15;
#else
#  error "Unknown platform"