summaryrefslogtreecommitdiff
path: root/libs/minikin/Locale.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/minikin/Locale.cpp')
-rw-r--r--libs/minikin/Locale.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/libs/minikin/Locale.cpp b/libs/minikin/Locale.cpp
index d246020..f7e7323 100644
--- a/libs/minikin/Locale.cpp
+++ b/libs/minikin/Locale.cpp
@@ -467,6 +467,12 @@ bool Locale::supportsScript(uint32_t script) const {
return supportsScript(mSubScriptBits, scriptToSubScriptBits(packedScript));
}
+bool Locale::supportsScript(char c1, char c2, char c3, char c4) const {
+ uint32_t packedScript = packScript(c1, c2, c3, c4);
+ if (packedScript == mScript) return true;
+ return supportsScript(mSubScriptBits, scriptToSubScriptBits(packedScript));
+}
+
int Locale::calcScoreFor(const LocaleList& supported) const {
bool languageScriptMatch = false;
bool subtagMatch = false;
@@ -528,4 +534,29 @@ LocaleList::LocaleList(std::vector<Locale>&& locales) : mLocales(std::move(local
}
}
+bool LocaleList::atLeastOneScriptMatch(const LocaleList& list) const {
+ if ((mUnionOfSubScriptBits & list.mUnionOfSubScriptBits) != 0) {
+ return true;
+ }
+
+ for (const Locale& myLocale : mLocales) {
+ for (const Locale& otherLocale : list.mLocales) {
+ if (myLocale.isEqualScript(otherLocale)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+bool LocaleList::hasScript(char c1, char c2, char c3, char c4) const {
+ for (const Locale& locale : mLocales) {
+ if (locale.supportsScript(c1, c2, c3, c4)) {
+ return true;
+ }
+ }
+ return false;
+}
+
} // namespace minikin