From 5b6dedfc3e778dd39a8e3b21e577bc7bc92bf2d7 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Thu, 16 May 2019 15:22:22 -0700 Subject: [PATCH] Add support for the Fontconfig-based Skia font manager (flutter/engine#8977) --- DEPS | 7 +++++-- .../src/flutter/ci/licenses_golden/tool_signature | 2 +- engine/src/flutter/third_party/txt/BUILD.gn | 15 +++++++++++++++ .../third_party/txt/src/txt/platform_linux.cc | 8 ++++++++ engine/src/flutter/tools/gn | 5 ++++- engine/src/flutter/tools/licenses/lib/main.dart | 1 + 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/DEPS b/DEPS index 87d58984aae..b02bba5d13c 100644 --- a/DEPS +++ b/DEPS @@ -121,7 +121,7 @@ allowed_hosts = [ ] deps = { - 'src': 'https://github.com/flutter/buildroot.git' + '@' + 'c5afcce6d7972b20eded5b090b489b76622e8ff3', + 'src': 'https://github.com/flutter/buildroot.git' + '@' + 'bc8826aab0fc4f7e17b21f64dec4c8a28ea42e3e', # Fuchsia compatibility # @@ -364,7 +364,7 @@ deps = { Var('chromium_git') + '/external/colorama.git' + '@' + '799604a1041e9b3bc5d2789ecbd7e8db2e18e6b8', 'src/third_party/freetype2': - Var('fuchsia_git') + '/third_party/freetype2' + '@' + 'a10b062df0c8958d69377aa04ea6554a9961a111', + Var('fuchsia_git') + '/third_party/freetype2' + '@' + 'edab12c07ac05d1185616688f338b1ad15936796', 'src/third_party/root_certificates': Var('dart_git') + '/root_certificates.git' + '@' + Var('dart_root_certificates_rev'), @@ -381,6 +381,9 @@ deps = { 'src/third_party/wuffs': Var('fuchsia_git') + '/third_party/wuffs' + '@' + 'a71538baa8f1f4053176c0d9f31bc12fd4e8e71b', + 'src/third_party/fontconfig/src': + Var('chromium_git') + '/external/fontconfig.git' + '@' + 'c336b8471877371f0190ba06f7547c54e2b890ba', + 'src/third_party/gyp': Var('chromium_git') + '/external/gyp.git' + '@' + '4801a5331ae62da9769a327f11c4213d32fb0dad', diff --git a/engine/src/flutter/ci/licenses_golden/tool_signature b/engine/src/flutter/ci/licenses_golden/tool_signature index 7e4b4e355b6..580f119ff4a 100644 --- a/engine/src/flutter/ci/licenses_golden/tool_signature +++ b/engine/src/flutter/ci/licenses_golden/tool_signature @@ -1,2 +1,2 @@ -Signature: 6d315fb6c8e9e949011f57c32b16cb48 +Signature: ab4f82ed4f38f0d3821073855c220992 diff --git a/engine/src/flutter/third_party/txt/BUILD.gn b/engine/src/flutter/third_party/txt/BUILD.gn index bc08ff2cf17..ccfb2859b6f 100644 --- a/engine/src/flutter/third_party/txt/BUILD.gn +++ b/engine/src/flutter/third_party/txt/BUILD.gn @@ -12,6 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +declare_args() { + flutter_use_fontconfig = false +} + +if (flutter_use_fontconfig) { + assert(is_linux) +} + config("txt_config") { visibility = [ ":*" ] include_dirs = [ "src" ] @@ -24,6 +32,9 @@ source_set("txt") { if (is_android) { defines = [ "ANDROID_FONT_MANAGER_AVAILABLE" ] } + if (flutter_use_fontconfig) { + defines = [ "FONTCONFIG_FONT_MANAGER_AVAILABLE" ] + } sources = [ "src/log/log.cc", @@ -116,6 +127,10 @@ source_set("txt") { "//third_party/skia", ] + if (flutter_use_fontconfig) { + deps += [ "//third_party/fontconfig" ] + } + if (is_mac || is_ios) { sources += [ "src/txt/platform_mac.mm" ] deps += [ "$flutter_root/fml" ] diff --git a/engine/src/flutter/third_party/txt/src/txt/platform_linux.cc b/engine/src/flutter/third_party/txt/src/txt/platform_linux.cc index b95d00a597c..a1f45ade65f 100644 --- a/engine/src/flutter/third_party/txt/src/txt/platform_linux.cc +++ b/engine/src/flutter/third_party/txt/src/txt/platform_linux.cc @@ -4,7 +4,11 @@ #include "txt/platform.h" +#ifdef FONTCONFIG_FONT_MANAGER_AVAILABLE +#include "third_party/skia/include/ports/SkFontMgr_fontconfig.h" +#else #include "third_party/skia/include/ports/SkFontMgr_directory.h" +#endif namespace txt { @@ -13,7 +17,11 @@ std::string GetDefaultFontFamily() { } sk_sp GetDefaultFontManager() { +#ifdef FONTCONFIG_FONT_MANAGER_AVAILABLE + return SkFontMgr_New_FontConfig(nullptr); +#else return SkFontMgr_New_Custom_Directory("/usr/share/fonts/"); +#endif } } // namespace txt diff --git a/engine/src/flutter/tools/gn b/engine/src/flutter/tools/gn index 8c5b8ed2153..ebf8be7bff4 100755 --- a/engine/src/flutter/tools/gn +++ b/engine/src/flutter/tools/gn @@ -90,7 +90,8 @@ def to_gn_args(args): gn_args['skia_enable_pdf'] = False # PDF handling. gn_args['skia_use_x11'] = False # Never add the X11 dependency (only takes effect on Linux). gn_args['skia_use_expat'] = args.target_os == 'android' - gn_args['skia_use_fontconfig'] = False # Use the custom font manager instead. + gn_args['skia_use_fontconfig'] = args.enable_fontconfig + gn_args['flutter_use_fontconfig'] = args.enable_fontconfig gn_args['is_official_build'] = True # Disable Skia test utilities. gn_args['dart_component_kind'] = 'static_library' # Always link Dart in statically. gn_args['is_debug'] = args.unoptimized @@ -298,6 +299,8 @@ def parse_args(args): parser.add_argument('--enable-vulkan', action='store_true', default=False) parser.add_argument('--enable-metal', action='store_true', default=False) + parser.add_argument('--enable-fontconfig', action='store_true', default=False) + parser.add_argument('--embedder-for-target', dest='embedder_for_target', action='store_true', default=False) parser.add_argument('--coverage', default=False, action='store_true') diff --git a/engine/src/flutter/tools/licenses/lib/main.dart b/engine/src/flutter/tools/licenses/lib/main.dart index 15eaed6def8..f5a7d174a63 100644 --- a/engine/src/flutter/tools/licenses/lib/main.dart +++ b/engine/src/flutter/tools/licenses/lib/main.dart @@ -1752,6 +1752,7 @@ class _RepositoryRootThirdPartyDirectory extends _RepositoryGenericThirdPartyDir && entry.name != 'android_support' // build-time only && entry.name != 'googletest' // only used by tests && entry.name != 'skia' // treated as a separate component + && entry.name != 'fontconfig' // not used in standard configurations && super.shouldRecurse(entry); }