summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorRoozbeh Pournader <roozbeh@google.com>2015-07-15 10:59:59 -0700
committerRoozbeh Pournader <roozbeh@google.com>2015-07-15 10:59:59 -0700
commitdaf62d0eef9e339c9d3269e5eaa2007d25c18194 (patch)
tree6c416d4f82296c90a4d9a1ed344194debd5f65b5 /libs
parentbaf6d0a41fdabb0f859bd065f3724921a3e91089 (diff)
downloadandroid_frameworks_minikin-daf62d0eef9e339c9d3269e5eaa2007d25c18194.tar.gz
android_frameworks_minikin-daf62d0eef9e339c9d3269e5eaa2007d25c18194.tar.bz2
android_frameworks_minikin-daf62d0eef9e339c9d3269e5eaa2007d25c18194.zip
Add missing hyphen-like characters.
This adds various hyphen-like characters missed in the previous patch, that should disallow automatic hyphenation of words containing them. Bug: 22484266 Change-Id: Ie972cb50384dbe0aa1ab5ec50286b75f9877953a
Diffstat (limited to 'libs')
-rw-r--r--libs/minikin/LineBreaker.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/libs/minikin/LineBreaker.cpp b/libs/minikin/LineBreaker.cpp
index bf8be26..72e5c18 100644
--- a/libs/minikin/LineBreaker.cpp
+++ b/libs/minikin/LineBreaker.cpp
@@ -29,9 +29,7 @@ using std::vector;
namespace android {
const int CHAR_TAB = 0x0009;
-const uint16_t CHAR_HYPHEN_MINUS = 0x002D;
const uint16_t CHAR_SOFT_HYPHEN = 0x00AD;
-const uint16_t CHAR_HYPHEN = 0x2010;
// Large scores in a hierarchy; we prefer desperate breaks to an overfull line. All these
// constants are larger than any reasonable actual width score.
@@ -107,6 +105,24 @@ static bool isLineEndSpace(uint16_t c) {
c == 0x205F || c == 0x3000;
}
+// This function determines whether a character is like U+2010 HYPHEN in
+// line breaking and usage: a character immediately after which line breaks
+// are allowed, but words containing it should not be automatically
+// hyphenated. This is a curated set, created by manually inspecting all
+// the characters that have the Unicode line breaking property of BA or HY
+// and seeing which ones are hyphens.
+static bool isLineBreakingHyphen(uint16_t c) {
+ return (c == 0x002D || // HYPHEN-MINUS
+ c == 0x058A || // ARMENIAN HYPHEN
+ c == 0x05BE || // HEBREW PUNCTUATION MAQAF
+ c == 0x1400 || // CANADIAN SYLLABICS HYPHEN
+ c == 0x2010 || // HYPHEN
+ c == 0x2013 || // EN DASH
+ c == 0x2027 || // HYPHENATION POINT
+ c == 0x2E17 || // DOUBLE OBLIQUE HYPHEN
+ c == 0x2E40); // DOUBLE HYPHEN
+}
+
// Ordinarily, this method measures the text in the range given. However, when paint
// is nullptr, it assumes the widths have already been calculated and stored in the
// width buffer.
@@ -163,7 +179,7 @@ float LineBreaker::addStyleRun(MinikinPaint* paint, const FontCollection* typefa
if (c != CHAR_SOFT_HYPHEN) {
// TODO: Add a new type of HyphenEdit for breaks whose hyphen already exists, so
// we can pass the whole word down to Hyphenator like the soft hyphen case.
- bool wordEndsInHyphen = (c == CHAR_HYPHEN_MINUS || c == CHAR_HYPHEN);
+ bool wordEndsInHyphen = isLineBreakingHyphen(c);
if (paint != nullptr && mHyphenator != nullptr &&
mHyphenationFrequency != kHyphenationFrequency_None &&
!wordEndsInHyphen && !temporarilySkipHyphenation &&