Bug 35790 - GC#stringExtent() lies
Summary: GC#stringExtent() lies
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.0.2   Edit
Hardware: PC Windows XP
: P3 major with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-27 19:05 EST by adrian CLA
Modified: 2019-09-06 16:10 EDT (History)
1 user (show)

See Also:


Attachments
Test program. (2.44 KB, text/plain)
2003-03-27 19:07 EST, adrian CLA
no flags Details
example run on Eclipse 2.1. (524.47 KB, image/bmp)
2003-03-28 07:47 EST, Veronika Irvine CLA
no flags Details
GC#stringExtent() in R2.0.2 (8.45 KB, image/gif)
2003-03-28 08:54 EST, adrian CLA
no flags Details
StringExtent() out to lunch (8.90 KB, image/gif)
2003-03-28 15:22 EST, adrian CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description adrian CLA 2003-03-27 19:05:30 EST
See attachment with test program.

1.- There is a mismatch between actual painting with gc.drawString() and the
gc.stringExtent() info returned, for e.g., chars '\u0001' - \u0006'.  The extent
returned is larger than the actual extent painted.

This makes it impossible e.g., to match a mouse-click's x offset in the window
to the correct index inside the displayed text string.

2.- These characters seem to be filtered out somehow by StyledText's rendering:  
they have a width of 0 pixels on the display?!  Consequently, StyledText seems
to manage fine to correlate an x offset to the correct text.  How is it solved
in StyledText (i.e., what is this workaround)??  I believe is better to not show
them at all (like StyledText appears to do), than cheese out the screen...

3.- What is the full set of these characters?
Comment 1 adrian CLA 2003-03-27 19:07:10 EST
Created attachment 4376 [details]
Test program.
Comment 2 Veronika Irvine CLA 2003-03-28 07:46:04 EST
This bug is reported against 2.0.2.  In Eclipse 2.1, all the strings in the 
example have a length of 400 pixels.  I will attach a picture of what it looks 
like.  I believe this looks correct.  

It depends on the font used whether it has a glyph for the character and how 
that glyph appears (question mark, empty rectangle, black rectangle etc).  Are 
you calling the glyph used for the characters '\u0001' - \u0006' "cheese"?
Comment 3 Veronika Irvine CLA 2003-03-28 07:47:42 EST
Created attachment 4380 [details]
example run on Eclipse 2.1.
Comment 4 adrian CLA 2003-03-28 08:47:50 EST
>>> Are you calling the glyph used for the characters '\u0001' - \u0006' "cheese"?

No, cheese is caused by other display operations I do (selections, selected
background painting, etc.), in which I rely on the information returned by
stringExtent(), but which is not in sync with the actual stuff displayed.
Comment 5 adrian CLA 2003-03-28 08:54:34 EST
Created attachment 4381 [details]
GC#stringExtent() in R2.0.2
Comment 6 adrian CLA 2003-03-28 08:56:09 EST
Your R2.1 image looks good, I'll give it a try.

I've attached what displays in R2.0.2, for the record.
Comment 7 adrian CLA 2003-03-28 15:17:32 EST
I still get the bad results (as in my previous attachment) for font "Courier"
10, on XP Home edition (version 5.1 SP1).  With "Courier New" 10 the output is
different (I'll attach), but just as bad.

TextEditor (and consequently JDT's JavaEditor, etc.) is still nicely 'filtering'
these characters / glyphs out from its own display.
Comment 8 adrian CLA 2003-03-28 15:22:06 EST
Created attachment 4390 [details]
StringExtent() out to lunch

Will also try R2.1 on Windows 2000 next week...
Comment 9 adrian CLA 2003-03-28 15:23:56 EST
The R2.1 I'm using is build I20030326-win32.
Comment 10 adrian CLA 2003-04-01 13:43:21 EST
Tried with the Eclipse R2.1 official release, Windows 2000 (v5.0 SP3):
I get the same bad results (with both the "Courier" and the "Courier New"
fonts)...
Comment 11 Silenio Quarti CLA 2003-04-08 19:35:15 EDT
Chrix to investigate and advise.
Comment 12 Eclipse Webmaster CLA 2019-09-06 16:10:29 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.