最后一个字符的文本字段的autoSize +斜体削减斜体、字段、字符、文本

2023-09-08 14:44:52 作者:今天的風超甜

在ActionScript 3中,我的文本字段有:

In actionscript 3, my TextField has :

在CSS样式 嵌入字体 设置textAlign:中心 的autoSize:中心

...当使用斜体非常正确的字符被稍稍切去(特别是盖)。 它基本上看来,它没有检测到合适的尺寸。

... when italics are used the very right character gets slightly cut off (specially caps). It basically seems that it fails detecting the right size.

我以前有这个问题,但只是想知道有没有一个很好的解决方法(而不是检查输出textWidth 或偏移文本等)?

I've had this problem before but just wondered is there a nice workaround (instead of checking textWidth or offsetting text etc.)?

推荐答案

初始化你的 textField的为你总是这样,采用多线,自动调整,的htmlText ...

Initialize your textField as you always do, using multiline, autosize, htmlText...

然后做这个小动作:

// saving wanted width and height plus 1px to get some space for last char
var savedWidth = myTextField.width + 1;
var savedHeight = myTextField.height + 1;

// removing autoSize, wich is the origin of the problem i think                 
myTextField.autoSize = "none";      

// now manually autoSizing the textField with saved values          
myTextField.width = savedWidth;
myTextField.height = savedHeight;