Skip to main content
June 21, 2011
Question

How to embed Font in as3?

  • June 21, 2011
  • 2 replies
  • 856 views

Hi guys,

I want to embed font "RUPEE_FORADIAN" in as3?

how can i do that?

can you please tell me?

Thanks in Advance!!!!!

Regards,

JaxNa

This topic has been closed for replies.

2 replies

Kenneth Kawamoto
Community Expert
Community Expert
June 21, 2011

You can embed with Embed metadata:

[Embed(source='path/to/RUPEE_FORADIAN.ttf', fontName='RupeeForadian', mimeType='application/x-font')]
private var RupeeForadian:Class;

Then you can use "RupeeForadian" as the font name hereafter.

relaxatraja
Inspiring
June 21, 2011

This is for a text that you had on the stage

i) I hope you have the font RUPEE_FORADIAN installed in your system, if yes, then drop a textfiled on stage and check whether you get the list in the font box and use embed button.

This is the code in AS3 for a text that you have created dynamically:

var myFont = new Font1();

var myFormat:TextFormat = new TextFormat();

myFormat.size = 15;

myFormat.align = TextFormatAlign.CENTER;

myFormat.font = myFont.fontName;

myFormat.color = 0xAA0000;

var myText:TextField = new TextField();

myText.defaultTextFormat = myFormat;

myText.type=TextFieldType.INPUT;

myText.selectable = false; 

myText.embedFonts = true;

myText.antiAliasType = AntiAliasType.ADVANCED;

myText.text = "The quick brown fox jumps over the lazy dog";

//myText .setTextFormat(myFormat);

myText.border = true;

myText.wordWrap = true;

myText.width = 150;

myText.height = 40;

myText.x = 100;

myText.y = 100;

myText.autosize=TextFieldAutoSize.LEFT ;

stage.focus= myText;

addChild(myText);

Make sure you have the font with the class name "Font1" in the library. or create the one from the library menu.

June 21, 2011

hi,

Thanks for replay,

I have not installed RUPEE_FORADIAN this font in my system.

Regards,

JaxNa

relaxatraja
Inspiring
June 21, 2011

Install it and do the process in the above thread.