From bc3690ab244a2bff5ea3ca032bc3cb6047b8d777 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 23 Dec 2016 18:41:00 +0000 Subject: Fix [3df559ef7c] - Negative bbox width on OS X. Tested OK on Windows with TK_LAYOUT_WITH_BASE_CHUNKS being defined. --- generic/tkTextDisp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 2171cd0..1be26c4 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -7819,7 +7819,7 @@ CharChunkMeasureChars( MeasureChars(tkfont, chars, charsLen, 0, bstart, 0, -1, 0, &widthUntilStart); - xDisplacement = startX - widthUntilStart - chunkPtr->x; + xDisplacement = startX - widthUntilStart - ciPtr->baseChunkPtr->x; } fit = MeasureChars(tkfont, chars, charsLen, 0, bend, -- cgit v0.12 From f816c46ea5a7eefb2cd880dedfa9e3b344a988f3 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 23 Dec 2016 22:05:42 +0000 Subject: On Windows with TK_LAYOUT_WITH_BASE_CHUNKS and TK_DRAW_IN_CONTEXT being both defined for testing purposes, four tests (textDisp-18.6, 20.2, 20.3 and 20.4) were failing. Fix this. --- generic/tkTextDisp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 1be26c4..4b7b0db 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -8793,7 +8793,7 @@ FinalizeBaseChunk( #if TK_DRAW_IN_CONTEXT newwidth = 0; CharChunkMeasureChars(chunkPtr, NULL, 0, 0, -1, 0, -1, 0, &newwidth); - if (newwidth != chunkPtr->width) { + if (newwidth < chunkPtr->width) { widthAdjust += newwidth - chunkPtr->width; chunkPtr->width = newwidth; } -- cgit v0.12 From 0316d840d0dd2798e1e345dd5a565c3c83ccbae3 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 23 Dec 2016 22:16:42 +0000 Subject: On Windows with TK_LAYOUT_WITH_BASE_CHUNKS and TK_DRAW_IN_CONTEXT being both defined for testing purposes, rendering of the text was incorrect because some chunks were superimposed (this was only a display issue, x and width of all chunks were already correct). Fix this. --- generic/tkTextDisp.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 4b7b0db..f07650f 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -7933,7 +7933,6 @@ CharDisplayProc( #if TK_DRAW_IN_CONTEXT int start = ciPtr->baseOffset + offsetBytes; int len = ciPtr->numBytes - offsetBytes; - int xDisplacement = x - chunkPtr->x; if ((len > 0) && (string[start + len - 1] == '\t')) { len--; @@ -7943,14 +7942,12 @@ CharDisplayProc( } TkpDrawCharsInContext(display, dst, stylePtr->fgGC, sValuePtr->tkfont, - string, numBytes, start, len, - ciPtr->baseChunkPtr->x + xDisplacement, + string, numBytes, start, len, offsetX, y + baseline - sValuePtr->offset); if (sValuePtr->underline) { TkUnderlineCharsInContext(display, dst, stylePtr->ulGC, - sValuePtr->tkfont, string, numBytes, - ciPtr->baseChunkPtr->x + xDisplacement, + sValuePtr->tkfont, string, numBytes, offsetX, y + baseline - sValuePtr->offset, start, start+len); } @@ -7959,8 +7956,7 @@ CharDisplayProc( Tk_GetFontMetrics(sValuePtr->tkfont, &fm); TkUnderlineCharsInContext(display, dst, stylePtr->ovGC, - sValuePtr->tkfont, string, numBytes, - ciPtr->baseChunkPtr->x + xDisplacement, + sValuePtr->tkfont, string, numBytes, offsetX, y + baseline - sValuePtr->offset - fm.descent - (fm.ascent * 3) / 10, start, start+len); -- cgit v0.12 From 531e91677e137dc0d6109374daef5cc802bf7c7d Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 30 Dec 2016 21:11:50 +0000 Subject: Restore correct rendering on OSX that was broken by the previous (platform-independent) commit --- macosx/tkMacOSXFont.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index d3e0e41..78e245a 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -1032,8 +1032,12 @@ TkpDrawCharsInContext( * whole (not just the range) string when * drawing. */ { + int widthUntilStart; + + TkpMeasureCharsInContext(tkfont, source, numBytes, 0, rangeStart, + -1, 0, &widthUntilStart); DrawCharsInContext(display, drawable, gc, tkfont, source, numBytes, - rangeStart, rangeLength, x, y, 0.0); + rangeStart, rangeLength, x-widthUntilStart, y, 0.0); } static void -- cgit v0.12 From aec9ede5b3da6947ff19211dab99b56bb5379305 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 30 Dec 2016 22:20:00 +0000 Subject: Do everything the other way round. Leave things how they were on OS X (revert [a076cf64] and [42e0339e]), and fix TkpDrawCharsInContext() on Win and Linux in case these platforms at some point of time decide to define TK_LAYOUT_WITH_BASE_CHUNKS and TK_DRAW_IN_CONTEXT to true --- generic/tkTextDisp.c | 10 +++++++--- macosx/tkMacOSXFont.c | 6 +----- unix/tkUnixFont.c | 5 ++++- win/tkWinFont.c | 6 +++++- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index f07650f..4b7b0db 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -7933,6 +7933,7 @@ CharDisplayProc( #if TK_DRAW_IN_CONTEXT int start = ciPtr->baseOffset + offsetBytes; int len = ciPtr->numBytes - offsetBytes; + int xDisplacement = x - chunkPtr->x; if ((len > 0) && (string[start + len - 1] == '\t')) { len--; @@ -7942,12 +7943,14 @@ CharDisplayProc( } TkpDrawCharsInContext(display, dst, stylePtr->fgGC, sValuePtr->tkfont, - string, numBytes, start, len, offsetX, + string, numBytes, start, len, + ciPtr->baseChunkPtr->x + xDisplacement, y + baseline - sValuePtr->offset); if (sValuePtr->underline) { TkUnderlineCharsInContext(display, dst, stylePtr->ulGC, - sValuePtr->tkfont, string, numBytes, offsetX, + sValuePtr->tkfont, string, numBytes, + ciPtr->baseChunkPtr->x + xDisplacement, y + baseline - sValuePtr->offset, start, start+len); } @@ -7956,7 +7959,8 @@ CharDisplayProc( Tk_GetFontMetrics(sValuePtr->tkfont, &fm); TkUnderlineCharsInContext(display, dst, stylePtr->ovGC, - sValuePtr->tkfont, string, numBytes, offsetX, + sValuePtr->tkfont, string, numBytes, + ciPtr->baseChunkPtr->x + xDisplacement, y + baseline - sValuePtr->offset - fm.descent - (fm.ascent * 3) / 10, start, start+len); diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index 78e245a..d3e0e41 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -1032,12 +1032,8 @@ TkpDrawCharsInContext( * whole (not just the range) string when * drawing. */ { - int widthUntilStart; - - TkpMeasureCharsInContext(tkfont, source, numBytes, 0, rangeStart, - -1, 0, &widthUntilStart); DrawCharsInContext(display, drawable, gc, tkfont, source, numBytes, - rangeStart, rangeLength, x-widthUntilStart, y, 0.0); + rangeStart, rangeLength, x, y, 0.0); } static void diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index 4a466f1..0c663a3 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -1414,10 +1414,13 @@ TkpDrawCharsInContext( * whole (not just the range) string when * drawing. */ { + int widthUntilStart; + (void) numBytes; /*unused*/ + Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart); Tk_DrawChars(display, drawable, gc, tkfont, source + rangeStart, - rangeLength, x, y); + rangeLength, x+widthUntilStart, y); } /* diff --git a/win/tkWinFont.c b/win/tkWinFont.c index 47c4c3c..860451b 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -1407,9 +1407,13 @@ TkpDrawCharsInContext( * whole (not just the range) string when * drawing. */ { + int widthUntilStart; + (void) numBytes; /*unused*/ + + Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart); Tk_DrawChars(display, drawable, gc, tkfont, source + rangeStart, - rangeLength, x, y); + rangeLength, x+widthUntilStart, y); } /* -- cgit v0.12 From f85e7916a82767bfc0f9fdffbc13edb698456c06 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 1 Jan 2017 20:56:48 +0000 Subject: Fix [28a4535fa2]: Off-by-1 error on text widget index on OS X --- macosx/tkMacOSXFont.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index d3e0e41..db36731 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -870,7 +870,7 @@ TkpMeasureCharsInContext( if (index <= start && !(flags & TK_WHOLE_WORDS)) { index = CTTypesetterSuggestClusterBreak(typesetter, start, maxWidth); } - cs = (index < len || (flags & TK_WHOLE_WORDS)) ? + cs = (index < len && (flags & TK_WHOLE_WORDS)) ? whitespaceCharacterSet : lineendingCharacterSet; while (index > start && [cs characterIsMember:[string characterAtIndex:(index - 1)]]) { -- cgit v0.12 From daf2eae38a06d6471872c5ff1987af418eddbfaf Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 2 Jan 2017 13:19:02 +0000 Subject: 'Fixed' font-24.11 and unixfont-5.12 to fail again identically as they fail in core-8-6-branch. --- macosx/tkMacOSXFont.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index db36731..b5ae1a3 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -870,7 +870,7 @@ TkpMeasureCharsInContext( if (index <= start && !(flags & TK_WHOLE_WORDS)) { index = CTTypesetterSuggestClusterBreak(typesetter, start, maxWidth); } - cs = (index < len && (flags & TK_WHOLE_WORDS)) ? + cs = (index <= len && (flags & TK_WHOLE_WORDS)) ? whitespaceCharacterSet : lineendingCharacterSet; while (index > start && [cs characterIsMember:[string characterAtIndex:(index - 1)]]) { -- cgit v0.12 From 3ae3e292d3d381885989cdaa6d121a7ae8d658a9 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 5 Jan 2017 23:19:41 +0000 Subject: Fix [c12af74765]: OS X - text-21.1 fails --- tests/text.test | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/text.test b/tests/text.test index 8ba177f..9d9b836 100644 --- a/tests/text.test +++ b/tests/text.test @@ -3925,7 +3925,7 @@ test text-20.5 {TextFetchSelection procedure, long selections} -setup { } -result {1} -test text-21.1 {TkTextLostSelection procedure} -constraints unix -setup { +test text-21.1 {TkTextLostSelection procedure} -constraints {unix notAqua} -setup { text .t .t insert 1.0 "Line 1" entry .t.e @@ -3940,6 +3940,21 @@ test text-21.1 {TkTextLostSelection procedure} -constraints unix -setup { } -cleanup { destroy .t .t2 } -result {} +test text-21.1a {TkTextLostSelection procedure} -constraints {unix aqua} -setup { + text .t + .t insert 1.0 "Line 1" + entry .t.e + .t.e insert end "abcdefg" + text .t2 + .t2 insert 1.0 "abc\ndef\nghijk\n1234" +} -body { + .t2 tag add sel 1.2 3.3 + .t.e select from 0 + .t.e select to 1 + .t2 tag ranges sel +} -cleanup { + destroy .t .t2 +} -result {1.2 3.3} test text-21.2 {TkTextLostSelection procedure} -constraints win -setup { text .t .t insert 1.0 "Line 1" -- cgit v0.12 From c20a3010587a7f5b2488d01ec10021f70eb92a8b Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 6 Jan 2017 14:14:21 +0000 Subject: Better fix for [c12af74765]: OS X - text-21.1 fails --- tests/constraints.tcl | 4 ++++ tests/text.test | 19 ++----------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/tests/constraints.tcl b/tests/constraints.tcl index e0486ff..a87499d 100644 --- a/tests/constraints.tcl +++ b/tests/constraints.tcl @@ -180,7 +180,11 @@ namespace import -force tk::test::* namespace import -force tcltest::testConstraint testConstraint notAqua [expr {[tk windowingsystem] ne "aqua"}] testConstraint aqua [expr {[tk windowingsystem] eq "aqua"}] +testConstraint x11 [expr {[tk windowingsystem] eq "x11"}] testConstraint nonwin [expr {[tk windowingsystem] ne "win32"}] +testConstraint aquaOrWin32 [expr { + ([tk windowingsystem] eq "win32") || [testConstraint aqua] +}] testConstraint userInteraction 0 testConstraint nonUnixUserInteraction [expr { [testConstraint userInteraction] || diff --git a/tests/text.test b/tests/text.test index 9d9b836..6812855 100644 --- a/tests/text.test +++ b/tests/text.test @@ -3925,7 +3925,7 @@ test text-20.5 {TextFetchSelection procedure, long selections} -setup { } -result {1} -test text-21.1 {TkTextLostSelection procedure} -constraints {unix notAqua} -setup { +test text-21.1 {TkTextLostSelection procedure} -constraints {x11} -setup { text .t .t insert 1.0 "Line 1" entry .t.e @@ -3940,22 +3940,7 @@ test text-21.1 {TkTextLostSelection procedure} -constraints {unix notAqua} -setu } -cleanup { destroy .t .t2 } -result {} -test text-21.1a {TkTextLostSelection procedure} -constraints {unix aqua} -setup { - text .t - .t insert 1.0 "Line 1" - entry .t.e - .t.e insert end "abcdefg" - text .t2 - .t2 insert 1.0 "abc\ndef\nghijk\n1234" -} -body { - .t2 tag add sel 1.2 3.3 - .t.e select from 0 - .t.e select to 1 - .t2 tag ranges sel -} -cleanup { - destroy .t .t2 -} -result {1.2 3.3} -test text-21.2 {TkTextLostSelection procedure} -constraints win -setup { +test text-21.2 {TkTextLostSelection procedure} -constraints aquaOrWin32 -setup { text .t .t insert 1.0 "Line 1" entry .t.e -- cgit v0.12 From ee8455b769a597dc5d87f89478032b49cf49cdba Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 7 Jan 2017 14:45:40 +0000 Subject: Reverted [7ed6460f] since it fixes an issue unrelated to the bug presented in [3df559ef7c] - Negative bbox width on OS X. --- generic/tkTextDisp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 4b7b0db..1be26c4 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -8793,7 +8793,7 @@ FinalizeBaseChunk( #if TK_DRAW_IN_CONTEXT newwidth = 0; CharChunkMeasureChars(chunkPtr, NULL, 0, 0, -1, 0, -1, 0, &newwidth); - if (newwidth < chunkPtr->width) { + if (newwidth != chunkPtr->width) { widthAdjust += newwidth - chunkPtr->width; chunkPtr->width = newwidth; } -- cgit v0.12