diff --git a/engine/src/flutter/third_party/txt/BUILD.gn b/engine/src/flutter/third_party/txt/BUILD.gn index 60bb416ee1..c331d14b09 100644 --- a/engine/src/flutter/third_party/txt/BUILD.gn +++ b/engine/src/flutter/third_party/txt/BUILD.gn @@ -86,6 +86,7 @@ source_set("txt") { "src/txt/paragraph_builder.h", "src/txt/paragraph_style.cc", "src/txt/paragraph_style.h", + "src/txt/platform.h", "src/txt/styled_runs.cc", "src/txt/styled_runs.h", "src/txt/text_align.h", @@ -100,6 +101,14 @@ source_set("txt") { "src/utils/TypeHelpers.h", ] + if (is_mac || is_ios) { + set_sources_assignment_filter([]) + sources += [ "src/txt/platform_mac.mm" ] + set_sources_assignment_filter(sources_assignment_filter) + } else { + sources += [ "src/txt/platform.cc" ] + } + public_configs = [ ":txt_config" ] public_deps = [ 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 2a763278a2..e2a0efb65d 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 @@ -25,6 +25,7 @@ #include #include "font_skia.h" #include "lib/ftl/logging.h" +#include "txt/platform.h" #include "txt/text_style.h" namespace txt { @@ -107,7 +108,7 @@ FontCollection::GetMinikinFontCollectionForFamily(const std::string& family) { return font_collection; } - const auto default_font_family = TextStyle::GetDefaultFontFamily(); + const auto default_font_family = GetDefaultFontFamily(); if (family != default_font_family) { return GetMinikinFontCollectionForFamily(default_font_family); } diff --git a/engine/src/flutter/third_party/txt/src/txt/platform.cc b/engine/src/flutter/third_party/txt/src/txt/platform.cc new file mode 100644 index 0000000000..fa35f0e196 --- /dev/null +++ b/engine/src/flutter/third_party/txt/src/txt/platform.cc @@ -0,0 +1,13 @@ +// Copyright 2017 The Chromium 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" + +namespace txt { + +std::string GetDefaultFontFamily() { + return "Roboto"; +} + +} // namespace txt diff --git a/engine/src/flutter/third_party/txt/src/txt/platform.h b/engine/src/flutter/third_party/txt/src/txt/platform.h new file mode 100644 index 0000000000..7b993e0f02 --- /dev/null +++ b/engine/src/flutter/third_party/txt/src/txt/platform.h @@ -0,0 +1,17 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef TXT_PLATFORM_H_ +#define TXT_PLATFORM_H_ + +#include +#include "lib/ftl/macros.h" + +namespace txt { + +std::string GetDefaultFontFamily(); + +} // namespace txt + +#endif // TXT_PLATFORM_H_ diff --git a/engine/src/flutter/third_party/txt/src/txt/platform_mac.mm b/engine/src/flutter/third_party/txt/src/txt/platform_mac.mm new file mode 100644 index 0000000000..b15ce10ef3 --- /dev/null +++ b/engine/src/flutter/third_party/txt/src/txt/platform_mac.mm @@ -0,0 +1,22 @@ +// Copyright 2017 The Chromium 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 +#include "txt/platform.h" + +#if TARGET_OS_EMBEDDED +#include +#define FONT_CLASS UIFont +#else // TARGET_OS_EMBEDDED +#include +#define FONT_CLASS NSFont +#endif // TARGET_OS_EMBEDDED + +namespace txt { + +std::string GetDefaultFontFamily() { + return [FONT_CLASS systemFontOfSize:14].familyName.UTF8String; +} + +} // namespace txt diff --git a/engine/src/flutter/third_party/txt/src/txt/text_style.cc b/engine/src/flutter/third_party/txt/src/txt/text_style.cc index 7516d24ff4..0796ad27e4 100644 --- a/engine/src/flutter/third_party/txt/src/txt/text_style.cc +++ b/engine/src/flutter/third_party/txt/src/txt/text_style.cc @@ -14,17 +14,14 @@ * limitations under the License. */ +#include "text_style.h" #include "font_style.h" #include "font_weight.h" -#include "text_style.h" #include "third_party/skia/include/core/SkColor.h" +#include "txt/platform.h" namespace txt { -std::string TextStyle::GetDefaultFontFamily() { - return "Roboto"; -} - TextStyle::TextStyle() : font_family(GetDefaultFontFamily()) {} bool TextStyle::equals(const TextStyle& other) const { diff --git a/engine/src/flutter/third_party/txt/src/txt/text_style.h b/engine/src/flutter/third_party/txt/src/txt/text_style.h index a17254c5d7..9e2dc06e21 100644 --- a/engine/src/flutter/third_party/txt/src/txt/text_style.h +++ b/engine/src/flutter/third_party/txt/src/txt/text_style.h @@ -46,8 +46,6 @@ class TextStyle { double word_spacing = 0.0; double height = 1.0; - static std::string GetDefaultFontFamily(); - TextStyle(); bool equals(const TextStyle& other) const;