是否有可能在 AS3 中获得准确的字符/字体度量?
我创建了一个类,它将使用嵌入字体在运行时动态生成位图字体。 到目前为止,它运行良好,只是我在字符间距方面有一个小问题。
在下图中,第一行是实际的 TextField
,第二行已渲染 使用生成的位图字体。
如果您查看单词“fox”或单词“jumped”的“ed”,您可以看到字母间距看起来有点奇怪。
TextLineMetrics
类是否有任何替代方案可以为我提供更准确的字符指标?
更新:
使用新的 Flash 文本引擎的文本渲染质量:
更新2:
偶然我最终找到了解决方案:
第一个问题是 antiAliasType
属性设置为AntiAliasType.ADVANCED
。
尽管它会生成更高质量的文本,但也会导致 TextLineMetrics
返回不正确的字符宽度。
第二个是它还必须向上舍入(使用 Math.ceil)到最近的像素,而不是向下舍入。
I have created a class which will use an embedded font to dynamically generate a bitmap font at run-time.
So far it works well except that I have a minor issue with character spacing.
In the image below the first line is an actual TextField
and the second has been rendered
using the generated bitmap font.
If you look at the word 'fox' or the 'ed' of the word 'jumped' you can see that the letter spacing looks a little bit odd.
Are there any alternatives to the TextLineMetrics
class which will give me more accurate character metrics?
UPDATE :
Text rendering quality using the new Flash Text Engine :
UPDATE 2 :
By chance I have eventually found the solution :
The first problem was the antiAliasType
property which was set to AntiAliasType.ADVANCED
.
Although it produces higher quality text it also causes TextLineMetrics
to return incorrect widths for characters.
The second was that it had to also be rounded up (using Math.ceil
) to the nearest pixel and not down.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
TextField 太重了。
flash.text.engine 将更好地用于位图生成
TextField is too heavy to that.
flash.text.engine will work better for bitmap generateing