Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 04-30-2012, 04:17 PM   #1
netrate
Registered User
 
Join Date: Mar 2012
Posts: 39
Default Fonts and embedding help

Can anyone explain embedding fonts please ? Here is a file that works while I am writing it, but when I save it, it doesn't work anymore.

I have tried to Embed fonts, but when I click on UpperCase, LowerCase etc, nothing happens - I have even tried to click ALL. Upper, Lower are already in the list, so maybe they are already embedded - but this doesn't seem to work. I am guessing that the problem is that, but I could be wrong.
Again, this works perfect while I write it and test it - the text displays in black. I save it, close the file and open it again, the text does not show up.
Thanks in advance.
Attached Files
File Type: zip test font.zip (5.8 KB, 30 views)
netrate is offline   Reply With Quote
Old 04-30-2012, 06:59 PM   #2
jsprclimber123
Breaking things...
 
Join Date: Jan 2010
Posts: 635
Default

You can take a look at some of the examples and files I posted in this article:

http://www.actionscript.org/forums/s....php3?t=272504
jsprclimber123 is offline   Reply With Quote
Old 04-30-2012, 08:42 PM   #3
netrate
Registered User
 
Join Date: Mar 2012
Posts: 39
Default

Thank you for the tip, I didn't realize it takes all that code just to get the font to show up.
Is my problem the font embedding then? Did you test my file?
netrate is offline   Reply With Quote
Old 04-30-2012, 09:41 PM   #4
netrate
Registered User
 
Join Date: Mar 2012
Posts: 39
Default

Lord knows I am trying, but this is making me see spots.
My text is reverting to some other color or disappearing when I try to place it on stage. As I have said, I am working from two different computers, one here and at school.
I run the program like this below and it works until I save it. Once i save it and reopen it, it stops displaying the text. BUT when I start writing the code with a static text box with a black font before I start programming, it seems to display fine. I am just going nuts here?
And yes, I must be - because I shut down flash and restarted and all of a sudden, my location_txt is no longer there. This is very frustrating.
I have included pics to help out.

ActionScript Code:
var myFormat:TextFormat= new TextFormat(); var myFormat2:TextFormat= new TextFormat(); myFormat.color=0x000000; myFormat.size=15; myFormat2.color=0X0088ee; myFormat2.size=20;             addChild(body_txt);     body_txt.text="What ?";     body_txt.setTextFormat(myFormat2);         addChild(location_txt);     location_txt.text="You are here";     location_txt.setTextFormat(myFormat);
Attached Thumbnails
Click image for larger version

Name:	pic1 before save and closing - works.png
Views:	28
Size:	35.2 KB
ID:	38436   Click image for larger version

Name:	pic2 after opening.png
Views:	33
Size:	31.3 KB
ID:	38437  

Last edited by netrate; 04-30-2012 at 10:56 PM.
netrate is offline   Reply With Quote
Old 05-01-2012, 05:01 AM   #5
Mazoonist
Site Contributor
 
Mazoonist's Avatar
 
Join Date: Jun 2006
Posts: 3,160
Send a message via AIM to Mazoonist
Default

If you place a textbox on the screen in the authoring tool (Flash), you don't also have to use addChild() on it with code. So the line:

addChild(location_txt);

...is redundant and doesn't do anything at all. You have already added it to the display manually in Flash. Two different ways of doing the same thing.

Similarly, if you format your text in the properties panel, there is no need to also do it with code using a TextFormat object. They are just two different ways of doing the same thing, one in the properties panel, and the other dynamically when your program runs. Sometimes there *might* be a reason to do both, but probably not in your case right now.

You are not the first person to take on font embedding to try and discover how it works. Keep going and you will definitely figure it out. One thing to realize is that the font ultimately comes from your computer system. Another is to realize what are the roles of your fla file and your swf file here. You tell your fla file to embed the font. This is like saying "when you make me a swf file from this (CTRL-ENTER to test movie always makes a new swf), I want you to go to my system, get such-and-such a font, and embed it in my swf file." In other words, the font is never embedded in the fla file, the fla file effectively just contains the command to "go and get it." The font is embedded in the swf file, not the fla file.

This means that if I author a fla file, asking it to embed a certain font, then I send you that file, and you compile it (CTRL-ENTER), the font will only be embedded for you if the exact same font is present on your system.

However, if I send you the swf file, which is already compiled, and you run it, you will see the font displayed even if it is not present on your system.
__________________
My Tutorials * My Website
Mazoonist is offline   Reply With Quote
Old 05-01-2012, 05:34 PM   #6
netrate
Registered User
 
Join Date: Mar 2012
Posts: 39
Default

Thank you for the reply.
I guess I am trying and trying, but still really confused and frustrated.
I am using only the Arial font - something that is technically on every system, yet, I am getting the same happening - works when i write it, save it and then doesn't display any text when I close flash and open it again.
I have broken the code down to its simplest form (without the addChild - thanks for the tip), and yet I am getting the same issue. I guess the real problem is that I must be missing some fundamental. For me, it is like saying "trace(0)" and seeing it work, only to find it not working the next time I start the program.

ActionScript Code:
var myFormat:TextFormat= new TextFormat(); var myFormat2:TextFormat= new TextFormat(); myFormat.color=0x000000; myFormat.size=15; myFormat2.color=0X0088ee; myFormat2.size=20;     body_txt.text="What ?";     body_txt.setTextFormat(myFormat2);         location_txt.text="You are here";     location_txt.setTextFormat(myFormat);
netrate is offline   Reply With Quote
Old 05-01-2012, 05:43 PM   #7
prasad19sara
Registered User
 
Join Date: Nov 2009
Location: Sri Lanka
Posts: 45
Default

1.Select the text field.
2.Go to properties > Character > Anti-alias
3.Select "Use device font" option
prasad19sara is offline   Reply With Quote
Old 05-01-2012, 05:51 PM   #8
netrate
Registered User
 
Join Date: Mar 2012
Posts: 39
Default

Thanks for the tip, but I just tried that "Device Font Option", as you suggested and it did NOT work. Very frustrating...
Again, the file and script. I keep telling myself, I am not stupid, I am not stupid...

ActionScript Code:
var myFormat:TextFormat= new TextFormat(); myFormat.color=0x000000; myFormat.size=15; location_txt.text="Here you are"; location_txt.setTextFormat(myFormat);
Attached Files
File Type: zip test font simple.zip (7.2 KB, 27 views)
netrate is offline   Reply With Quote
Old 05-01-2012, 06:26 PM   #9
dmb85
Senior Member
 
Join Date: Jan 2012
Posts: 608
Default

To use an embedded font, you need to do this:

1. In the font embedding options, go to the font you want to embed, go to the Actionscript tab, set Outline format to Classic(DF3) if using Classic textfield, or TLF(DF4) if using TLF. Check the "export for actionscript" checkbox and give the font a class name (we'll use class name MyFont)

2. Then to apply this font to a textfield, use the code below:

ActionScript Code:
var font:MyFont = new MyFont(); var myFormat = new TextFormat( font.fontName, 16, 0x666666 ); //If using the bold version of a font, TextFormat.bold must be set to true location_txt.text="Here you are"; location_txt.setTextFormat(myFormat); location_txt.embedFonts = true;
dmb85 is offline   Reply With Quote
Old 05-02-2012, 02:11 AM   #10
Mazoonist
Site Contributor
 
Mazoonist's Avatar
 
Join Date: Jun 2006
Posts: 3,160
Send a message via AIM to Mazoonist
Default

I repeat "if you format your text in the properties panel, there is no need to also do it with code using a TextFormat object."

What part of that did you not get?

Click the embed button in the properties panel and check off uppercase, lowercase, numerals and punctuation. Done. All this stuff you are doing with code is unnecessary. The only code you need in your case is the code that sets the text property:

location_txt.text = "You are here";

Edit: "Use device font" is bad advice. This makes the swf look for the font on the end user's machine, and it will replace it with something different if it is not found.
__________________
My Tutorials * My Website

Last edited by Mazoonist; 05-02-2012 at 02:14 AM.
Mazoonist is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:27 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.