Add baseFont method to FontCollection

This patch adds a method to retrieve the base font from a
FontCollection, which is useful when querying global font metrics.

Part of the fix for bug 15467288 "Inconsistent line heights on
Minikin builds"

Change-Id: I268ae5128d0852a020d746bc22af81fc1a623228
This commit is contained in:
Raph Levien 2014-06-05 22:40:15 -07:00
parent 06dec08ca2
commit 1e35d09df1
2 changed files with 11 additions and 0 deletions

View File

@ -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;

View File

@ -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;
}