2
votes

I need to get a distance between Baseline and Lowercase line inside the scaled TextField, using ActionScript 3. I marked it's with the blue arrows here: enter image description here

Does anybody knows how to get this value?

2
Based on the info provided in the diagram/by AS3 I don't think it's possible. A fun puzzle, but unfortunately it appears impossible (perhaps this is somehow based on the font?) - shaunhusain

2 Answers

2
votes

What you are looking for is called the x-height. Unfortunately, the Flash ActionScript API does not provide any way of getting the x-height for a typeface.

With some tricky techniques, you might be able to calculate the x-height yourself though. I am thinking you might be able to create a new textfield with just an "x" in it, and draw it to a bitmapdata. Then test the pixels to get the height.

2
votes
var s:String=yourTF.text; // preserve
yourTF.text='x';
var c:uint=yourTF.textColor; // get color
var bd:BitmapData=new BitmapData(yourTF.width,yourTF.height);
bd.draw(yourTF);
var r:Rectangle=bg.getColorBoundsRect(0x00ffffff,c);
trace(r.height);
yourTF.text=s;