aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dw/hyphenator.cc18
-rw-r--r--test/liang.cc1
2 files changed, 12 insertions, 7 deletions
diff --git a/dw/hyphenator.cc b/dw/hyphenator.cc
index 6af77603..b2e557c5 100644
--- a/dw/hyphenator.cc
+++ b/dw/hyphenator.cc
@@ -300,14 +300,18 @@ int *Hyphenator::hyphenateWord(const char *word, int *numBreaks)
// No hyphens in the first two chars or the last two.
// Characters are not bytes, so UTF-8 characters must be counted.
- int numBytes1 = platform->nextGlyph (wordLc + startActualWord, 0);
- int numBytes2 = platform->nextGlyph (wordLc + startActualWord, numBytes1);
- for (int i = 0; i < numBytes2; i++)
+ int numBytes1Start = platform->nextGlyph (wordLc + startActualWord, 0);
+ int numBytes2Start = platform->nextGlyph (wordLc + startActualWord,
+ numBytes1Start);
+ for (int i = 0; i < numBytes2Start; i++)
points.set (i + 1, 0);
-
- // TODO: Characters, not bytes (as above).
- points.set (points.size() - 2, 0);
- points.set (points.size() - 3, 0);
+
+ int len = strlen (wordLc + startActualWord);
+ int numBytes1End = platform->prevGlyph (wordLc + startActualWord, len);
+ int numBytes2End = platform->prevGlyph (wordLc + startActualWord,
+ numBytes1End);
+ for (int i = 0; i < len - numBytes2End; i++)
+ points.set (points.size() - 2 - i, 0);
// Examine the points to build the pieces list.
SimpleVector <int> breakPos (1);
diff --git a/test/liang.cc b/test/liang.cc
index 4ed717ee..1f08f95c 100644
--- a/test/liang.cc
+++ b/test/liang.cc
@@ -50,6 +50,7 @@ int main (int argc, char *argv[])
hyphenateWord (&p, "Abtei-Stadt");
hyphenateWord (&p, "Nordrhein-Westfalen");
hyphenateWord (&p, "kurz\xc2\xa0und\xc2\xa0knapp");
+ hyphenateWord (&p, "weiß");
return 0;
}