summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormdejong <mdejong>2004-08-09 23:48:11 (GMT)
committermdejong <mdejong>2004-08-09 23:48:11 (GMT)
commitd5fe0750220b427c1aa8081d80bf33c614c5f987 (patch)
treef357f6aa844b20cc3bf79bb0a11fc51406fff627
parente0cb984907178744d3fc7780d943c2a6806423dc (diff)
downloadtk-d5fe0750220b427c1aa8081d80bf33c614c5f987.zip
tk-d5fe0750220b427c1aa8081d80bf33c614c5f987.tar.gz
tk-d5fe0750220b427c1aa8081d80bf33c614c5f987.tar.bz2
* tests/canvText.test:
* win/tkWinFont.c (Tk_MeasureChars): Fix for text wrapping problem that appeared using canvas text under Win32. A long wrapping string that had leading spaces was being incorrectly wrapped. This change makes the Win32 implementation behave the same as the Unix implementation. [Patch 100628
-rw-r--r--ChangeLog10
-rw-r--r--tests/canvText.test57
-rw-r--r--win/tkWinFont.c4
3 files changed, 68 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 25a53b8..e64321f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2004-08-09 Mo DeJong <mdejong@users.sourceforge.net>
+
+ * tests/canvText.test:
+ * win/tkWinFont.c (Tk_MeasureChars): Fix for text
+ wrapping problem that appeared using canvas text
+ under Win32. A long wrapping string that had
+ leading spaces was being incorrectly wrapped.
+ This change makes the Win32 implementation behave
+ the same as the Unix implementation. [Patch 1006286]
+
2004-08-04 Donal K. Fellows <donal.k.fellows@man.ac.uk>
* generic/tkImgPhoto.c (ImgPhotoBlendComplexAlpha): Clean the code
diff --git a/tests/canvText.test b/tests/canvText.test
index 21f09a6..9400b2b 100644
--- a/tests/canvText.test
+++ b/tests/canvText.test
@@ -6,7 +6,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: canvText.test,v 1.12 2003/02/09 07:48:22 hobbs Exp $
+# RCS: @(#) $Id: canvText.test,v 1.12.2.1 2004/08/09 23:48:11 mdejong Exp $
package require tcltest 2.1
namespace import -force tcltest::configure
@@ -516,6 +516,61 @@ test canvText-18.1 {bug fix 2525, find enclosed on text with newlines} {
.c find enclosed 99 99 [expr $x2 + $i] [expr $y2 + 1]
} 1
+test canvText-19.1 {patch 1006286, leading space caused wrap under Win32} {
+ catch {destroy .c}
+ set c [canvas .c -bg black -width 964]
+ pack $c
+ $c delete all
+ after 1000 "set done 1" ; vwait done
+
+ set f {Arial 28 bold}
+
+ set s1 { Yeah-ah-ah-ah-oh-oh-oh-oh-oh-oh-oh-oh-oh-oh-oh-oh-oh-oh-oh-oh-Yow}
+ set s2 { Yeah ah ah ah oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh Yow}
+
+ $c create text 21 18 \
+ -font $f \
+ -text $s1 \
+ -fill white \
+ -width 922 \
+ -anchor nw \
+ -tags tbox1
+ eval {$c create rect} [$c bbox tbox1] -outline red
+
+ $c create text 21 160 \
+ -font $f \
+ -text $s2 \
+ -fill white \
+ -width 922 \
+ -anchor nw \
+ -tags tbox2
+ eval {$c create rect} [$c bbox tbox2] -outline red
+
+ after 1000 "set done 1" ; vwait done
+
+ set results [list]
+
+ $c select from tbox2 4
+ $c select to tbox2 8
+ lappend results [selection get]
+
+ $c select from tbox1 4
+ $c select to tbox1 8
+ lappend results [selection get]
+
+ array set metrics [font metrics $f]
+ set x [expr {21 + [font measure $f " "] \
+ + ([font measure {Arial 28 bold} "Y"] / 2)}]
+ set y1 [expr {18 + ($metrics(-linespace) / 2)}]
+ set y2 [expr {160 + ($metrics(-linespace) / 2)}]
+
+ lappend results [$c index tbox1 @$x,$y1]
+ lappend results [$c index tbox2 @$x,$y2]
+
+ set results
+} {{Yeah } Yeah- 4 4}
+
+
# cleanup
::tcltest::cleanupTests
return
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index 33dd131..0ec67fa 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinFont.c,v 1.17.2.2 2004/05/05 16:51:22 hobbs Exp $
+ * RCS: @(#) $Id: tkWinFont.c,v 1.17.2.3 2004/08/09 23:48:11 mdejong Exp $
*/
#include "tkWinInt.h"
@@ -764,7 +764,7 @@ Tk_MeasureChars(
end = p;
p = source;
- ch = 0;
+ ch = ' ';
while (p < end) {
next = p + Tcl_UtfToUniChar(p, &ch2);
if ((ch != ' ') && (ch2 == ' ')) {