TextField autoSize+最后一个字符的斜体剪切
在actionscript 3中,我的TextField
具有:
- CSS样式
- 嵌入字体
- textAlign:CENTER
- autoSize:CENTER
...当使用斜体时,最右边的字符会被稍微切断(特别是大写字母)。 基本上看来它无法检测到正确的尺寸。
我以前遇到过这个问题,但只是想知道是否有一个很好的解决方法(而不是检查 textWidth
或偏移文本等)?
In actionscript 3, my TextField
has :
- CSS styling
- embedded fonts
- textAlign : CENTER
- autoSize : CENTER
... when italics are used the very right character gets slightly cut off (specially caps).
It basically seems that it fails detecting the right size.
I've had this problem before but just wondered is there a nice workaround (instead of checking textWidth
or offsetting text etc.)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
像往常一样初始化您的
textField
,使用多行、自动调整大小、htmlText...然后执行以下小技巧:
Initialize your
textField
as you always do, using multiline, autosize, htmlText...Then do this little trick :
这并不是说这对您来说很舒服,但 Flash 有时在完成这个看似简单的任务时遇到了麻烦。 html
TextField
的 CSS 样式是一个很好的补充,但它给文本渲染带来了麻烦。事实上,出于这个原因,我非常很少使用 CSS 来设置文本样式。我只能想象,在 HTML 中组合粗体、斜体和普通字体会导致 Flash 的一些宽度计算错误,从而导致autoSize
将蒙版设置得稍微短一点。我非常希望 Flash Player 10 中出现新的文本渲染引擎 最终会解决这些问题(理论上看起来确实更好)。因此,我的解决方案是从不使用 HTML,除非我在文本中需要
链接...并且有甚至还有一些棘手的文本转换问题。在这些情况下,我避免在同一文本字段中混合不同的字体粗细和字体样式。所有其他情况下,我直接在
TextField
上使用TextFormat
。我想如果您无法摆脱当前的架构(由于某种原因),您可以尝试将
添加到 html 编码字符串的末尾。或者您可以手动设置字段的宽度而不依赖
autoSize
(正如您所提到的)。但是,如果您继续使用 CSS/HTML 路线,您可能会在您不想要的时候发现另一个新的、令人痛苦的限制。Not that it is much comfort to you, but Flash sometimes has trouble with this seemingly simple task. CSS styling of html
TextField
was a nice addition but it has caused headaches for text-rendering. In fact I very rarely use CSS for styling text for that reason. I can only imagine that combining bold, italic and normal type faces within the HTML causes Flash to get some of the width calculations wrong which causesautoSize
to set the mask a tiny bit short. I hope very much that the new text rendering engine in Flash Player 10 will finally fix these issues (it certainly looks better in theory).So my solution is never to use HTML with the exception being when I require
<a>
links in my text ... and there are even some tricky text shifting issues there. In those cases I avoid mixing different font weights and font styles within the same text field. All other cases I useTextFormat
directly onTextField
.I suppose if you can't get out of your current architecture (for some reason) you could try adding
to the end of your html encoded strings. Or you could manually set the width of the field and not rely on
autoSize
(as you have mentioned). But if you keep on the CSS/HTML route you may find another new and painful limitation just when you don't want it.我遇到了
TextField
遮罩在 Flash 预览中和实际浏览器插件中表现不同的问题。通常,这对我来说很奇怪,它在浏览器中显示得更正确。您是否尝试过在浏览器中运行swf
来查看该问题是否实际上是一个烦恼而不是一个永久性问题?我说过这样的话:
我解决此问题的理想方法是将更改事件附加到 TextField ,该事件始终在字段的最后一个字符后添加一个空格。然后记住在使用该值时修剪掉这个空格。
但这没有考虑到这可能没有更改事件并且它是 HTML 呈现的文本字段。要在 HTML 文本字段中添加尾随空格,请再次输入
,这并不能真正解决问题。
I've had issues with
TextField
masks behaving differently in the Flash preview, and in the actual browser plugin. Usually, and this is strange to me, it would appear more correctly in the browser. Have you tried running theswf
in a browser to see if the problem is actually an annoyance rather than a permanent problem?I had said this:
My in-ideal approach to solving this is to attach a change event to the
TextField
which always adds a space after the last character of the field. And then to remember to trim this space off when using the value.But that didn't take into account that this probably doesn't have a change event and that it's an HTML rendered text field. To add a trailing space in the HTML text field throw in an
again, that's not really fixing the problem.