3
votes

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?

3

3 Answers

3
votes

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;
5
votes

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;
0
votes

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.