View unanswered posts | View active topics



Reply to topic  [ 5 posts ] 
[Solved] Embedding fonts 
Author Message
Member

Joined: Wed Feb 03, 2010 1:55 pm
Posts: 8
First off, that image ierification CAPTCHA during registration is deadly! Only took me about 10 attempts to get in :)

Anyway, on to my problem. I'm trying to embed a font in an AS3 project in FD 3.0.6 RTM using (non-OS) Flex SDK 3.5.0.12683. Basically in the directory structure FD gave to me I added a 'res' directory and have the .ttf file in there, but I don't know if my font is special in any way.

My embed code is simply this:

Code:
[Embed(source='../res/VAGRounded LT Thin.ttf', fontName='VAGRounded LT Thin', advancedAntiAliasing="true", mimeType="application/x-font", unicodeRange='U+0020-U+007E')]
private var font_vag:Class;


The exact same thing happens if the fontName contains no spaces or the mimeType is "application/x-font-truetype" or the unicodeRange is not specified (except a larger swf in that case) so I don't think it's something I've done wrong here. If I tell the Embed line that it's bold is complains saying there's no bold version or something so it seems there's no funky styling in the font (after all it is an "LT Thin" version of a font). My code to stick it in a textField is something a bit like this (not my actual code but basically the same thing, all the other stuff removed):

Code:
[Embed(source='../res/VAGRounded LT Thin.ttf', fontName='VAGRounded LT Thin', advancedAntiAliasing="true", mimeType="application/x-font", unicodeRange='U+0020-U+007E')]
private var font_vag:Class;

private static const THE_TEXT:String = 'Select full screen for\nmaximum viewing';
private static const textFormat:TextFormat = new TextFormat("VAGRounded LT Thin", 12, 0xffffff);
private var theText:TextField;

public function Main():void {
   theText = new TextField();
   theText.autoSize = TextFieldAutoSize.LEFT;
   theText.text = THE_TEXT;
   theText.setTextFormat(textFormat);
   addChild(theText);
}


And it comes out in the default Times New Roman font. The text format is working as it is coloured white and the right size. Also if I change the textFormat const line to something like
Code:
private static const textFormat:TextFormat = new TextFormat("Arial", 12, 0xffffff);
it works fine - it's Arial. It just doesn't seem to link the fontName property of the textFormat ("VAGRounded LT Thin") to the fontName I gave the Embedded font. Am I doing something wrong?

Interestingly I don't have the font in question installed on my machine, which I guess is good as I probably wouldn't have noticed the problem.


Also, while I'm here can I ask what right clicking a resource and clicking "add to library" does differently to this textual embedding style? From what I've read it may only be appropriate for AS2 projects, and makes the resource available under library.[var_name] but I haven't tested these bits of information. What's the deal here?


Last edited by alexrussell on Tue Feb 09, 2010 1:20 pm, edited 1 time in total.



Wed Feb 03, 2010 2:09 pm
Profile
Member

Joined: Wed Feb 03, 2010 1:55 pm
Posts: 8
Any ideas anyone? It doesn't seem to fall under the previous font embedding problems that I can see. I've even tried a less wordily-named font (just in case it was because of the "LT Thin" styling) and it too didn't work.

Am I doing the embedding properly? As I said, I can make the compiler complain by saying it's bold when it's not, and the compiler doesn't complain when I'm embedding how I think I'm supposed to (and the filesize of the swf goes up) so presumably it's embedding correctly, and just not using it.


Tue Feb 09, 2010 12:09 pm
Profile
Member

Joined: Tue Jun 02, 2009 5:08 pm
Posts: 220
Location: Lyon - France
try using
theText.embedFonts = true;


:)

_________________
Martín Fernández Lombana - Creative Website Designer & Developer
http://www.interactivemartin.com - contact [_AT_] interactivemartin.com


Tue Feb 09, 2010 1:12 pm
Profile WWW
Member

Joined: Wed Feb 03, 2010 1:55 pm
Posts: 8
Argh!

Yes, I'm a fool. Thank you!


Tue Feb 09, 2010 1:20 pm
Profile
Member

Joined: Tue Jun 02, 2009 5:08 pm
Posts: 220
Location: Lyon - France
You are welcome,

The worse bugs sometimes, are the very obvious and simple ones. Plus, you don't have compile or runtime errors so you have no reference at all...

Ciao!

_________________
Martín Fernández Lombana - Creative Website Designer & Developer
http://www.interactivemartin.com - contact [_AT_] interactivemartin.com


Tue Feb 09, 2010 1:48 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.