Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 62951

Summary: [rulers] Line numbers are not aligned with text
Product: [Eclipse Project] JDT Reporter: Douglas Pollock <douglas.pollock>
Component: UIAssignee: Tom Hofmann <eclipse>
Status: VERIFIED FIXED QA Contact:
Severity: trivial    
Priority: P3 CC: daniel_megert
Version: 3.0   
Target Milestone: 3.0 RC1   
Hardware: Sun   
OS: Solaris   
Whiteboard:

Description Douglas Pollock CLA 2004-05-19 11:17:28 EDT
I200405190010, Solaris 8, CDE

The line numbers on the side of the Java editor are not aligned with the text of
the editor itself.  It appears as though the numbers are slightly higher (I'd
guess around 5-10 pixels).  It is particularly noticeable at the level of the
class definition, where the text is right next to the numbers.
Comment 1 Dani Megert CLA 2004-05-19 11:39:29 EDT
What font?
Is this a regression?

We cannot see it on Linux-GTK and WinXP.
Comment 2 Tom Hofmann CLA 2004-05-19 11:45:44 EDT
reproducible also on motif (I believe CDE is somehow motif-based, no?).

On motif, we're off by 1 pixel with a courier 10pt, 3px with a 14 pt font.
Comment 3 Douglas Pollock CLA 2004-05-19 11:49:28 EDT
Default font (iso8859-1, courier(adobe), medium, 12).  I'm not sure if this is 
a regression. 
 
CDE is the desktop environment.  We only support Motif on Solaris. 
Comment 4 Tom Hofmann CLA 2004-05-19 12:09:17 EDT
in 2.0, the line numbers are aligned, so this is a regression. Although, in 2.0,
the line number ruler has double width... not sure what's worse.
Comment 5 Douglas Pollock CLA 2004-05-19 15:30:57 EDT
This also appears to affect the underlined items in the Java editor.  The
warning and error squigglies appear too high relative to the text.
Comment 6 Dani Megert CLA 2004-05-20 07:06:01 EDT
should check what changed since 2.0
Comment 7 Tom Hofmann CLA 2004-05-20 17:25:56 EDT
This could be related to bug 63154. It mentions Solaris explicitely in bug 63154
comment 0, and the problem seems to be measuring line height / baseline.
Comment 8 Dani Megert CLA 2004-05-21 05:01:27 EDT
We debugged it down to GC.drawString: on Windows this seems to draw the string
correctly but on Linux-Motif it's directly at the top.
Comment 9 Steve Northover CLA 2004-05-21 08:48:54 EDT
Felipe, is this another manifestation of the "baseline problem" that was 
introduced when we implemented italic fonts for StyledText?
Comment 10 Felipe Heidrich CLA 2004-05-21 10:14:04 EDT
Daniel, try this:

//code that draws the line number
Font font = someFont;
GC gc = someGC;
gc.setFont(font);
FontMetrics fm = gc.getFontMetrics();
int baseline = fm.getAscent() + fm.getLeading();
int stBaseline = styledText.getBaseline();
String lineNumber = "1";
gc.drawString(lineNumber, someX, someY + (stBaseline - baseline ));
//end

This should fix the problem.
Comment 11 Felipe Heidrich CLA 2004-05-21 10:16:39 EDT
Daniel, send this pr back to me if the code in comment#10 doesn't work.
Comment 12 Dani Megert CLA 2004-05-21 11:06:59 EDT
tom, please try this out
Comment 13 Tom Hofmann CLA 2004-05-24 10:59:41 EDT
fixed > 20040524
Comment 14 Dirk Baeumer CLA 2004-06-11 13:21:00 EDT
start verifying...
Comment 15 Dirk Baeumer CLA 2004-06-11 13:21:26 EDT
verified under Linux Motif on build I20040611.