summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/minikin/FontCollection.h3
-rw-r--r--libs/minikin/FontCollection.cpp8
2 files changed, 11 insertions, 0 deletions
diff --git a/include/minikin/FontCollection.h b/include/minikin/FontCollection.h
index 78ab2aa..508a129 100644
--- a/include/minikin/FontCollection.h
+++ b/include/minikin/FontCollection.h
@@ -57,6 +57,9 @@ public:
void itemize(const uint16_t *string, size_t string_length, FontStyle style,
std::vector<Run>* 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/libs/minikin/FontCollection.cpp b/libs/minikin/FontCollection.cpp
index 1713b47..c13670e 100644
--- a/libs/minikin/FontCollection.cpp
+++ b/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;
}