Skip to content

Commit

Permalink
Expand font whitelist on macOS (#13807)
Browse files Browse the repository at this point in the history
* Expand font whitelist on macOS

* .

* .
  • Loading branch information
pilgrim-brave authored Jun 16, 2022
1 parent 6d36df2 commit 0db7e55
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 11 additions & 0 deletions third_party/blink/renderer/brave_font_whitelist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ bool kCanRestrictFonts = true;
// This list covers the fonts installed by default on Mac OS as of Mac OS 12.3.
base::flat_set<base::StringPiece> kAllowedFontFamilies =
base::MakeFlatSet<base::StringPiece>(std::vector<base::StringPiece>{
"Academy Engraved LET",
"Al Bayan",
"Al Nile",
"Al Tarikh",
Expand All @@ -29,6 +30,7 @@ base::flat_set<base::StringPiece> kAllowedFontFamilies =
"Apple Braille Pinpoint 6 Dot",
"Apple Braille Pinpoint 8 Dot",
"Apple Braille",
"Apple Chancery",
"Apple Color Emoji",
"Apple SD Gothic Neo",
"Apple Symbols",
Expand Down Expand Up @@ -67,6 +69,9 @@ base::flat_set<base::StringPiece> kAllowedFontFamilies =
"Baskerville",
"Beirut",
"Big Caslon",
"Bodoni 72",
"Bodoni 72 Oldstyle",
"Bodoni 72 Smallcaps",
"Bodoni Ornaments",
"Bradley Hand",
"Brush Script MT",
Expand Down Expand Up @@ -99,13 +104,15 @@ base::flat_set<base::StringPiece> kAllowedFontFamilies =
"Geneva",
"Georgia",
"Gill Sans",
"Grantha Sangam MN",
"Gujarati MT",
"Gujarati Sangam MN",
"Gurmukhi MN",
"Gurmukhi MT",
"Gurmukhi Sangam MN",
"Heiti SC",
"Heiti TC",
"Helvetica",
"Helvetica Neue",
"Herculanum",
"Hiragino Kaku Gothic Pro W3",
Expand Down Expand Up @@ -178,6 +185,7 @@ base::flat_set<base::StringPiece> kAllowedFontFamilies =
"Mishafi",
"Monaco",
"Mshtakan",
"Mukta Mahee",
"Muna",
"Myanmar MN",
"Myanmar Sangam MN",
Expand All @@ -202,6 +210,8 @@ base::flat_set<base::StringPiece> kAllowedFontFamilies =
"PT Serif Caption",
"PT Serif",
"Palatino",
"Papyrus",
"Party LET",
"Phosphate",
"PingFang HK",
"PingFang SC",
Expand Down Expand Up @@ -261,6 +271,7 @@ base::flat_set<base::StringPiece> kAllowedFontFamilies =
"Seravek Light",
"Seravek Medium",
"Seravek",
"Shree Devanagari 714",
"SignPainter",
"SignPainter-HouseScript",
"Silom",
Expand Down
7 changes: 5 additions & 2 deletions third_party/blink/renderer/brave_font_whitelist_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ TEST(BraveFontWhitelistTest, Platforms) {

#if BUILDFLAG(IS_MAC)
EXPECT_EQ(brave::CanRestrictFontFamiliesOnThisPlatform(), true);
EXPECT_EQ(allowed.size(), 271UL);
EXPECT_EQ(allowed.size(), 282UL);
#elif BUILDFLAG(IS_WIN)
EXPECT_EQ(brave::CanRestrictFontFamiliesOnThisPlatform(), true);
EXPECT_EQ(allowed.size(), 311UL);
Expand Down Expand Up @@ -104,25 +104,28 @@ TEST(BraveFontWhitelistTest, Locales) {
}

TEST(BraveFontWhitelistTest, KnownFonts) {
const std::array<std::tuple<base::StringPiece, bool>, 6> test_cases = {
const std::array<std::tuple<base::StringPiece, bool>, 7> test_cases = {
#if BUILDFLAG(IS_MAC)
std::make_tuple<>("Arial Unicode MS", true),
std::make_tuple<>("Calibri", false),
std::make_tuple<>("Gill Sans", true),
std::make_tuple<>("Helvetica", true),
std::make_tuple<>("Helvetica Neue", true),
std::make_tuple<>("Menlo", true),
std::make_tuple<>("Franklin Gothic Medium", false),
#elif BUILDFLAG(IS_WIN)
std::make_tuple<>("Arial Unicode MS", false),
std::make_tuple<>("Calibri", true),
std::make_tuple<>("Gill Sans", false),
std::make_tuple<>("Helvetica", false),
std::make_tuple<>("Helvetica Neue", false),
std::make_tuple<>("Menlo", false),
std::make_tuple<>("Franklin Gothic Medium", true),
#else
std::make_tuple<>("Arial Unicode MS", false),
std::make_tuple<>("Calibri", false),
std::make_tuple<>("Gill Sans", false),
std::make_tuple<>("Helvetica", false),
std::make_tuple<>("Helvetica Neue", false),
std::make_tuple<>("Menlo", false),
std::make_tuple<>("Franklin Gothic Medium", false),
Expand Down

0 comments on commit 0db7e55

Please sign in to comment.