Solved

How to embed fonts in an AS3 project with CSS

Posted on 2010-11-17
13
798 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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
 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to convert pdf file to html file 8 393
Flash content not working in IE 11 on Windows 8.1 3 165
Adobe flash player memory exhaustion 6 96
Java and adobe flash updates 4 45
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…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
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.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

815 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

7 Experts available now in Live!

Get 1:1 Help Now