Commit e6d9de93 authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame 🎃 Committed by jwilde
Browse files

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.
parent 0347fc4d
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
/* 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",
};
+1 −1
Original line number Diff line number Diff line
@@ -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/
+25 −0
Original line number Diff line number Diff line
/* 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",
};
+3 −0
Original line number Diff line number Diff line
@@ -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;
+7 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#define StandardFonts
#include "StandardFonts-win10.inc"
#undef StandardFonts
#include "StandardFonts-win10-bb.inc"

using namespace mozilla;
using namespace mozilla::gfx;
@@ -921,7 +922,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
@@ -1164,12 +1167,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;
}

@@ -1178,8 +1183,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;
}
Loading