Jon:

Thanks for taking the time to answer this so extensively. Your Method 2 is
what I've come up with so far, only using descent instead of ascent, as you
pointed out. And yeah, you're right - it doesn't always work since Flash
does not seem to return accurate values for ascent/descent/etc. for all
fonts. So I'm feeling kind of stuck at the end of this road ... maybe a
Gumbo-truck will come to rescue soon?? ;-)


Alex Harui:

> Subclass and reposition the internal textfield.

The repositioning itself is not the problem, finding the number of pixels to
reposition by is :)

Bjørn




2008/12/17 Gordon Smith <[email protected]>

>    > 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]>
>
> 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?
>
>
>
>
>
>   
>



-- 
========================
http://www.juicability.com - flex blog
http://www.nospoiler.com - link to youtube videos without the spoilers

Reply via email to