Skip to main content
Participating Frequently
March 4, 2010
Question

How to use embedded font (CFF) for Flash CS4?

  • March 4, 2010
  • 1 reply
  • 2990 views

Hi,

I am trying to embed "Arial Unicode MS" for use by TLF in my Flash CS4 project. As I googled around, I am using the "Flex SWC" approach, only not having any luck. Here is what I got:

//Code in Flex ActionScript project:

package
{
    public class FontEmbeds
    {
        [Embed(source='C:/Windows/Fonts/ARIALUNI.TTF',
                fontFamily='ArialUnicodeMS',
                embedAsCFF='true'
        )]
        public const Font1:Class;
    }
}

When I am trying to instantiate this class, I have AS code in my Flash main timeline:

var font:Font = new FontEmbeds_Font1();

Flash compiler says: "1067: Implicit coercion of a value of type FontEmbeds_Font1 to an unrelated type flash.text:Font."

Ok. Now after I changed it to:

var font:FontEmbeds_Font1 = new FontEmbeds_Font1();

Flash gives 3 errors:

"VerifyError: Error #1014: Class mx.core::FontAsset could not be found.

ReferenceError: Error #1065: Variable TextLayout is not defined.

ReferenceError: Error #1065: Variable MainTimeline is not defined."

I am assuming I have to create a Font1 object in order to use the embedded font. Is this assumption correct? As I've tried to use the "fontFamily" directly but Flash didn't seem to find the font at all:

charFormat.fontFamily = "ArialUnicodeMS";

Thanks.

This topic has been closed for replies.

1 reply

Participating Frequently
March 4, 2010

You do not need to create an object of class Font1. Just use "ArialUnicodeMS" as you family name in a FontDescription.

gengwangAuthor
Participating Frequently
March 4, 2010

Hi Eric,

Thanks for the info.

I've tried to use the "fontFamily" directly but Flash didn't seem to  find the font at all:

charFormat.fontFamily = "ArialUnicodeMS";

In one fla where I used pure TFL, nothing gets rendered at all in the container Sprite. Flash doesn't throw any errors either. In another fla where I used a ComboBox, etc. along with TFL, it throws an error says it can't compile since "there is no ActionScript found" and I got a screen where all the Flash components were  flickering. After several attempts, Flash crashed.

Also as a side note, the swc gets generated by Flash Builder Beta 2, at first it was 18mb and the second time I complied it become 9mb and stayed 9mb afterwards. Not sure if that's a concern.

Geng

gengwangAuthor
Participating Frequently
March 5, 2010

Hi,

Just want to report back. I tried 3 different approaches and the one that I read from TLF team's blog about "World Class Text Tour" works for me.

1. ActionScript project from Gumbo 4.0/? and loads .swf with cff embedded (Works)

2. Flex Library project from Gumbo 4.0.? embeds swc into Flash (never worked)

3. Flex project from Gumbo 4.0.?and loads .swf into Flash (never worked. cannot' figure out out to access the "font" class from Flash:(_

Not sure this is useful for anyone with the similar situation.

Thanks and have a great weekend.

Geng