Solved

How to embed fonts in an AS3 project with CSS

Posted on 2010-11-17
13
791 Views
Last Modified: 2012-05-10
Hey,

I'm trying to embed a font in my AS3 project but the text keeps disappearing if I set embed-fonts to true. I'm using FlashDevelop and Flex SDK 3 to compile the application.

This is how I am defining the font in the external CSS file:

@font-face
{
    src: url( "../../resource/font/frutiger.ttf" ) ;
    fontFamily: defaultFontFamily ;
    advancedAntiAliasing: true ;
}

p
{
      font-family: defaultFontFamily ;
      font-size: 12 ;
      color: #ffffff ;
}

The styling works, but fonts won't show up. What am I missing here?
0
Comment
Question by:eCat12
13 Comments
 
LVL 5

Expert Comment

by:GarrettChristopherson
ID: 34157891
Here is a tutorial on embedding fonts in Flex:

http://livedocs.adobe.com/flex/3/html/help.html?content=fonts_04.html

In the tutorial, I saw that there are some additional commands, although I haven't worked this out myself.  Hopefully the tutorial will fill in the blanks for you!
0
 

Author Comment

by:eCat12
ID: 34157907
Thanks! This seems to be exactly how I am doing it though, and it still doesn't work. Do I need to embed  the font in both CSS and AS or is CSS enough?
0
 
LVL 17

Expert Comment

by:deepanjandas
ID: 34161173
Did you register the fonts in AS while using CS3.

Warm Regards
Deepanjan Das
http://deepanjandas.wordpress.com
0
 

Author Comment

by:eCat12
ID: 34162638
Hi,

Yes, I tried embedding the font in AS as well using the [Embed] metatag. Didn't make any difference.
0
 
LVL 17

Expert Comment

by:deepanjandas
ID: 34162673
I mean Registering the fonts.

Here are the steps:
1. Add the font in library.
2. Register the fonts using this script:
var FontClass:Class = getDefinitionByName( "FontName" ) as Class;
Font.registerFont( FontClass );

And you are done.

Warm Regards
Deepanjan Das
http://deepanjandas.wordpress.com
0
 

Author Comment

by:eCat12
ID: 34162685
Thanks, but I can't use the library as this is a pure AS3 project and not a Flash one... can you think of another way of doing this?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 17

Expert Comment

by:deepanjandas
ID: 34162693
So you can just use an SWF which contains the fonts only, load it as a library and register the font in your code using AS3.0


Warm Regards
Deepanjan Das
http://deepanjandas.wordpress.com
0
 

Author Comment

by:eCat12
ID: 34163082
Ok, thanks, I tried that. I now have the font in a SWC library with the linkage name Frutiger. However, I still can't get it to work. I'm trying this:

var FontClass:Class = getDefinitionByName( "Frutiger" ) as Class;
Font.registerFont( FontClass );

and I get this error:

[Fault] exception, information=ReferenceError: Error #1065: Variable Frutiger is not defined.


0
 
LVL 17

Expert Comment

by:deepanjandas
ID: 34163458
It seems you have not entered its linkage name.

In the font fla, select the font from library and open its linkage.

Then click Export for ActionScript.

Warm Regards
Deepanjan Das
http://deepanjandas.wordpress.com
0
 

Author Comment

by:eCat12
ID: 34163839
I've already done that. I'm out of ideas here. :/
0
 
LVL 1

Accepted Solution

by:
PankajRai earned 500 total points
ID: 34172144
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 34824197
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now