summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeigo Nonaka <nona@google.com>2021-04-17 22:43:45 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-04-17 22:43:45 +0000
commite15a7768ae2230afd48d7a0359f221ddcdc7d0dd (patch)
tree7719cfa78b77359036ab330e1ffe1b11f324cf4b
parent03d9007a6915c20fe226d6e7f42aae910a3662b3 (diff)
parentb67f9c4a19d87a49501765ffdc1cfca1457c003d (diff)
downloadminikin-e15a7768ae2230afd48d7a0359f221ddcdc7d0dd.tar.gz
Update native font API to read updated font files am: b67f9c4a19
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/minikin/+/14193063 Change-Id: I5a939934bc4f802f2d4c68992ceeeb5bf3750a48
-rw-r--r--include/minikin/SystemFonts.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/minikin/SystemFonts.h b/include/minikin/SystemFonts.h
index 686f32e..616997d 100644
--- a/include/minikin/SystemFonts.h
+++ b/include/minikin/SystemFonts.h
@@ -43,6 +43,18 @@ public:
return getInstance().registerDefaultInternal(fc);
}
+ using FontMapDeleter = std::function<void()>;
+
+ static void addFontMap(std::shared_ptr<FontCollection>&& collections) {
+ return getInstance().addFontMapInternal(std::move(collections));
+ }
+
+ // This obtains a mutex inside, so do not call this method inside callback.
+ static void getFontMap(
+ std::function<void(const std::vector<std::shared_ptr<FontCollection>>&)> func) {
+ return getInstance().getFontMapInternal(func);
+ }
+
protected:
// Visible for testing purposes.
SystemFonts() {}
@@ -60,11 +72,24 @@ protected:
mDefaultFallback = fc;
}
+ void addFontMapInternal(std::shared_ptr<FontCollection>&& collections) {
+ std::lock_guard<std::mutex> lock(mMutex);
+ mCollections.emplace_back(std::move(collections));
+ }
+
+ void getFontMapInternal(
+ std::function<void(const std::vector<std::shared_ptr<FontCollection>>&)> func) {
+ std::lock_guard<std::mutex> lock(mMutex);
+ func(mCollections);
+ }
+
private:
static SystemFonts& getInstance();
std::map<std::string, std::shared_ptr<FontCollection>> mSystemFallbacks GUARDED_BY(mMutex);
std::shared_ptr<FontCollection> mDefaultFallback GUARDED_BY(mMutex);
+ std::vector<std::shared_ptr<FontCollection>> mCollections GUARDED_BY(mMutex);
+
std::mutex mMutex;
};