2012-02-07 70 views
1

有誰知道是否有辦法在TextLayout類中查找文本的高度?查找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。

謝謝,

克里斯

+0

在與高度相關的屬性獲取值之前,可能需要顯示一次。 – 2012-02-07 20:52:17

回答

1

按照documentation,lineHeight是在默認情況下未定義,並且未定義的值是指線高度是文本高度的120%。文本高度由fontSize屬性確定,默認情況下該屬性也未定義,即文本高度爲12.

假設在您的應用程序中兩者都未定義,每行的高度應爲1.2 * 12 = 14.4。免責聲明:我從來沒有真正使用過Text Layout Framework,也不知道這些信息有多可靠。

+0

檢查過;你是對的。 – 2013-01-03 19:56:46