Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shell/platform/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ group("linux") {
}
}

# Temporary workraround for the issue describe in
# Temporary workaround for the issue describe in
# https://github.com/flutter/flutter/issues/14509 and
# https://github.com/flutter/flutter/issues/14438
# Remove once the build infrastructure moves to Ubuntu 18.04 or newer, where
Expand Down
15 changes: 9 additions & 6 deletions third_party/txt/src/txt/font_collection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,14 @@ FontCollection::GetMinikinFontCollectionForFamilies(
}
// Search for default font family if no user font families were found.
if (minikin_families.empty()) {
const auto default_font_family = GetDefaultFontFamily();
std::shared_ptr<minikin::FontFamily> minikin_family =
FindFontFamilyInManagers(default_font_family);
if (minikin_family != nullptr) {
minikin_families.push_back(minikin_family);
const auto default_font_families = GetDefaultFontFamilies();
for (auto family : default_font_families) {
std::shared_ptr<minikin::FontFamily> minikin_family =
FindFontFamilyInManagers(family);
if (minikin_family != nullptr) {
minikin_families.push_back(minikin_family);
break;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exit the loop here. It should be sufficient to provide the first available default font instead of merging all available default fonts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good point! Done.

}
}
// Default font family also not found. We fail to get a FontCollection.
Expand Down Expand Up @@ -319,7 +322,7 @@ FontCollection::CreateSktFontCollection() {
skt_collection_ = sk_make_sp<skia::textlayout::FontCollection>();

skt_collection_->setDefaultFontManager(default_font_manager_,
GetDefaultFontFamily().c_str());
GetDefaultFontFamilies()[0].c_str());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SkParagraph FontCollection API in Skia will need to be extended to handle multiple default fonts. I'll look into this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I wasn't sure what to do about that yet, so I just punted and provided the first one. I suppose I could do a similar thing to what I did above and just supply the first existing one.

skt_collection_->setAssetFontManager(asset_font_manager_);
skt_collection_->setDynamicFontManager(dynamic_font_manager_);
skt_collection_->setTestFontManager(test_font_manager_);
Expand Down
4 changes: 2 additions & 2 deletions third_party/txt/src/txt/platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace txt {

std::string GetDefaultFontFamily() {
return "Arial";
std::vector<std::string> GetDefaultFontFamilies() {
return {"Arial"};
}

sk_sp<SkFontMgr> GetDefaultFontManager() {
Expand Down
4 changes: 3 additions & 1 deletion third_party/txt/src/txt/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
#define TXT_PLATFORM_H_

#include <string>
#include <vector>

#include "flutter/fml/macros.h"

#include "third_party/skia/include/core/SkFontMgr.h"

namespace txt {

std::string GetDefaultFontFamily();
std::vector<std::string> GetDefaultFontFamilies();

sk_sp<SkFontMgr> GetDefaultFontManager();

Expand Down
4 changes: 2 additions & 2 deletions third_party/txt/src/txt/platform_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace txt {

std::string GetDefaultFontFamily() {
return "sans-serif";
std::vector<std::string> GetDefaultFontFamilies() {
return {"sans-serif"};
}

sk_sp<SkFontMgr> GetDefaultFontManager() {
Expand Down
4 changes: 2 additions & 2 deletions third_party/txt/src/txt/platform_fuchsia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace txt {

std::string GetDefaultFontFamily() {
return "Roboto";
std::vector<std::string> GetDefaultFontFamilies() {
return {"Roboto"};
}

sk_sp<SkFontMgr> GetDefaultFontManager() {
Expand Down
4 changes: 2 additions & 2 deletions third_party/txt/src/txt/platform_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

namespace txt {

std::string GetDefaultFontFamily() {
return "Arial";
std::vector<std::string> GetDefaultFontFamilies() {
return {"Ubuntu", "Cantarell", "DejaVu Sans", "Liberation Sans", "Arial"};
}

sk_sp<SkFontMgr> GetDefaultFontManager() {
Expand Down
6 changes: 3 additions & 3 deletions third_party/txt/src/txt/platform_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

namespace txt {

std::string GetDefaultFontFamily() {
std::vector<std::string> GetDefaultFontFamilies() {
if (fml::IsPlatformVersionAtLeast(9)) {
return [FONT_CLASS systemFontOfSize:14].familyName.UTF8String;
return {[FONT_CLASS systemFontOfSize:14].familyName.UTF8String};
} else {
return "Helvetica";
return {"Helvetica"};
}
}

Expand Down
4 changes: 2 additions & 2 deletions third_party/txt/src/txt/platform_windows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

namespace txt {

std::string GetDefaultFontFamily() {
return "Arial";
std::vector<std::string> GetDefaultFontFamilies() {
return {"Segoe UI", "Arial"};
}

sk_sp<SkFontMgr> GetDefaultFontManager() {
Expand Down
3 changes: 1 addition & 2 deletions third_party/txt/src/txt/text_style.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@

namespace txt {

TextStyle::TextStyle()
: font_families(std::vector<std::string>(1, GetDefaultFontFamily())) {}
TextStyle::TextStyle() : font_families(GetDefaultFontFamilies()) {}

bool TextStyle::equals(const TextStyle& other) const {
if (color != other.color)
Expand Down