mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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:
parent
06dec08ca2
commit
1e35d09df1
@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user