| Ticket UUID: | 2825888 | |||
| Title: | Off-by-one errors in overlap computation of text items | |||
| Type: | Bug | Version: | obsolete: 8.6b1.1 | |
| Submitter: | ferrieux | Created on: | 2009-07-23 09:30:34 | |
| Subsystem: | 44. Generic Fonts | Assigned To: | hobbs | |
| Priority: | 5 Medium | Severity: | ||
| Status: | Open | Last Modified: | 2009-07-28 15:57:45 | |
| Resolution: | None | Closed By: | ||
| Closed on: | ||||
| Description: |
The semantics of the right and bottom edges of the rectangle passed to [find overlapping] are off by one for text items in a canvas.
Comparing text and rect:
% .c create rect 100 100 150 150
1
% .c create text 100 100 -text abc -anchor nw
2
% .c bbox 1
99 99 151 151
% .c bbox 2
99 100 121 115
% .c find overlapping 0 0 99 300
2
So, for rect (and other item types as well), the right and bottom edges of the test rectangle are considered outside, while for text items they are considered inside.
IOW, the "normal" semantics of the rectangle is a cartesian product of two half-closed intervals:
[left,right[ * [top,bottom[
while for text items it uses closed intervals:
[left,right] * [top,bottom]
This can be traced to surprising use of < and <= in tkFont.c in the Tk_IntersectTextLayout function:
if ((right < x1) || (left >= x2)
|| (bottom < y1) || (top >= y2)) {
[CONSIDER "OUTSIDE"]
here I would replace the two strict "<" by "<=".
One thing to note is that the above behavior has changed rather recently in Tcl history (absent in 8.5.5), while that part of the code has not changed since the beginning. Maybe changing contracts in the rest of the code...
Also note this is *not* a consequence of the 2328657 fixes; but I detected the behavior while analysing that bug.
| |||
| User Comments: |
nijtmans added on 2009-07-28 15:57:44:
Checked this with 8.5.7, and there it indeed works correct. For what's worth, I tend to agree with dkf. dkf added on 2009-07-26 13:17:59: (BTW, I think that means you need another opinion from someone else...) dkf added on 2009-07-26 13:17:03: I don't know that there's any specific reason for this difference. Indeed, I was not aware of this difference in the first place. I'm tempted to say "fix it and see what breaks" | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki