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

Bug 358030

Summary: ImageUtilities.createRotatedImageOfString doesn't take descent into account
Product: [Tools] GEF Reporter: Alain Picard <picard>
Component: GEF-Legacy Draw2dAssignee: Alexander Nyßen <nyssen>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipse.felipe, nyssen
Version: 3.7   
Target Milestone: 3.7.2 (Indigo SR2)   
Hardware: PC   
OS: Windows Vista   
Whiteboard:

Description Alain Picard CLA 2011-09-18 14:18:32 EDT
Build Identifier: I20110613-1736

Rotating of a text with character that have descent (like g) clips the descent part of the characters.

Fix is to take descent into account as done here:
Image srcImage = new Image(display, strSize.width, metrics.getAscent() + metrics.getDescent());  //added + getDescent()


Reproducible: Always
Comment 1 Felipe Heidrich CLA 2011-09-19 15:13:12 EDT
you forgot to add the leading
try this:

Image srcImage = new Image(display, strSize.width, metrics.getAscent() +
metrics.getDescent() + metrics.getLeading());

reopen the bug if that doesn't work.

Note that maybe you want to use TextLayout as you do more interesting things to text using a TextLayout.
(and in TextLayout the value for leading is always zero (our secret), so if you forget it there you will be okay).
Comment 2 Alain Picard CLA 2011-09-19 15:44:54 EDT
As they say, one solution leads to another...better one.

Great
Comment 3 Alain Picard CLA 2011-09-19 15:46:00 EDT
BTW this is a class supplied by Eclipse and used by many, not my code. So why won't this be fixed. That part doesn't make sense to me.
Comment 4 Felipe Heidrich CLA 2011-09-19 16:39:56 EDT
(In reply to comment #3)
> BTW this is a class supplied by Eclipse and used by many, not my code. So why
> won't this be fixed. That part doesn't make sense to me.

What class ?
FontMetrics is fine IMO. See the doc for getAscent() and getDescent() they both are very explict saying that they don't include the leading.

What do you want me to fix ? Sorry, I don't think I understood your suggestion.
Comment 5 Alain Picard CLA 2011-09-19 18:20:40 EDT
This is a bug report regarding class:
org.eclipse.draw2d.ImageUtilities in method createRotatedImageOfString at line 53 where it now reads:
Image srcImage = new Image(display, strSize.width, metrics.getAscent());

and it doesn't take into account the descent and also as got pointed out here, the leading value.

So I would expect such a bug report (and solution) to be followed by a fix of this method in this dras2d class.
Comment 6 Felipe Heidrich CLA 2011-09-20 10:13:33 EDT
Thanks!
but that is not a SWT class, I believe it belongs to GEF.
Comment 7 Alexander Nyßen CLA 2011-09-27 12:46:29 EDT
Changed implementation to now respect descent, ascent, and leading. Committed changes to cvs HEAD as well as R3_7_maintenance branch. Validated changes with GEF's rulers, which make use of this API.