From 06b2132f076029e9b6ee37732e4886b0dd7ca2f8 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 23 Sep 2024 04:01:26 +0000 Subject: [PATCH] A slightly different approach is beeded to deal with angled text. --- generic/tkCanvText.c | 13 +++++++------ tests/canvText.test | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c index ca4a42256..0581bed31 100644 --- a/generic/tkCanvText.c +++ b/generic/tkCanvText.c @@ -737,6 +737,12 @@ ComputeTextBbox( width = height = 0; } + /* Extend the width to account for characters that overhang. + * See [7ea3245acd] + */ + + width += overhang; + /* * Use overall geometry information to compute the top-left corner of the * bounding box for the text item. @@ -841,12 +847,7 @@ ComputeTextBbox( tmp = x[i]; } } - - /* Extend the bounding box to account for characters that overhang. - * See [7ea3245acd] - */ - - textPtr->header.x2 = ROUND(tmp) + overhang; + textPtr->header.x2 = ROUND(tmp); for (i=1,tmp=y[0] ; i<4 ; i++) { if (y[i] > tmp) { tmp = y[i]; diff --git a/tests/canvText.test b/tests/canvText.test index 1263ad468..f6c2b2813 100644 --- a/tests/canvText.test +++ b/tests/canvText.test @@ -967,7 +967,7 @@ test canvText-20.1 {angled text bounding box} -setup { # bboxes should be the same, possibly with a small (platform-specific) rounding difference list [expr {[almosteq $bb0 $bb2] ? "ok" : "$bb0,$bb2"}] \ [expr {[almosteq $bb1 $bb3] ? "ok" : "$bb1,$bb3"}] \ - [expr {[almosteq $bb0 [transpose $bb1]] ? "ok" : "$bb0,$bb1"}] + [expr {[almosteq $bb0 [transpose $bb1]] ? "ok" : "$bb0,[transpose $bb1]"}] } -cleanup { destroy .c rename transpose {}