Bug 319646 - Text's vertical positioning within Text control is inconsistent with GC.drawString
Summary: Text's vertical positioning within Text control is inconsistent with GC.drawS...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.6   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Scott Kovatch CLA
QA Contact: Silenio Quarti CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-12 18:23 EDT by Doug M CLA
Modified: 2019-09-06 16:07 EDT (History)
1 user (show)

See Also:


Attachments
Demonstrates problem. (5.75 KB, application/octet-stream)
2010-07-12 18:23 EDT, Doug M CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Doug M CLA 2010-07-12 18:23:31 EDT
Created attachment 174109 [details]
Demonstrates problem.

We are attempting to align text drawn directly in Composite with text drawn in a Text control by drawing the text and placing the control at the same y position. Their vertical alignment varies with the point size, as the Text control seems to "randomly" add space above its Text. Therefore at some point sizes, alignment is perfect, while at others the Text's text is lowered by 1-2 pixels.

StyledText's alignment is always exactly right.

I think that computeTrim is supposed to report the unused area around a control, however it always indicates no trim, and getClientRect is the same as the Text's bounds. Likewise, the information returned by FontMetrics getHeight, getAscent, and getDescent reveals no consistency to the misalignment. (At least I can't deduce any.)

I am developing a complex text-based client that needs to draw editable text, with text and graphic decorations in precise relationship to the Text. So I need to be able to tell exactly where Text draws its text (in relation to the Text or its parent), either by it's being consistent, or the API revealing this information.

------------------------------------
Textalign attachment draws Courier text in a Composite's PaintListener at the same vertical position as a Text. It also draws a horizontal line at the text position. The Bigger and Smaller buttons adjust the font size. Note that for some sizes the text is not aligned.

Values for the bounds, trim, and client rectangles, and font height, ascent, and descent are printed to Output.

Change Text to StyledText to see the alignment work always.
Comment 1 Scott Kovatch CLA 2010-07-15 13:14:36 EDT
I think this is a rounding or truncation error of some kind. Cocoa uses fractional points, which we convert to integral values.
Comment 2 Eclipse Webmaster CLA 2019-09-06 16:07:02 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.