问题描述
我学习ActionScript / Flash中。我喜欢用文字来打,并且已经做了很多这种事情与精湛的Java2D的API。
I'm learning ActionScript/Flash. I love to play with text, and have done a lot of that kind of thing with the superb Java2D API.
的事情之一,我想知道的是里,就是这样,你在画的字形? TextField类提供了方法的getBounds
和使用getCharBoundaries
,但这些方法返回的矩形远远超出的实际边界整个文本对象或个性,分别为。
One of the things I like to know is "where, exactly, are you drawing that glyph?" The TextField class provides the methods getBounds
and getCharBoundaries
, but these methods return rectangles that extend far beyond the actual bounds of the whole text object or the individual character, respectively.
var b:Sprite = new Sprite();
b.graphics.lineStyle(1,0xFF0000);
var r:Rectangle = text.getCharBoundaries(4);
r.offset(text.x, text.y);
b.graphics.drawRect(r.x,r.y,r.width,r.height);
addChild(b);
b = new Sprite();
b.graphics.lineStyle(1,0x00FF00);
r = text.getBounds(this);
b.graphics.drawRect(r.x,r.y,r.width,r.height);
addChild(b);
有没有什么办法让有关的文字字形的ActionScript中的实际可视范围更precise信息?
Is there any way to get more precise information about the actual visual bounds of text glyphs in ActionScript?
推荐答案
没有合理可能性在Flash 9 - 理查德的回答是一个聪明的解决方法,虽然可能完全不适合生产code(因为他提到了): )
Not reasonably possible in Flash 9 -- Richard's answer is a clever work-around, though probably completely unsuitable for production code (as he mentions) :)
如果你有机会到Flash 10,检查出新的的,尤其是一个TextLine。
If you have access to Flash 10, check out the new text engine classes, particularly TextLine.
这篇关于有没有办法让在ActionScript字形的实际边界框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!