From 28d536a39aa0aeffcdd6ebbe356e32d133015b25 Mon Sep 17 00:00:00 2001 From: Anthony Bullard <1380687+gamebox@users.noreply.github.com> Date: Fri, 14 Dec 2018 10:05:41 -0800 Subject: [PATCH] Support real fonts in 'flutter test' (flutter/engine#6913) * Support real fonts in 'flutter test' Change the order of font_managers to query in font_collection so that dynamic_font_manager fonts will be resolved. Tested with test case in `flutter/flutter` repo: `packages/flutter/test/rendering/localized_fonts_test.dart` Ensured: - A font loaded with FontLoader will be used - The default 'Ahem' font is still loaded by default The test above still cannot be fixed because FontLoader and the underlying mechanisms don't cover Locale-specific font loading and therefore a CJK font-family won't be able to be loaded as needed for that test. Fixes #17700 * Format fixup --- engine/src/flutter/shell/common/engine.cc | 4 ++-- engine/src/flutter/third_party/txt/src/txt/font_collection.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/engine/src/flutter/shell/common/engine.cc b/engine/src/flutter/shell/common/engine.cc index 56c55310e7..ef3369347e 100644 --- a/engine/src/flutter/shell/common/engine.cc +++ b/engine/src/flutter/shell/common/engine.cc @@ -90,10 +90,10 @@ bool Engine::UpdateAssetManager( } // Using libTXT as the text engine. + font_collection_.RegisterFonts(asset_manager_); + if (settings_.use_test_fonts) { font_collection_.RegisterTestFonts(); - } else { - font_collection_.RegisterFonts(asset_manager_); } return true; diff --git a/engine/src/flutter/third_party/txt/src/txt/font_collection.cc b/engine/src/flutter/third_party/txt/src/txt/font_collection.cc index 71e6a5178e..2be51f6312 100644 --- a/engine/src/flutter/third_party/txt/src/txt/font_collection.cc +++ b/engine/src/flutter/third_party/txt/src/txt/font_collection.cc @@ -95,12 +95,12 @@ void FontCollection::SetTestFontManager(sk_sp font_manager) { // Return the available font managers in the order they should be queried. std::vector> FontCollection::GetFontManagerOrder() const { std::vector> order; - if (test_font_manager_) - order.push_back(test_font_manager_); if (dynamic_font_manager_) order.push_back(dynamic_font_manager_); if (asset_font_manager_) order.push_back(asset_font_manager_); + if (test_font_manager_) + order.push_back(test_font_manager_); if (default_font_manager_) order.push_back(default_font_manager_); return order;