Hello,

I'm trying to create a TextField that uses an embedded font. Please
see my code below.

The font displays properly when I use it in MXML, but not when I try
to create the text display object in AS.

Has anyone had success with something similar to this?


CSS:

@font-face{
        src:url("HelveticaNeueLTStd-Cn.otf");
        fontFamily: HelveticaNeue;
        advancedAntiAliasing: true;
}


AS:

private function createSheet(sheet:Sprite, str:String):void {
            sheet.graphics.beginFill(0xEEEEEE);
            sheet.graphics.lineStyle(1, 0x000000);
            sheet.graphics.drawRect(0, 0, 100, 200);
            sheet.graphics.endFill();
           
            var txtFmt:TextFormat = new TextFormat()
            txtFmt.color = 0x000000;
            txtFmt.size = 17;
            txtFmt.font = "HelveticaNeue";
            
            var txt:TextField = new TextField();
            txt.embedFonts = true;
            txt.height = 200;
            txt.width = 100;
            txt.wordWrap = true;
            txt.defaultTextFormat = txtFmt;
            txt.text = str;
            
            sheet.addChild(txt);
        }

Reply via email to