> This has been a long standing bug that I've been complaining to Adobe about.

The new Text Layout Framework that Gumbo components use gives you control over 
the vertical placement of the first line.

Gordon Smith
Adobe Flex SDK Team

From: [email protected] [mailto:[email protected]] On Behalf 
Of Jon Bradley
Sent: Tuesday, December 16, 2008 7:46 AM
To: [email protected]
Subject: Re: [flexcoders] Re: Padding/spacing before the first line in a 
TextArea


You can't manually remove that padding from the field. It's built into the 
field as the ascent of the font + 4 pixels for the natural field border (which 
also cannot be 'removed').

There are only two ways to shift up a field in Flash:

Method 1:
a. Bitmap snapshot of the text field
b. getColorRectBounds on the bitmap in question to retrieve a bounding 
rectangle of the non-alpha pixels.
c. Capture the top position from the Rectangle returned from that call and 
subtract that value from the y-position of the field.

Pros:
Will work every time

Cons:
Additional memory overhead. Tricky to do with the Flex component architecture - 
especially TextArea

Method 2:
a. Capture font metrics from the text field
b. Subtract (metrics.ascent + 4) from the text field y position. It is the 
ascent measurement, not descent.

Pros:
Less memory and less code to deal with.

Cons:
Will not work every time. Ascent and descent measurements from the font metrics 
within Flash are not accurate measurements and are only correct at very, very 
specific font sizes (8, 12, 17, 28, 36, 44 ... etc.).

Almost all point sizes of text return incorrect ascent and descent values in 
Flash. They usually return values less than they really are (7,8,9 point type 
will return the same ascent value for most fonts, for example).

Additionally, you'll still need to extend TextArea to handle the functionality.

Does not function well at all with advanced antialiasing ... also a known bug 
in the Flash text rendering. Saffron antialiasing causes a jump in the leading 
and position values of lines in a field, so don't use it.

------

This has been a long standing bug that I've been complaining to Adobe about. 
I've worked on applications for some big greeting card companies (take a couple 
guesses) creating a rendering system in Flash that will match Photoshop and 
Illustrator text rendering. Illustrator, btw, is the only Adobe application 
that let's you set the first baseline position of a text field using a variety 
of measures.

Good luck.

- jon


On Dec 16, 2008, at 8:53 AM, bjorn wrote:


Any ideas on where I might find more info about this? .. or people who might 
know more ...


2008/12/2 bjorn <[email protected]<mailto:[email protected]>>
There is some padding before the first line in a TextArea. Have a look at this 
image to see what I mean:

http://i34.tinypic.com/4uz8s0.jpg

I need to remove this, and the first solution that comes to mind is to find 
that value and position the TextArea.y = TextArea.y - [that value]. The padding 
before the first line seems to be equal (in most cases) to the font's descent, 
which I can get from getTextLineMetrics().descent.

However, this is not true in all cases. In some cases, the padding is more.

Anyone have suggestions?



Reply via email to