diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index c4e3fd171004a..95c7220a90829 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -711,6 +711,7 @@ FILE: ../../../flutter/synchronization/semaphore_unittest.cc FILE: ../../../flutter/third_party/txt/src/txt/platform.cc FILE: ../../../flutter/third_party/txt/src/txt/platform.h FILE: ../../../flutter/third_party/txt/src/txt/platform_android.cc +FILE: ../../../flutter/third_party/txt/src/txt/platform_linux.cc FILE: ../../../flutter/third_party/txt/src/txt/platform_mac.mm FILE: ../../../flutter/vulkan/skia_vulkan_header.h FILE: ../../../flutter/vulkan/vulkan_application.cc diff --git a/lib/ui/text/font_collection.cc b/lib/ui/text/font_collection.cc index 3f41f6457c83e..55e95df96740b 100644 --- a/lib/ui/text/font_collection.cc +++ b/lib/ui/text/font_collection.cc @@ -46,7 +46,7 @@ void _LoadFontFromList(Dart_NativeArguments args) { FontCollection::FontCollection() : collection_(std::make_shared()) { - collection_->SetDefaultFontManager(SkFontMgr::RefDefault()); + collection_->SetupDefaultFontManager(); dynamic_font_manager_ = sk_make_sp(); collection_->SetDynamicFontManager(dynamic_font_manager_); diff --git a/third_party/txt/BUILD.gn b/third_party/txt/BUILD.gn index a6a4bd82d170d..af05631f7d137 100644 --- a/third_party/txt/BUILD.gn +++ b/third_party/txt/BUILD.gn @@ -123,6 +123,8 @@ source_set("txt") { deps += [ "$flutter_root/fml" ] } else if (is_android) { sources += [ "src/txt/platform_android.cc" ] + } else if (is_linux) { + sources += [ "src/txt/platform_linux.cc" ] } else { sources += [ "src/txt/platform.cc" ] } diff --git a/third_party/txt/src/txt/font_collection.cc b/third_party/txt/src/txt/font_collection.cc index ff687726ebed9..d1bd02ed748d8 100644 --- a/third_party/txt/src/txt/font_collection.cc +++ b/third_party/txt/src/txt/font_collection.cc @@ -87,8 +87,8 @@ size_t FontCollection::GetFontManagersCount() const { return GetFontManagerOrder().size(); } -void FontCollection::SetDefaultFontManager(sk_sp font_manager) { - default_font_manager_ = font_manager; +void FontCollection::SetupDefaultFontManager() { + default_font_manager_ = GetDefaultFontManager(); } void FontCollection::SetAssetFontManager(sk_sp font_manager) { diff --git a/third_party/txt/src/txt/font_collection.h b/third_party/txt/src/txt/font_collection.h index c98b4d29ca05d..e7fb842933d66 100644 --- a/third_party/txt/src/txt/font_collection.h +++ b/third_party/txt/src/txt/font_collection.h @@ -40,7 +40,7 @@ class FontCollection : public std::enable_shared_from_this { size_t GetFontManagersCount() const; - void SetDefaultFontManager(sk_sp font_manager); + void SetupDefaultFontManager(); void SetAssetFontManager(sk_sp font_manager); void SetDynamicFontManager(sk_sp font_manager); void SetTestFontManager(sk_sp font_manager); diff --git a/third_party/txt/src/txt/platform.cc b/third_party/txt/src/txt/platform.cc index 411e96f0f4b9c..41831870d5335 100644 --- a/third_party/txt/src/txt/platform.cc +++ b/third_party/txt/src/txt/platform.cc @@ -10,4 +10,8 @@ std::string GetDefaultFontFamily() { return "Arial"; } +sk_sp GetDefaultFontManager() { + return SkFontMgr::RefDefault(); +} + } // namespace txt diff --git a/third_party/txt/src/txt/platform.h b/third_party/txt/src/txt/platform.h index d45be43b0392a..3df3433011ea2 100644 --- a/third_party/txt/src/txt/platform.h +++ b/third_party/txt/src/txt/platform.h @@ -8,10 +8,14 @@ #include #include "flutter/fml/macros.h" +#include "third_party/skia/include/core/SkFontMgr.h" + namespace txt { std::string GetDefaultFontFamily(); +sk_sp GetDefaultFontManager(); + } // namespace txt #endif // TXT_PLATFORM_H_ diff --git a/third_party/txt/src/txt/platform_android.cc b/third_party/txt/src/txt/platform_android.cc index 600d3d5ccfd9e..ae7fa2c77ec2c 100644 --- a/third_party/txt/src/txt/platform_android.cc +++ b/third_party/txt/src/txt/platform_android.cc @@ -10,4 +10,8 @@ std::string GetDefaultFontFamily() { return "sans-serif"; } +sk_sp GetDefaultFontManager() { + return SkFontMgr::RefDefault(); +} + } // namespace txt diff --git a/third_party/txt/src/txt/platform_linux.cc b/third_party/txt/src/txt/platform_linux.cc new file mode 100644 index 0000000000000..b95d00a597c7d --- /dev/null +++ b/third_party/txt/src/txt/platform_linux.cc @@ -0,0 +1,19 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "txt/platform.h" + +#include "third_party/skia/include/ports/SkFontMgr_directory.h" + +namespace txt { + +std::string GetDefaultFontFamily() { + return "Arial"; +} + +sk_sp GetDefaultFontManager() { + return SkFontMgr_New_Custom_Directory("/usr/share/fonts/"); +} + +} // namespace txt diff --git a/third_party/txt/src/txt/platform_mac.mm b/third_party/txt/src/txt/platform_mac.mm index 423edddd97c07..3dce7b6ca3954 100644 --- a/third_party/txt/src/txt/platform_mac.mm +++ b/third_party/txt/src/txt/platform_mac.mm @@ -24,4 +24,8 @@ } } +sk_sp GetDefaultFontManager() { + return SkFontMgr::RefDefault(); +} + } // namespace txt