Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to embed fonts in an AS3 project with CSS

Posted on 2010-11-17
13
Medium Priority
?
811 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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,…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
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.

610 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