summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSeigo Nonaka <nona@google.com>2015-12-14 18:33:23 -0800
committerSeigo Nonaka <nona@google.com>2015-12-22 09:34:04 +0900
commit5e995fb850c2b32631914c3815dfb421855fba9b (patch)
tree10554f7103872f1ea3ecff082aeb2278ece9a792 /include
parent1f0d7947373882f812a119aedeb1948e12a440a0 (diff)
downloadandroid_frameworks_minikin-5e995fb850c2b32631914c3815dfb421855fba9b.tar.gz
android_frameworks_minikin-5e995fb850c2b32631914c3815dfb421855fba9b.tar.bz2
android_frameworks_minikin-5e995fb850c2b32631914c3815dfb421855fba9b.zip
Save all kind of script tags into FontLanguage.
The main purpose of this CL is expanding FontLanguage to be able to save full script tag. Previously, FontLangauge kept only limited script tags. With this CL, FontLanguage keeps all script tags. This CL contains the following changes: - FontLanguage changes: -- Moved to private directory not to be instantiated outside of Minikin. -- Removed bool(), bits(), FontLanguage(uint32_t) methods which are no longer used. -- Change the FontLanguage internal data structure. -- Introduces script match logic. - FontLanguages changes: -- Moved to private directory not to be instantiated outside of Minikin. -- This is now std::vector<FontLanguage> - FontLanguageListCache changes: -- Now FontLanguageListCache::getId through FontStyle::registerLanguageList is the only way to instantiate the FontLanguage. -- Normalize input to be BCP47 compliant identifier by ICU. Bug: 26168983 Change-Id: I8df992a6851021903478972601a9a5c9424b100c
Diffstat (limited to 'include')
-rw-r--r--include/minikin/FontFamily.h64
1 files changed, 5 insertions, 59 deletions
diff --git a/include/minikin/FontFamily.h b/include/minikin/FontFamily.h
index 00130e6..aa2e0ac 100644
--- a/include/minikin/FontFamily.h
+++ b/include/minikin/FontFamily.h
@@ -30,62 +30,6 @@ namespace android {
class MinikinFont;
-// FontLanguage is a compact representation of a bcp-47 language tag. It
-// does not capture all possible information, only what directly affects
-// font rendering.
-class FontLanguage {
- friend class FontStyle;
- friend class FontLanguages;
-public:
- FontLanguage() : mBits(0) { }
-
- // Parse from string
- FontLanguage(const char* buf, size_t size);
-
- bool operator==(const FontLanguage other) const {
- return mBits != kUnsupportedLanguage && mBits == other.mBits;
- }
- operator bool() const { return mBits != 0; }
-
- bool isUnsupported() const { return mBits == kUnsupportedLanguage; }
- bool hasEmojiFlag() const { return isUnsupported() ? false : (mBits & kEmojiFlag); }
-
- std::string getString() const;
-
- // 0 = no match, 1 = language matches
- int match(const FontLanguage other) const;
-
-private:
- explicit FontLanguage(uint32_t bits) : mBits(bits) { }
-
- uint32_t bits() const { return mBits; }
-
- static const uint32_t kUnsupportedLanguage = 0xFFFFFFFFu;
- static const uint32_t kBaseLangMask = 0xFFFFFFu;
- static const uint32_t kHansFlag = 1u << 24;
- static const uint32_t kHantFlag = 1u << 25;
- static const uint32_t kEmojiFlag = 1u << 26;
- static const uint32_t kScriptMask = kHansFlag | kHantFlag | kEmojiFlag;
- uint32_t mBits;
-};
-
-// A list of zero or more instances of FontLanguage, in the order of
-// preference. Used for further resolution of rendering results.
-class FontLanguages {
-public:
- FontLanguages() { mLangs.clear(); }
-
- // Parse from string, which is a comma-separated list of languages
- FontLanguages(const char* buf, size_t size);
-
- const FontLanguage& operator[](size_t index) const { return mLangs.at(index); }
-
- size_t size() const { return mLangs.size(); }
-
-private:
- std::vector<FontLanguage> mLangs;
-};
-
// FontStyle represents all style information needed to select an actual font
// from a collection. The implementation is packed into two 32-bit words
// so it can be efficiently copied, embedded in other objects, etc.
@@ -158,7 +102,9 @@ class FontFamily : public MinikinRefCounted {
public:
FontFamily() : mHbFont(nullptr) { }
- FontFamily(FontLanguage lang, int variant) : mLang(lang), mVariant(variant), mHbFont(nullptr) {
+ FontFamily(int variant);
+
+ FontFamily(uint32_t langId, int variant) : mLangId(langId), mVariant(variant), mHbFont(nullptr) {
}
~FontFamily();
@@ -169,7 +115,7 @@ public:
void addFont(MinikinFont* typeface, FontStyle style);
FakedFont getClosestMatch(FontStyle style) const;
- FontLanguage lang() const { return mLang; }
+ uint32_t langId() const { return mLangId; }
int variant() const { return mVariant; }
// API's for enumerating the fonts in a family. These don't guarantee any particular order
@@ -200,7 +146,7 @@ private:
MinikinFont* typeface;
FontStyle style;
};
- FontLanguage mLang;
+ uint32_t mLangId;
int mVariant;
std::vector<Font> mFonts;