diff --git a/engine/src/flutter/include/minikin/FontCollection.h b/engine/src/flutter/include/minikin/FontCollection.h index 78ab2aae7b9..508a129a99f 100644 --- a/engine/src/flutter/include/minikin/FontCollection.h +++ b/engine/src/flutter/include/minikin/FontCollection.h @@ -57,6 +57,9 @@ public: void itemize(const uint16_t *string, size_t string_length, FontStyle style, std::vector* result) const; + // Get the base font for the given style, useful for font-wide metrics. + MinikinFont* baseFont(FontStyle style); + uint32_t getId() const; private: static const int kLogCharsPerPage = 8; diff --git a/engine/src/flutter/libs/minikin/FontCollection.cpp b/engine/src/flutter/libs/minikin/FontCollection.cpp index 1713b476e0b..c13670e74a8 100644 --- a/engine/src/flutter/libs/minikin/FontCollection.cpp +++ b/engine/src/flutter/libs/minikin/FontCollection.cpp @@ -185,6 +185,14 @@ void FontCollection::itemize(const uint16_t *string, size_t string_size, FontSty } } +MinikinFont* FontCollection::baseFont(FontStyle style) { + if (mInstances.empty()) { + return NULL; + } + return mInstances[0].mFamily->getClosestMatch(style); +} + + uint32_t FontCollection::getId() const { return mId; }