查找TextLayout组件的文本高度

时间:2012-02-07 18:11:37

标签: actionscript-3 actionscript

有没有人知道是否有办法在TextLayout类中找到文本的高度?

我正在制作我的TextLayout对象:

        this._textFlow = new TextFlow();
        this._paragraphElement = new ParagraphElement();
        this._textFlow.addChild(this._paragraphElement);

        this._span = new SpanElement();
        this._span.text = this._text;
        this._paragraphElement.addChild(this._span);
        if(this._textAlign != ''){
            this._paragraphElement.textAlign = this._textAlign;
        }

        var tempTextWidth:Number;
        var tempTextHeight:Number;
        if(this._textWidth > 0){
            tempTextWidth = this._textWidth;
        } else {
            tempTextWidth = NaN;
        }
        if(this._textHeight > 0){
            tempTextHeight = this._textHeight;
        } else {
            tempTextHeight = NaN;
        }

        this._containerController = new ContainerController(this, tempTextWidth, tempTextHeight);
        this._textFlow.flowComposer.addController(this._containerController);
        this._textFlow.flowComposer.updateAllControllers();

我希望找到高度的所有公共属性都是未定义的,例如this._textFlow.lineHeight。

谢谢,

克里斯

1 个答案:

答案 0 :(得分:1)

根据documentation,默认情况下lineHeight未定义,undefined值表示行高为文本高度的120%。文本高度由fontSize属性确定,默认情况下也未定义,即文本高度为12。

假设您的应用程序中两者都未定义,则每行的高度应为1.2 * 12 = 14.4。免责声明:我从未真正使用过Text Layout Framework,也不知道这些信息有多可靠。