Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 358030 - ImageUtilities.createRotatedImageOfString doesn't take descent into account
Summary: ImageUtilities.createRotatedImageOfString doesn't take descent into account
Status: RESOLVED FIXED
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy Draw2d (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: 3.7.2 (Indigo SR2)   Edit
Assignee: Alexander Nyßen CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-18 14:18 EDT by Alain Picard CLA
Modified: 2011-09-27 12:46 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.