Flash AS3,文本抗锯齿是由代码控制的吗?

发布于 2024-10-06 11:14:02 字数 115 浏览 0 评论 0原文

文本抗锯齿是由代码控制的,还是嵌入的?我想要做的是获取别人制作的 swf 文件,找到 swf 文件中的所有文本,并将所有抗锯齿模式从动画更改为可读。在as3中也是这样吗?老实说,我还没有在代码中尝试过任何抗锯齿功能。

Is text anti-aliasing controlled by code, or is it embedded? What I want to do is take a swf file that someone else has made, find all of the text in the swf file and change all of the anti-aliasing modes from animation to readability. Does it work that way in as3? I honestly haven't tried any anti-aliasing in code yet.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦里的微风 2024-10-13 11:14:02

您可以将文本字段的 antiAliasType 设置为“高级”,这样您就可以对清晰度和厚度进行精细控制。但是,必须嵌入字体(包括:文本字段必须将 embedFonts 设置为 true,TextFormat 对象的字体属性必须与嵌入字体的 fontName 完全相同,并且字体必须已编译)。所以从技术上来说“这可能吗?” - 是的。它有可能按照你想要的方式工作吗?不,除非您打算使用您知道已经使用嵌入字体的 swiff。那么您需要从加载的 swiff 中获取所有文本字段(您可以使用如下内容: http:// upshots.org/?p=107,然后使用 array.filter 只返回 TextField 对象),然后应用您的逻辑。

编辑:添加代码示例

// assuming you're using the DisplayList class linked above
var request:URLRequest = new URLRequest("textfields.swf");
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler, false, 0, true);
loader.load(request);

function completeHandler(event:Event):void{

    var content:DisplayObjectContainer = event.target.loader.content as DisplayObjectContainer;
    addChild(content);

    var children:Array = new DisplayList(content);
    children = children.filter(function(item:Object, index:int, array:Array):Boolean {
        return item is TextField;
    });
    children.forEach(function(item:Object, index:int, array:Array):void {
        var textfield:TextField = item as TextField;
        textfield.antiAliasType = AntiAliasType.ADVANCED;
        textfield.sharpness = 100;
        textfield.thickness = 100;
    });
}

刚刚运行了快速测试 - 按描述工作。

you can set the antiAliasType of a textfield to 'advanced', which gives you fine control over sharpness and thickness. however, the fonts must be embedded (inclusive: the textfield must have embedFonts set to true, the TextFormat objects must have font properties exactly equal to the fontName of the embedded font, and the fonts must be already compiled). so technically 'is it possible?' - yes. is it likely to work the way you want it to? no, unless you plan on working with a swiff that you know is using embedded fonts already. then you'll need to grab all the textfields from the loaded swiff (you could use something like this: http://upshots.org/?p=107, then use array.filter to get back only TextField objects), then apply your logic.

EDIT: adding code sample

// assuming you're using the DisplayList class linked above
var request:URLRequest = new URLRequest("textfields.swf");
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler, false, 0, true);
loader.load(request);

function completeHandler(event:Event):void{

    var content:DisplayObjectContainer = event.target.loader.content as DisplayObjectContainer;
    addChild(content);

    var children:Array = new DisplayList(content);
    children = children.filter(function(item:Object, index:int, array:Array):Boolean {
        return item is TextField;
    });
    children.forEach(function(item:Object, index:int, array:Array):void {
        var textfield:TextField = item as TextField;
        textfield.antiAliasType = AntiAliasType.ADVANCED;
        textfield.sharpness = 100;
        textfield.thickness = 100;
    });
}

just ran a quick test - works as described.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文