From 84fed7e642c848c5a5cd4a54dec7cc40fd59bc9c Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Wed, 3 Nov 2004 11:54:38 +0000 Subject: [PATCH] Line wrapping needs to work at charachter level, not byte level git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9762 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/BTextView/TextView.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/kits/interface/BTextView/TextView.cpp b/src/kits/interface/BTextView/TextView.cpp index 437abc2665..1a5aa04793 100644 --- a/src/kits/interface/BTextView/TextView.cpp +++ b/src/kits/interface/BTextView/TextView.cpp @@ -3354,8 +3354,9 @@ BTextView::RecalLineBreaks(int32 *startLine, int32 *endLine) &descent, &width); // we want to advance at least by one character - if (toOffset == fromOffset && fromOffset < textLength) - toOffset = NextInitialByte(toOffset); + int32 nextOffset = NextInitialByte(fromOffset); + if (toOffset < nextOffset && fromOffset < textLength) + toOffset = nextOffset; // set the ascent of this line curLine->ascent = ascent; @@ -3573,7 +3574,8 @@ BTextView::FindLineBreak(int32 fromOffset, float *outAscent, strWidth = 0.0; for (offset = fromOffset; offset < limit; offset++) { - strWidth += StyledWidth(offset, 1, &ascent, &descent); + int32 nextInitial = NextInitialByte(offset); + strWidth += StyledWidth(offset, nextInitial - offset, &ascent, &descent); if (strWidth >= *ioWidth) break; @@ -3614,7 +3616,7 @@ BTextView::StyledWidth(int32 fromOffset, int32 length, float *outAscent, maxAscent = max_c(ascent, maxAscent); maxDescent = max_c(descent, maxDescent); - // Use _BWidthBuffer_ if possible + // Use _BWidthBuffer_ if possible (TODO: reenable this when it's fixed) if (false && (sWidths != NULL)) { LockWidthBuffer(); result += sWidths->StringWidth(*fText, fromOffset, numChars, font);