summaryrefslogtreecommitdiffstats
path: root/include/minikin/FontFamily.h
diff options
context:
space:
mode:
authorSeigo Nonaka <nona@google.com>2015-09-24 18:41:41 +0900
committerSeigo Nonaka <nona@google.com>2015-10-12 18:53:45 +0900
commit0f2a025d135f9ca52cc3cf917fffc29d6c126094 (patch)
tree689fb7a3b3c2a16be8c9eaa54fe1f290d2cfd7f7 /include/minikin/FontFamily.h
parent7c8ac67a9022590d32d25e61094f29f7af42357d (diff)
downloadandroid_frameworks_minikin-0f2a025d135f9ca52cc3cf917fffc29d6c126094.tar.gz
android_frameworks_minikin-0f2a025d135f9ca52cc3cf917fffc29d6c126094.tar.bz2
android_frameworks_minikin-0f2a025d135f9ca52cc3cf917fffc29d6c126094.zip
Introduce FontFamily::hasVariationSelector
This CL introduces new method hasVariationSelector into FontFamily but it is not used in production code. So no behavior changes are expected. This CL contains the following changes: - Introduce hasVariationSelector which returns true if the corresponding font has a glyph for a code point and variation selector pair. - Introduce purgeHbFontCache since hb_face_t won't be released by keeping hb_font_t. - Introduce unit tests with self-built font. Change-Id: I659a6d03d9ec446b409e1fba2758452abb9f44fa
Diffstat (limited to 'include/minikin/FontFamily.h')
-rw-r--r--include/minikin/FontFamily.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/include/minikin/FontFamily.h b/include/minikin/FontFamily.h
index d21a20a..b199404 100644
--- a/include/minikin/FontFamily.h
+++ b/include/minikin/FontFamily.h
@@ -19,6 +19,7 @@
#include <vector>
#include <string>
+#include <hb.h>
#include <utils/TypeHelpers.h>
@@ -123,9 +124,9 @@ struct FakedFont {
class FontFamily : public MinikinRefCounted {
public:
- FontFamily() { }
+ FontFamily() : mHbFont(nullptr) { }
- FontFamily(FontLanguage lang, int variant) : mLang(lang), mVariant(variant) {
+ FontFamily(FontLanguage lang, int variant) : mLang(lang), mVariant(variant), mHbFont(nullptr) {
}
~FontFamily();
@@ -147,6 +148,16 @@ public:
// Get Unicode coverage. Lifetime of returned bitset is same as receiver. May return nullptr on
// error.
const SparseBitSet* getCoverage();
+
+ // Returns true if the font has a glyph for the code point and variation selector pair.
+ // Caller should acquire a lock before calling the method.
+ bool hasVariationSelector(uint32_t codepoint, uint32_t variationSelector);
+
+ // Purges cached mHbFont.
+ // hb_font_t keeps a reference to hb_face_t which is managed by HbFaceCache. Thus,
+ // it is good to purge hb_font_t once it is no longer necessary.
+ // Caller should acquire a lock before calling the method.
+ void purgeHbFontCache();
private:
void addFontLocked(MinikinFont* typeface, FontStyle style);
@@ -163,6 +174,8 @@ private:
SparseBitSet mCoverage;
bool mCoverageValid;
+
+ hb_font_t* mHbFont;
};
} // namespace android