-
Notifications
You must be signed in to change notification settings - Fork 6k
Make GetDefaultFontFamilies return a vector<string> instead of a string. #16928
Conversation
e2d581f
to
859b851
Compare
859b851
to
1019b90
Compare
/cc @stuartmorgan |
@@ -319,7 +321,7 @@ FontCollection::CreateSktFontCollection() { | |||
skt_collection_ = sk_make_sp<skia::textlayout::FontCollection>(); | |||
|
|||
skt_collection_->setDefaultFontManager(default_font_manager_, | |||
GetDefaultFontFamily().c_str()); | |||
GetDefaultFontFamilies()[0].c_str()); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
FindFontFamilyInManagers(family); | ||
if (minikin_family != nullptr) { | ||
minikin_families.push_back(minikin_family); | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, good point! Done.
On Linux, there is rarely just one default font that can reasonably be expected to be on the platform. This PR changes the
GetDefaultFontFamily
call to beGetDefaultFontFamilies
, and it now returns avector<string>
so that the font collection code can look up all of them, and if any of them exist, add them to the fallback list.For Linux, I supplied the list "Ubuntu", "Cantarell", "DejaVu Sans", "Liberation Sans", and "Arial", which should cover a large proportion of linux machines. For the other platforms, I supplied a list of length one, containing the one fallback font that used to be defined. On Windows, I added "Segoe UI" as a default, since that is the default system font on newer Windows.
The goal of this function is to provide at least one font family that is installed, since otherwise linux (or any platform) will just have no font at all if the default font isn't found.