Jan
Jan

Reputation: 165

Embed custom font in Actionscript 3 project

I want to display "Hello World" with calibri.ttf using only AC3. How would I do that?

Found two solutions on the web but I cannot use any of them - The Adobe documentation site requires the use of Flash CS4. (Don't know how to use this in Flex Builder) - The embed tag method requires FLEX SDK

Is it possible to embed font with purely Actionscript 3 in an actionscript project using Flex Builder?

Upvotes: 3

Views: 3059

Answers (3)

back2dos
back2dos

Reputation: 15623

Flex Builder includes the Flex SDK, and uses the SDK for compilation. In a pure AS3 project you'd thus use the embed tag to embed fonts.

Upvotes: 0

arboc7
arboc7

Reputation: 5880

I was having a similar problem in a pure AS3 mobile project where I used Daniel's code (below from another answer), but it wasn't working for me.

Daniel's code

[Embed(source='/assets/calibri.ttf', fontName="Font", mimeType="application/x-font-truetype")]
private static var calibri:String;

The trick I found here was to add embedAsCFF="false" Since I was adding a True-Type Font (TTF) and not a Compact Font File (CFF), this small change worked for me.

Updated code

[Embed(source='/assets/calibri.ttf', fontName="Font", mimeType="application/x-font-truetype" embedAsCFF="false")]
private static var calibri:String;

Upvotes: 5

Daniel
Daniel

Reputation: 35734

Right-click on the library in your Flash Project, and you have the option to add the Font there. You can even just create an empty dynamic text field, and have it embed all the characters you need.

In the settings, you have the option to give you the compilation details, so when you compile the project you can see what was included, and in both cases you should see the font be included.

--edit-- right, sorry I understood that you're using Flash, my bad

you can use something like this

[Embed(source='/assets/calibri.ttf', fontName="Font", mimeType="application/x-font-truetype")]
private static var calibri:String;

Upvotes: 3

Related Questions