Skip to content
Snippets Groups Projects
Commit 3af8e4e6 authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame :jack_o_lantern: Committed by Beatriz Rizental
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 d140e580
Branches
Tags
1 merge request!1527Bug 43808: Rebase 128.10.1 onto 128.11
/* 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",
};
/* 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",
};
struct FontSubstitute {
const char* substituteName;
const char* actualFontName;
};
static const FontSubstitute kFontSubstitutes[] = {
// Common substitutions
{"Arabic Transparent", "Arial"},
{"Arabic Transparent Bold", "Arial Bold"},
{"Arial Baltic", "Arial"},
{"Arial CE", "Arial"},
{"Arial CYR", "Arial"},
{"Arial Greek", "Arial"},
{"Arial TUR", "Arial"},
{"Courier New Baltic", "Courier New"},
{"Courier New CE", "Courier New"},
{"Courier New CYR", "Courier New"},
{"Courier New Greek", "Courier New"},
{"Courier New TUR", "Courier New"},
{"Helv", "MS Sans Serif"},
{"Helvetica", "Arial"},
{"MS Shell Dlg 2", "Tahoma"},
{"Tahoma Armenian", "Tahoma"},
{"Times", "Times New Roman"},
{"Times New Roman Baltic", "Times New Roman"},
{"Times New Roman CE", "Times New Roman"},
{"Times New Roman CYR", "Times New Roman"},
{"Times New Roman Greek", "Times New Roman"},
{"Times New Roman TUR", "Times New Roman"},
{"Tms Rmn", "MS Serif"},
// Common, except Japanese (which uses MS UI Gothic, instead)
{"MS Shell Dlg", "Microsoft Sans Serif"},
// Arabic
{"Arial (Arabic)", "Arial"},
{"Courier New (Arabic)", "Courier New"},
{"Times New Roman (Arabic)", "Times New Roman"},
// Cyrillic + Greek
{"Courier", "Courier New"},
// Greek
{"Fixedsys Greek", "Fixedsys"},
{"MS Serif Greek", "MS Serif"},
{"MS Sans Serif Greek", "MS Sans Serif"},
{"Small Fonts Greek", "Small Fonts"},
{"System Greek", "System"},
// Hebrew
{"Arial (Hebrew)", "Arial"},
{"Courier New (Hebrew)", "Courier New"},
{"David Transparent", "David"},
{"Fixed Miriam Transparent", "Miriam Fixed"},
{"Miriam Transparent", "Miriam"},
{"Rod Transparent", "Rod"},
{"Times New Roman (Hebrew)", "Times New Roman"},
// Japanese
{"標準明朝", "MS 明朝"},
{"標準ゴシック", "MS ゴシック"},
{"ゴシック", "MS ゴシック"},
{"ゴシック", "MS ゴシック"},
{"クーリエ", "Courier"},
{"タイムズロマン", "Times New Roman"},
{"ヘルベチカ", "Arial"},
// Simplified Chinese
{"FangSong_GB2312", "FangSong"},
{"KaiTi_GB2312", "KaiTi"},
};
......@@ -200,68 +200,3 @@ static const char* kLangPackFonts[] = {
// "Rockwell Nova", // Pan-European Supplemental Fonts - EXCLUDED
// "Verdana Pro", // Pan-European Supplemental Fonts - EXCLUDED
};
struct FontSubstitute {
const char *substituteName;
const char *actualFontName;
};
static const FontSubstitute kFontSubstitutes[] = {
// Common substitutions
{"Arabic Transparent", "Arial"},
{"Arabic Transparent Bold", "Arial Bold"},
{"Arial Baltic", "Arial"},
{"Arial CE", "Arial"},
{"Arial CYR", "Arial"},
{"Arial Greek", "Arial"},
{"Arial TUR", "Arial"},
{"Courier New Baltic", "Courier New"},
{"Courier New CE", "Courier New"},
{"Courier New CYR", "Courier New"},
{"Courier New Greek", "Courier New"},
{"Courier New TUR", "Courier New"},
{"Helv", "MS Sans Serif"},
{"Helvetica", "Arial"},
{"MS Shell Dlg 2", "Tahoma"},
{"Tahoma Armenian", "Tahoma"},
{"Times", "Times New Roman"},
{"Times New Roman Baltic", "Times New Roman"},
{"Times New Roman CE", "Times New Roman"},
{"Times New Roman CYR", "Times New Roman"},
{"Times New Roman Greek", "Times New Roman"},
{"Times New Roman TUR", "Times New Roman"},
{"Tms Rmn", "MS Serif"},
// Common, except Japanese (which uses MS UI Gothic, instead)
{"MS Shell Dlg", "Microsoft Sans Serif"},
// Arabic
{"Arial (Arabic)", "Arial"},
{"Courier New (Arabic)", "Courier New"},
{"Times New Roman (Arabic)", "Times New Roman"},
// Cyrillic + Greek
{"Courier", "Courier New"},
// Greek
{"Fixedsys Greek", "Fixedsys"},
{"MS Serif Greek", "MS Serif"},
{"MS Sans Serif Greek", "MS Sans Serif"},
{"Small Fonts Greek", "Small Fonts"},
{"System Greek", "System"},
// Hebrew
{"Arial (Hebrew)", "Arial"},
{"Courier New (Hebrew)", "Courier New"},
{"David Transparent", "David"},
{"Fixed Miriam Transparent", "Miriam Fixed"},
{"Miriam Transparent", "Miriam"},
{"Rod Transparent", "Rod"},
{"Times New Roman (Hebrew)", "Times New Roman"},
// Japanese
{"標準明朝", "MS 明朝"},
{"標準ゴシック", "MS ゴシック"},
{"ゴシック", "MS ゴシック"},
{"ゴシック", "MS ゴシック"},
{"クーリエ", "Courier"},
{"タイムズロマン", "Times New Roman"},
{"ヘルベチカ", "Arial"},
// Simplified Chinese
{"FangSong_GB2312", "FangSong"},
{"KaiTi_GB2312", "KaiTi"},
};
......@@ -32,7 +32,7 @@
#include "harfbuzz/hb.h"
#include "StandardFonts-win10.inc"
#include "StandardFonts-win10-bb.inc"
using namespace mozilla;
using namespace mozilla::gfx;
......@@ -910,7 +910,9 @@ void gfxDWriteFontEntry::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
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
......@@ -1153,9 +1155,11 @@ FontVisibility gfxDWriteFontList::GetVisibilityForFamily(
if (FamilyInList(aName, kBaseFonts)) {
return FontVisibility::Base;
}
#ifndef BASE_BROWSER_VERSION
if (FamilyInList(aName, kLangPackFonts)) {
return FontVisibility::LangPack;
}
#endif
return FontVisibility::User;
}
......@@ -1164,8 +1168,10 @@ gfxDWriteFontList::GetFilteredPlatformFontLists() {
nsTArray<std::pair<const char**, uint32_t>> fontLists;
fontLists.AppendElement(std::make_pair(kBaseFonts, ArrayLength(kBaseFonts)));
#ifndef BASE_BROWSER_VERSION
fontLists.AppendElement(
std::make_pair(kLangPackFonts, ArrayLength(kLangPackFonts)));
#endif
return fontLists;
}
......
......@@ -32,7 +32,9 @@
#include "nsCharSeparatedTokenizer.h"
#include "nsXULAppAPI.h"
#include "SharedFontList-impl.h"
#ifndef BASE_BROWSER_VERSION
# include "StandardFonts-linux.inc"
#endif
#include "mozilla/intl/Locale.h"
#include "mozilla/gfx/HelpersCairo.h"
......@@ -1358,12 +1360,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
......@@ -1677,11 +1681,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.
......@@ -2002,6 +2009,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)) {
......@@ -2041,7 +2049,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;
......@@ -2054,6 +2062,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:
......@@ -2087,6 +2096,7 @@ gfxFcPlatformFontList::GetFilteredPlatformFontLists() {
// We don't know how to categorize fonts on this system
break;
}
#endif
return fontLists;
}
......
......@@ -33,7 +33,7 @@
#include "nsContentUtils.h"
#include "StandardFonts-win10.inc"
#include "StandardFonts-win10-bb.inc"
#include <usp10.h>
......
......@@ -46,7 +46,7 @@
#include <time.h>
#include <dlfcn.h>
#include "StandardFonts-macos.inc"
#include "StandardFonts-macos-bb.inc"
using namespace mozilla;
using namespace mozilla::gfx;
......@@ -153,7 +153,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
......@@ -188,10 +190,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;
......@@ -206,10 +210,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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment