summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoozbeh Pournader <roozbeh@google.com>2015-06-12 10:29:59 -0700
committerRoozbeh Pournader <roozbeh@google.com>2015-06-12 15:23:10 -0700
commitf997dd21968bac16966269aede235247fb08a00b (patch)
tree16554809acf79d2b9def1088553190481bf59969
parent73fa6dfd6366c6ac04d6a25cdcc0721f5b3e7fbb (diff)
downloadandroid_frameworks_minikin-f997dd21968bac16966269aede235247fb08a00b.tar.gz
android_frameworks_minikin-f997dd21968bac16966269aede235247fb08a00b.tar.bz2
android_frameworks_minikin-f997dd21968bac16966269aede235247fb08a00b.zip
Use ASCII HYPHEN-MINUS when there's no HYPHEN in the font.
Previously, we just assumed the font in use had a U+2010 HYPHEN character, resulting in a tofu (or an empty space) being shown when U+2010 was not supported in the font used to render the hyphenated word. Now we try to fallback to U+002D HYPHEN-MINUS, which has a very good chance of being available in at least any Latin font. We still show a tofu when neither character is supported, to intentionally alert that something is missing. Bug: 20497913 Bug: 21088552 Bug: 21570828 Change-Id: Iff69bbc38836c03495e9124502b5207c39270da2
-rw-r--r--libs/minikin/Layout.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/libs/minikin/Layout.cpp b/libs/minikin/Layout.cpp
index 88baeac..17ce596 100644
--- a/libs/minikin/Layout.cpp
+++ b/libs/minikin/Layout.cpp
@@ -729,7 +729,17 @@ void Layout::doLayoutRun(const uint16_t* buf, size_t start, size_t count, size_t
// TODO: check whether this is really the desired semantics. It could have the
// effect of assigning the hyphen width to a nonspacing mark
unsigned int lastCluster = srunend - 1;
- hb_buffer_add(buffer, 0x2010, lastCluster);
+
+ hb_codepoint_t hyphenChar = 0x2010; // HYPHEN
+ hb_codepoint_t glyph;
+ // Fallback to ASCII HYPHEN-MINUS if the font didn't have a glyph for HYPHEN. Note
+ // that we intentionally don't do anything special if the font doesn't have a
+ // HYPHEN-MINUS either, so a tofu could be shown, hinting towards something
+ // missing.
+ if (!hb_font_get_glyph(hbFont, hyphenChar, 0, &glyph)) {
+ hyphenChar = 0x002D; // HYPHEN-MINUS
+ }
+ hb_buffer_add(buffer, hyphenChar, lastCluster);
}
hb_shape(hbFont, buffer, features.empty() ? NULL : &features[0], features.size());
unsigned int numGlyphs;