Flexbuilder 中的字体嵌入与其他字体嵌入CS4
我有一个全 AS3 Flex 项目,我在其中嵌入了字体。我正在尝试从 CS4 运行这个项目。但是,由于某种原因,文本根本没有显示。
Flex AS3 中的代码如下所示:
[Embed(source='C:/WINDOWS/Fonts/ArialBD.TTF', fontWeight = 'bold', fontName='ArialBold', unicodeRange='U+0020-U+0020,U+0021-...')] //a bunch of other unicode
public static var _VerdanaFontBold:Class;
[Embed(source='C:/WINDOWS/Fonts/Arial.TTF', fontWeight = 'regular', fontName='Arial', unicodeRange='U+0020-U+0020...')] //a bunch of other unicode
public static var _VerdanaFont:Class;
在我的文本出现的扩展文本字段的构造函数中,我有:
Font.registerFont(_VerdanaFontBold);
Font.registerFont(_VerdanaFont);
我发现 这篇文章关于使用 Flash 嵌入元数据,但我也无法让它工作(我尝试了 systemFont="Arial" 以及底部评论中的建议那篇文章)。
所以我尝试注释掉上面的行并以另一种方式进行。在 CS4 中,我知道我应该在 FLA 文件的设计模式下创建一个空白文本字段。然后我可以选择要嵌入到属性面板中的字体。我选择了 verdana(大小写、标点符号、数字等)。但当我在 CS4 中运行该应用程序时,文本字段再次为空。
事实上,我将字体嵌入到空白文本字段中,而不是我设置的文档类调用的字体,这应该不重要,对吗? -- 字体应该嵌入到 swf 中并可供使用。但它是空白的。
有人有什么想法吗?
I have an all-AS3 Flex project in which I embed fonts. I'm trying to run this project from CS4. However, for some reason the text isn't showing up at all.
The code in the Flex AS3 looks like this:
[Embed(source='C:/WINDOWS/Fonts/ArialBD.TTF', fontWeight = 'bold', fontName='ArialBold', unicodeRange='U+0020-U+0020,U+0021-...')] //a bunch of other unicode
public static var _VerdanaFontBold:Class;
[Embed(source='C:/WINDOWS/Fonts/Arial.TTF', fontWeight = 'regular', fontName='Arial', unicodeRange='U+0020-U+0020...')] //a bunch of other unicode
public static var _VerdanaFont:Class;
And in constructor of the extended textfield in which my text appears I have:
Font.registerFont(_VerdanaFontBold);
Font.registerFont(_VerdanaFont);
I found this article on embedding metadata with Flash, but I couldn't get that to work either (I tried systemFont="Arial" as well as suggested in the comments at the bottom of that article).
So I tried commenting out the above lines and doing it another way. In CS4, I understand that I'm supposed to create a blank textfield in design mode in the FLA file. I then can select fonts to embed in the properties panel. I selected verdana (upper and lower case, punctuation, number, etc). But again when I run the app in CS4, the textfield is blank.
The fact that I'm embedding the font in a blank textfield, and not the one that's called by the document class I've set, shouldn't matter, right? -- the font should just be embedded in the swf and available for use. But it's blank.
Anyone have any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要在 flash cs4 中嵌入字体,我将执行以下操作。
在flash环境下,在库面板中添加字体符号。确保单击“导出以进行操作”按钮。请注意字体类别的名称。这将是您将在 as3 代码中使用的字体类的名称。最后点击确定,忽略下面的警告信息。
然后您可以从 as3 文件访问该字体类。例如
导入flash.text.Font;
...
var titleField:TextField = new TextField();
var myFont:Font = new nameOfFontClass(); // 参见第 1 点
var format:TextFormat = new TextFormat();
format.font = myFont.fontName;
titleField.defaultTextFormat = 格式;
titleField.embedFonts = true;
希望这有帮助
to embed a font in flash cs4 I would do the following.
in the flash environment, add a font symbol in the library panel. Make sure to click on the "export for actionsctipt button". Note the name of the font class. This will be the name of the font class you will use in your as3 code. Finally click ok and ignore the following warning message.
You can then access this font class from your as3 files. For instance
import flash.text.Font;
...
var titleField:TextField = new TextField();
var myFont:Font = new nameOfFontClass(); // see point 1
var format:TextFormat = new TextFormat();
format.font = myFont.fontName;
titleField.defaultTextFormat = format;
titleField.embedFonts = true;
hope this helps