?
Solved

How to embed fonts in an AS3 project with CSS

Posted on 2010-11-17
13
Medium Priority
?
810 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses
Course of the Month14 days, 3 hours left to enroll

800 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