summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorRaph Levien <raph@google.com>2015-07-29 13:03:50 -0700
committerRaph Levien <raph@google.com>2015-07-29 14:36:33 -0700
commit90a09c3f36d98530822392446884b8af68035908 (patch)
tree05bb6a25516e9bf843b5311e207afd76a60604bf /libs
parent5ba60b1c255efee72316f002bc850908b7f0fe4e (diff)
downloadandroid_frameworks_minikin-90a09c3f36d98530822392446884b8af68035908.tar.gz
android_frameworks_minikin-90a09c3f36d98530822392446884b8af68035908.tar.bz2
android_frameworks_minikin-90a09c3f36d98530822392446884b8af68035908.zip
Improve fallback where explicit variant is not given
In computing scores for which fallback font to choose, a match of a variant given explicitly in the xml config file scores higher than a family with no explicit variant. One consequence is that U+2010 HYPHEN is chosen from the Naskh Arabic font in the fallback case. This patch scores families with no variants as a match (effectively the same as if the xml file specified both variants). Thus, it will choose the first matching font (Roboto), which is a better choice. This patch also revises the list of "sticky" characters to include various hyphens, so Arabic (and potentially other scripts) text that includes hyphens can access the script-specific variants matched to the underlying text. Bug: 22824219 Change-Id: I6ec1043037f89cad50ca99ac24c473395546bcdf
Diffstat (limited to 'libs')
-rw-r--r--libs/minikin/FontCollection.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/libs/minikin/FontCollection.cpp b/libs/minikin/FontCollection.cpp
index e3911c5..b4bfe31 100644
--- a/libs/minikin/FontCollection.cpp
+++ b/libs/minikin/FontCollection.cpp
@@ -122,7 +122,7 @@ FontFamily* FontCollection::getFamilyForChar(uint32_t ch,
return family;
}
int score = lang.match(family->lang()) * 2;
- if (variant != 0 && variant == family->variant()) {
+ if (family->variant() == 0 || family->variant() == variant) {
score++;
}
if (score > bestScore) {
@@ -152,10 +152,13 @@ const uint32_t NBSP = 0xa0;
const uint32_t ZWJ = 0x200c;
const uint32_t ZWNJ = 0x200d;
const uint32_t KEYCAP = 0x20e3;
+const uint32_t HYPHEN = 0x2010;
+const uint32_t NB_HYPHEN = 0x2011;
// Characters where we want to continue using existing font run instead of
// recomputing the best match in the fallback list.
-static const uint32_t stickyWhitelist[] = { '!', ',', '.', ':', ';', '?', NBSP, ZWJ, ZWNJ, KEYCAP };
+static const uint32_t stickyWhitelist[] = { '!', ',', '-', '.', ':', ';', '?', NBSP, ZWJ, ZWNJ,
+ KEYCAP, HYPHEN, NB_HYPHEN };
static bool isStickyWhitelisted(uint32_t c) {
for (size_t i = 0; i < sizeof(stickyWhitelist) / sizeof(stickyWhitelist[0]); i++) {