简体   繁体   English

AS3 Flash CS5-将嵌入式字体与fontDescription.fontName一起使用

[英]AS3 Flash CS5 - Using embedded fonts with fontDescription.fontName

I have a function that has an optional variable myFont . 我有一个具有可选变量myFont的函数 By default, it's set to myFont:String="Impact" . 默认情况下,它设置为myFont:String =“ Impact” However, when I try to define a different font name by using the function, or even just changing the default font name, I get 但是,当我尝试通过使用函数定义其他字体名称,甚至只是更改默认字体名称时,都会得到

TypeError: Error #1009: Cannot access a property or method of a null object reference. TypeError:错误#1009:无法访问空对象引用的属性或方法。

Arial isn't embedded anywhere in my project, so I don't really understand why the compiler is being so fussy about others... :< Arial没有嵌入我的项目中的任何地方,所以我真的不明白为什么编译器对其他人如此挑剔...:<

Here is the FontDescription -> ElementFormat part of the code: 这是代码的FontDescription-> ElementFormat部分:

        fontDescription = new FontDescription();

        fontDescription.fontName=myFont;
        fontDescription.fontWeight=FontWeight.BOLD;
        fontDescription.fontPosture=FontPosture.ITALIC;
        fontDescription.renderingMode=RenderingMode.CFF;

        format = new ElementFormat(fontDescription);

Any clues? 有什么线索吗? I've tried [Embed]ing the font in the document class, embedding it via the Flash IDE... 我尝试将字体嵌入文档类中,并通过Flash IDE嵌入...

In my experience, Flash`s font embedding has always been a little tricky. 以我的经验,Flash的字体嵌入一直有些棘手。 The way I embed my fonts are as follows: 我嵌入字体的方式如下:

  • Create a dynamic text field on the documents stage outside of the visible area (usually up on the top-left side) for each font and setting (bold, italic, both, etc); 在可见区域之外(通常在左上方)的文档台上,为每种字体和设置(粗体,斜体,两者均等)创建一个动态文本字段;
  • Click the embed button on each of these created text fields and make sure I select the characters I'm going to use; 单击每个创建的文本字段上的嵌入按钮,并确保我选择了将要使用的字符。

That way, since there's a dynamic text field using that font right on the stage, Flash is forced to embed correctly the fonts. 这样,由于舞台上就存在一个使用该字体的动态文本字段,因此Flash被迫正确嵌入字体。

And, the reason why some fonts don't trigger an error, is that they're available for use by default. 而且,某些字体不会触发错误的原因是默认情况下可以使用它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM