567 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+4 more
iamdok says

I’m checking around the web for some more info about this method of embedding fonts into an swf for use in any new dynamically created textfields, in AS3 !. (Not using the library font or flex embed way!)

As I understood it, you place a textfield off-stage. Embed the font and style you require into it in the usual way. Then when you dynamically create new textfields, in the Doc Class for example, you set the textformat font name to the name of the font embedded into the off-stage textfield, and that’s it!

Well this doesn’t seem to work. Anyone have an example? Also, where do you get the exact name of the font? Is it ok to simply use the on you can see in the font properties panel?

It’s difficult to find any information about this method. Most online resources refer to the method of placing a font into the library, but this is not suitable for ActiveDen (as you need to have a licence to do that). The other methods commonly referred to is the Flex SDK method of using an “Embed” statement in the Class body, but this is not available outside of Flex, and so is unsuitable for Flash projects for AD.

I’m using Flash Develop for the classes and getting artwork etc. from the Flash IDE Library. I’m aware that I can instantiate a textfield from the library which sits inside an mc prepared with all the embedded font goodies, but I would like to do it cleanly with code instead.

Anyone any ideas?

4140 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $5,000+ on Envato Market
  • Located in Brazil
+3 more
tsafi says

CS3 ? CS4 ?

Load your font via external swf …….

567 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+4 more
iamdok says

Hey tsafi,

CS3 & CS4 & CS5

I would like to avoid loading the font externally, as that’s a little too complicated for small projects where I only need 2 fonts and maybe two styles for each.

I’m just looking for a simple method for use on AD projects, where I don’t need to embed the actual font (like in the library or in an external swf), but just into a textfield.

4140 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $5,000+ on Envato Market
  • Located in Brazil
+3 more
tsafi says

Not at all it’s very easy to load external font via 1 class with 70 line of code that’s it.

You can look at bitfade` post here on his external load font or look there at my sample i add a class there really its super easy and base on my last file(mini projects you want :P) look like buyer love the way i allow them to embed the font via external swf.

The external swf font load will give to option to embed your font in pure AS or via text filed, the nice thing about the text filed you can draw dynamic text filed on your parent swf but still the embedding will be externally so your main Swf stay law on the kb ,still it’s a matter of preference and that’s the way i feel comfortable .

But embedding the actual text field is the best way to go on language mix and all font syntax i didn’t find yet a better way that can defeat that in flash.

In CS4 /CS5 you have a great way to embed font but that’s only if you use there text engine something that very few developers here use any way

5390 posts The Dude Abides
  • Located in United States
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Has been part of the Envato Community for over 5 years
+9 more
CodingJack says
var ar:Array = Font.enumerateFonts();

for(var i:int = 0; i < ar.length; i++) {

    trace(ar[i].fontName);

}

var myStyle:Object = {fontFamily: ar[0].fontName, fontSize: "48px"};

var sheet:StyleSheet = new StyleSheet();
sheet.setStyle("p", myStyle);

var txt:TextField = new TextField();
txt.autoSize = TextFieldAutoSize.LEFT;
txt.antiAliasType = AntiAliasType.ADVANCED;
txt.embedFonts = true;
txt.styleSheet = sheet;
txt.htmlText = "<p>Old Sans Black</p>";

addChild(txt);

Doesn’t seem to work with TextFormat, only StyleSheet

4140 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $5,000+ on Envato Market
  • Located in Brazil
+3 more
tsafi says
Doesn’t seem to work with TextFormat, only StyleSheet

Maybe you should add TextFormat you still need to do it you know, that will help :P

http://activeden.net/forums/thread/a-common-solution-for-external-fonts/27269?page=3

567 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+4 more
iamdok says

CJ,

In order to use the enumerateFont method you need to have the font placed in the library right? Siimply embedded into an tf on the stage won’t make it show up in the resulting list , right?

tsafi,

In your external font loading class, to make the external swf which contains the fonts, you need to place the fonts into the library or what way do it need to be done?

5390 posts The Dude Abides
  • Located in United States
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Has been part of the Envato Community for over 5 years
+9 more
CodingJack says
CJ,

In order to use the enumerateFont method you need to have the font placed in the library right? Siimply embedded into an tf on the stage won’t make it show up in the resulting list , right?

No once a font is embedded whether it’s exported for Actionscript in the library or just a text field on the stage it will show up in the list :)

4140 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $5,000+ on Envato Market
  • Located in Brazil
+3 more
tsafi says

tsafi,

In your external font loading class, to make the external swf which contains the fonts, you need to place the fonts into the library or what way do it need to be done?

Yes place the font in the library Right click on the font export for AS and enter MyFont click ok

567 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+4 more
iamdok says

Thanks guys. I think I was dreaming before about there being a simple version ;)

I’m also looking at bitfade’s github runtime loading solution. Very well documented and explained with examples. Really nice piece of work.

http://github.com/bitfade/Flash-runtime-font-loading

I can’t even make sense of the guy’s loading class ! :confused: All I know is, it works!

Donagh

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by