import flash.text.*;
var font:Font1=new Font1();
var txt_fmt:TextFormat=new TextFormat();
txt_fmt.font=font.fontName;
txt_fmt.size=24
var txt:TextField=new TextField();
txt.autoSize=TextFieldAutoSize.LEFT;
txt.defaultTextFormat=txt_fmt;
txt.embedFonts=true
txt.text="sara"
txt.selectable=false
addChild(txt);
Code Explanation:
Importing all the necessary classes..
import flash.text.*;
Creating new instance of the font from library..
var font:Font1=new Font1();
Here Font1 is the Linkage name given in the library
Creating TextFormat
var txt_fmt:TextFormat=new TextFormat();
txt_fmt.font=font.fontName;
txt_fmt.size=24
Note:
font is the instance name of Linkage name
Creating text field and applying the TextFormat created above
var txt:TextField=new TextField();
txt.autoSize=TextFieldAutoSize.LEFT;
txt.defaultTextFormat=txt_fmt;
txt.embedFonts=true
txt.text="sara"
txt.selectable=false
Adding the TextField to the DisplayList
addChild(txt);
13 comments:
this helped me alot, thanks!
It was very useful. Thank you.
what if i want to use
txt.htmlText="sara"
???
HI,
you can use htnl tags there to decorate your text
thanks for posting this -- just found it on a search for embedding fonts and it was just what i needed!
-miranda
Thanks dude.
Indeed very useful. Thanks
it's not working
thanks, it save my time!
Thanks! :)
this is the wrong way man - you shouldn't embed the ENTIRE font family.
Hi,
I did the same thing using Arial font and was able to embed the font for English language only. I was not able to see the Russian characters. I tried with "Arial Unicode MS" font also, but no luck...
Some one please help me?
I tested the font with this text "Джоан Брукс прибывает в Лондон".
Great! Very simple and usefull. Thank you very much.
Post a Comment