diff options
author | Sebastian Geerken <devnull@localhost> | 2012-12-05 12:59:19 +0100 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2012-12-05 12:59:19 +0100 |
commit | 2a375b1193544aeb215b12d31066f5b1099084a5 (patch) | |
tree | 2f4ea7ac7aef958e1257ee370cb8cf0008a1b1d7 /dw/hyphenator.cc | |
parent | 9931f73e91bde579357365a3e089834cf23839a3 (diff) |
Hyphenation regard characters, not bytes, at the end.
Diffstat (limited to 'dw/hyphenator.cc')
-rw-r--r-- | dw/hyphenator.cc | 18 |
1 files changed, 11 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); |