是否可以将 `[Embed source=`... 与 Flash CS3 一起使用?
是否可以使用 AS3 和 Flash CS3 IDE 执行以下操作?仅当在 IDE 中创建 txt
TextField 并且删除 txt.embedFonts
行时,以下内容才有效。如果我使用 AS3 而不是使用 IDE 创建 TextField,则这不起作用。通过代码嵌入字体只能在 Flex 中使用吗?
package mtm.EmbedFonts
{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.AntiAliasType;
import flash.text.TextFieldAutoSize;
public class EmbedFonts extends MovieClip
{
public var txt:TextField; //References stage instance created in Flash CS3 IDE
[Embed(source='C:/WINDOWS/Fonts/Arial.TTF', fontName='_Arial', unicodeRange='U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E')]
protected var format:TextFormat = new TextFormat();
public function EmbedFonts():void
{
initTextFormat();
initTextField();
txt.text = 'Hello World!';
}
protected function initTextFormat():void
{
format.letterSpacing = 1;
format.size = 14;
format.font = "Arial";
}
protected function initTextField():void
{
txt.multiline = true;
txt.wordWrap = true;
txt.border = true;
txt.selectable = true;
txt.autoSize = TextFieldAutoSize.LEFT;
txt.condenseWhite = true;
txt.embedFonts = true;
txt.setTextFormat(format);
txt.antiAliasType = AntiAliasType.ADVANCED;
}
}
}
Is it possible to do the following using AS3 and Flash CS3 IDE? The following only works if the txt
TextField is created in the IDE and if the txt.embedFonts
line is removed. This does not work if I create a TextField with AS3 instead of using the IDE. Is embedding a font via code only available in Flex?
package mtm.EmbedFonts
{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.AntiAliasType;
import flash.text.TextFieldAutoSize;
public class EmbedFonts extends MovieClip
{
public var txt:TextField; //References stage instance created in Flash CS3 IDE
[Embed(source='C:/WINDOWS/Fonts/Arial.TTF', fontName='_Arial', unicodeRange='U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E')]
protected var format:TextFormat = new TextFormat();
public function EmbedFonts():void
{
initTextFormat();
initTextField();
txt.text = 'Hello World!';
}
protected function initTextFormat():void
{
format.letterSpacing = 1;
format.size = 14;
format.font = "Arial";
}
protected function initTextField():void
{
txt.multiline = true;
txt.wordWrap = true;
txt.border = true;
txt.selectable = true;
txt.autoSize = TextFieldAutoSize.LEFT;
txt.condenseWhite = true;
txt.embedFonts = true;
txt.setTextFormat(format);
txt.antiAliasType = AntiAliasType.ADVANCED;
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
遗憾的是,[Embed] 元标记仅在 Flex 中可用。
The [Embed] metatag is only available in Flex sadly.