0

Instantiate Android system fonts with Fontations

Partial revert of https://crrev.com/c/6378864, but keep flag disabled.

After Julia landed [1] (thank you!), it's now possible to create
Fontations Android system fonts.

Create a skia feature "FontationsAndroidSystemFonts" to set the Android
default font manager to one that instantiates through Fontations.

[1] https://chromium.googlesource.com/skia.git/+/eb9fc76e302f873de982cefa7690443e7a2cede5

Bug: chromium:370816214
Change-Id: I48c97ec7b25049c13b7718c062f31998553edf7b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6382313
Reviewed-by: Ben Wagner <bungeman@google.com>
Auto-Submit: Dominik Röttsches <drott@chromium.org>
Commit-Queue: Ben Wagner <bungeman@google.com>
Cr-Commit-Position: refs/heads/main@{#1436053}
This commit is contained in:
Dominik Röttsches
2025-03-21 08:14:12 -07:00
committed by Chromium LUCI CQ
parent 868cb645c2
commit cee18ff86e
3 changed files with 13 additions and 1 deletions

@ -14,6 +14,7 @@
#if BUILDFLAG(IS_ANDROID)
#include "third_party/skia/include/ports/SkFontMgr_android.h"
#include "third_party/skia/include/ports/SkFontScanner_Fontations.h"
#endif
#if BUILDFLAG(IS_APPLE)
@ -59,7 +60,11 @@ static sk_sp<SkFontMgr> fontmgr_factory() {
return sk_ref_sp(g_fontmgr_override);
}
#if BUILDFLAG(IS_ANDROID)
return SkFontMgr_New_Android(nullptr);
if (base::FeatureList::IsEnabled(skia::kFontationsAndroidSystemFonts)) {
return SkFontMgr_New_Android(nullptr, SkFontScanner_Make_Fontations());
} else {
return SkFontMgr_New_Android(nullptr);
}
#elif BUILDFLAG(IS_APPLE)
return SkFontMgr_New_CoreText(nullptr);
#elif BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX)

@ -11,4 +11,10 @@ BASE_FEATURE(kFontationsLinuxSystemFonts,
"FontationsLinuxSystemFonts",
base::FEATURE_ENABLED_BY_DEFAULT);
// Instantiate system fonts on Android with Fontations, affects
// SkFontMgr instantiation in skia/ext/font_utils.cc
BASE_FEATURE(kFontationsAndroidSystemFonts,
"FontationsAndroidSystemFonts",
base::FEATURE_DISABLED_BY_DEFAULT);
} // namespace skia

@ -12,6 +12,7 @@ namespace skia {
SK_API BASE_DECLARE_FEATURE(kFontationsLinuxSystemFonts);
SK_API BASE_DECLARE_FEATURE(kFontationsAndroidSystemFonts);
}
#endif // SKIA_FONTATIONS_FEATURE_H_