From e528bc07b40e853ec8660b68bd7560ba3430f6ce Mon Sep 17 00:00:00 2001 From: Chun-Heng Tai Date: Fri, 19 May 2023 16:37:52 -0700 Subject: [PATCH 1/3] Removes unnecesary setDefultFontManager --- shell/common/shell.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/shell/common/shell.cc b/shell/common/shell.cc index 7487147f57783..47d66b1d56b5a 100644 --- a/shell/common/shell.cc +++ b/shell/common/shell.cc @@ -2063,7 +2063,6 @@ bool Shell::ReloadSystemFonts() { if (!engine_) { return false; } - engine_->SetupDefaultFontManager(); engine_->GetFontCollection().GetFontCollection()->ClearFontFamilyCache(); // After system fonts are reloaded, we send a system channel message // to notify flutter framework. From 53e7693bb5c96c45482ad7b36db7f49893aa358c Mon Sep 17 00:00:00 2001 From: Chun-Heng Tai Date: Tue, 6 Jun 2023 11:21:41 -0700 Subject: [PATCH 2/3] update --- shell/common/shell.cc | 1 + third_party/txt/BUILD.gn | 8 ++++- third_party/txt/src/txt/font_collection.cc | 1 + .../txt/tests/font_collection_tests.cc | 31 +++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 third_party/txt/tests/font_collection_tests.cc diff --git a/shell/common/shell.cc b/shell/common/shell.cc index 47d66b1d56b5a..7487147f57783 100644 --- a/shell/common/shell.cc +++ b/shell/common/shell.cc @@ -2063,6 +2063,7 @@ bool Shell::ReloadSystemFonts() { if (!engine_) { return false; } + engine_->SetupDefaultFontManager(); engine_->GetFontCollection().GetFontCollection()->ClearFontFamilyCache(); // After system fonts are reloaded, we send a system channel message // to notify flutter framework. diff --git a/third_party/txt/BUILD.gn b/third_party/txt/BUILD.gn index 6abab7cba017b..1f57ef313a84e 100644 --- a/third_party/txt/BUILD.gn +++ b/third_party/txt/BUILD.gn @@ -141,11 +141,17 @@ if (enable_unittests) { executable("txt_unittests") { testonly = true - sources = [ "tests/txt_run_all_unittests.cc" ] + sources = [ + "tests/font_collection_tests.cc", + "tests/txt_run_all_unittests.cc", + ] + + public_configs = [ ":txt_config" ] configs += [ ":allow_posix_names" ] deps = [ + ":txt", ":txt_fixtures", "//flutter/fml", "//flutter/testing:testing_lib", diff --git a/third_party/txt/src/txt/font_collection.cc b/third_party/txt/src/txt/font_collection.cc index 9d1e8b51be4ce..5cef503cb87bf 100644 --- a/third_party/txt/src/txt/font_collection.cc +++ b/third_party/txt/src/txt/font_collection.cc @@ -46,6 +46,7 @@ size_t FontCollection::GetFontManagersCount() const { void FontCollection::SetupDefaultFontManager( uint32_t font_initialization_data) { default_font_manager_ = GetDefaultFontManager(font_initialization_data); + skt_collection_.reset(); } void FontCollection::SetDefaultFontManager(sk_sp font_manager) { diff --git a/third_party/txt/tests/font_collection_tests.cc b/third_party/txt/tests/font_collection_tests.cc new file mode 100644 index 0000000000000..af146bdafd900 --- /dev/null +++ b/third_party/txt/tests/font_collection_tests.cc @@ -0,0 +1,31 @@ +// 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 "gtest/gtest.h" + +#include + +#include "txt/font_collection.h" + +namespace txt { +namespace testing { + +class FontCollectionTests : public ::testing::Test { + public: + FontCollectionTests() {} + + void SetUp() override {} +}; + +TEST_F(FontCollectionTests, SettingUpDefaultFontManagerClearsCache) { + FontCollection font_collection; + sk_sp sk_font_collection = + font_collection.CreateSktFontCollection(); + ASSERT_EQ(sk_font_collection->getFallbackManager().get(), nullptr); + font_collection.SetupDefaultFontManager(0); + sk_font_collection = font_collection.CreateSktFontCollection(); + ASSERT_NE(sk_font_collection->getFallbackManager().get(), nullptr); +} +} // namespace testing +} // namespace txt From dde56dbd1e2ce1e544973445e82be0b35ed99197 Mon Sep 17 00:00:00 2001 From: Chun-Heng Tai Date: Fri, 9 Jun 2023 09:23:23 -0700 Subject: [PATCH 3/3] update license --- third_party/txt/tests/font_collection_tests.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/third_party/txt/tests/font_collection_tests.cc b/third_party/txt/tests/font_collection_tests.cc index af146bdafd900..051d378de17d6 100644 --- a/third_party/txt/tests/font_collection_tests.cc +++ b/third_party/txt/tests/font_collection_tests.cc @@ -1,6 +1,18 @@ -// 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. +/* + * Copyright 2017 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include "gtest/gtest.h"