Skip to content

Commit

Permalink
A slightly different approach is beeded to deal with angled text.
Browse files Browse the repository at this point in the history
  • Loading branch information
culler committed Sep 23, 2024
1 parent 6e51918 commit 06b2132
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions generic/tkCanvText.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion tests/canvText.test
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down

0 comments on commit 06b2132

Please sign in to comment.