Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 424940f

Browse files
Add support for the Fontconfig-based Skia font manager (#8977)
1 parent 859cd98 commit 424940f

6 files changed

Lines changed: 34 additions & 4 deletions

File tree

DEPS

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ allowed_hosts = [
121121
]
122122

123123
deps = {
124-
'src': 'https://github.com/flutter/buildroot.git' + '@' + 'c5afcce6d7972b20eded5b090b489b76622e8ff3',
124+
'src': 'https://github.com/flutter/buildroot.git' + '@' + 'bc8826aab0fc4f7e17b21f64dec4c8a28ea42e3e',
125125

126126
# Fuchsia compatibility
127127
#
@@ -364,7 +364,7 @@ deps = {
364364
Var('chromium_git') + '/external/colorama.git' + '@' + '799604a1041e9b3bc5d2789ecbd7e8db2e18e6b8',
365365

366366
'src/third_party/freetype2':
367-
Var('fuchsia_git') + '/third_party/freetype2' + '@' + 'a10b062df0c8958d69377aa04ea6554a9961a111',
367+
Var('fuchsia_git') + '/third_party/freetype2' + '@' + 'edab12c07ac05d1185616688f338b1ad15936796',
368368

369369
'src/third_party/root_certificates':
370370
Var('dart_git') + '/root_certificates.git' + '@' + Var('dart_root_certificates_rev'),
@@ -381,6 +381,9 @@ deps = {
381381
'src/third_party/wuffs':
382382
Var('fuchsia_git') + '/third_party/wuffs' + '@' + 'a71538baa8f1f4053176c0d9f31bc12fd4e8e71b',
383383

384+
'src/third_party/fontconfig/src':
385+
Var('chromium_git') + '/external/fontconfig.git' + '@' + 'c336b8471877371f0190ba06f7547c54e2b890ba',
386+
384387
'src/third_party/gyp':
385388
Var('chromium_git') + '/external/gyp.git' + '@' + '4801a5331ae62da9769a327f11c4213d32fb0dad',
386389

ci/licenses_golden/tool_signature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Signature: 6d315fb6c8e9e949011f57c32b16cb48
1+
Signature: ab4f82ed4f38f0d3821073855c220992
22

third_party/txt/BUILD.gn

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
declare_args() {
16+
flutter_use_fontconfig = false
17+
}
18+
19+
if (flutter_use_fontconfig) {
20+
assert(is_linux)
21+
}
22+
1523
config("txt_config") {
1624
visibility = [ ":*" ]
1725
include_dirs = [ "src" ]
@@ -24,6 +32,9 @@ source_set("txt") {
2432
if (is_android) {
2533
defines = [ "ANDROID_FONT_MANAGER_AVAILABLE" ]
2634
}
35+
if (flutter_use_fontconfig) {
36+
defines = [ "FONTCONFIG_FONT_MANAGER_AVAILABLE" ]
37+
}
2738

2839
sources = [
2940
"src/log/log.cc",
@@ -116,6 +127,10 @@ source_set("txt") {
116127
"//third_party/skia",
117128
]
118129

130+
if (flutter_use_fontconfig) {
131+
deps += [ "//third_party/fontconfig" ]
132+
}
133+
119134
if (is_mac || is_ios) {
120135
sources += [ "src/txt/platform_mac.mm" ]
121136
deps += [ "$flutter_root/fml" ]

third_party/txt/src/txt/platform_linux.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
#include "txt/platform.h"
66

7+
#ifdef FONTCONFIG_FONT_MANAGER_AVAILABLE
8+
#include "third_party/skia/include/ports/SkFontMgr_fontconfig.h"
9+
#else
710
#include "third_party/skia/include/ports/SkFontMgr_directory.h"
11+
#endif
812

913
namespace txt {
1014

@@ -13,7 +17,11 @@ std::string GetDefaultFontFamily() {
1317
}
1418

1519
sk_sp<SkFontMgr> GetDefaultFontManager() {
20+
#ifdef FONTCONFIG_FONT_MANAGER_AVAILABLE
21+
return SkFontMgr_New_FontConfig(nullptr);
22+
#else
1623
return SkFontMgr_New_Custom_Directory("/usr/share/fonts/");
24+
#endif
1725
}
1826

1927
} // namespace txt

tools/gn

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ def to_gn_args(args):
9090
gn_args['skia_enable_pdf'] = False # PDF handling.
9191
gn_args['skia_use_x11'] = False # Never add the X11 dependency (only takes effect on Linux).
9292
gn_args['skia_use_expat'] = args.target_os == 'android'
93-
gn_args['skia_use_fontconfig'] = False # Use the custom font manager instead.
93+
gn_args['skia_use_fontconfig'] = args.enable_fontconfig
94+
gn_args['flutter_use_fontconfig'] = args.enable_fontconfig
9495
gn_args['is_official_build'] = True # Disable Skia test utilities.
9596
gn_args['dart_component_kind'] = 'static_library' # Always link Dart in statically.
9697
gn_args['is_debug'] = args.unoptimized
@@ -298,6 +299,8 @@ def parse_args(args):
298299
parser.add_argument('--enable-vulkan', action='store_true', default=False)
299300
parser.add_argument('--enable-metal', action='store_true', default=False)
300301

302+
parser.add_argument('--enable-fontconfig', action='store_true', default=False)
303+
301304
parser.add_argument('--embedder-for-target', dest='embedder_for_target', action='store_true', default=False)
302305

303306
parser.add_argument('--coverage', default=False, action='store_true')

tools/licenses/lib/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,6 +1752,7 @@ class _RepositoryRootThirdPartyDirectory extends _RepositoryGenericThirdPartyDir
17521752
&& entry.name != 'android_support' // build-time only
17531753
&& entry.name != 'googletest' // only used by tests
17541754
&& entry.name != 'skia' // treated as a separate component
1755+
&& entry.name != 'fontconfig' // not used in standard configurations
17551756
&& super.shouldRecurse(entry);
17561757
}
17571758

0 commit comments

Comments
 (0)