From: SourceForge.net <no...@so...> - 2009-07-26 06:18:00
|
Bugs item #2825888, was opened at 2009-07-23 10:30 Message generated for change (Comment added) made by dkf You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112997&aid=2825888&group_id=12997 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: 44. Generic Fonts Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Alexandre Ferrieux (ferrieux) Assigned to: Jeffrey Hobbs (hobbs) Summary: Off-by-one errors in overlap computation of text items Initial Comment: 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. ---------------------------------------------------------------------- >Comment By: Donal K. Fellows (dkf) Date: 2009-07-26 07:17 Message: (BTW, I think that means you need another opinion from someone else...) ---------------------------------------------------------------------- Comment By: Donal K. Fellows (dkf) Date: 2009-07-26 07:17 Message: 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" ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112997&aid=2825888&group_id=12997 |