Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed a font in as3 using FlashDevelop?

How can you embed a font in as3 using FlashDevelop? I have read a lot of posts regarding this issue but none of them helped me solving it. When I use the following code, nothing is displayed (this is all the code) :

package  
{
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFormat;

    public class Main extends Sprite 
    {
        [Embed(source="/../resources/fonts/andbasr.ttf", fontName = "andbasr", fontWeight = "Demibold", mimeType="application/x-font")]
        private var andbasr:Class;

        public function Main() 
        {
            var textField:TextField = new TextField();
            textField.embedFonts = true;
            var format:TextFormat = new TextFormat("andbasr", 16, 0x000000);
            textField.defaultTextFormat = format;
            textField.text = "Test";
            stage.addChild(textField);
        }

    }

}

"andbasr" is just a random ttf file I found. Any idea of what I am doing wrong?

like image 598
user3240131 Avatar asked Oct 22 '25 22:10

user3240131


1 Answers

It works ok, I just downloaded font that you are testing. I think font doesn't have DemiBold weight, also in your case, as you don't use TLF TextField, disable embedding of font in DF4 format by embedAsCFF="false"

[Embed(source="AndBasR.ttf",
        fontName = "myFont",
        mimeType = "application/x-font",
        advancedAntiAliasing="true",
        embedAsCFF="false")]
private var myEmbeddedFont:Class;

//Testing 
var textField: TextField = new TextField();
textField.defaultTextFormat = new TextFormat("myFont", 20);
textField.embedFonts = true;
textField.text = "Test Embedded Font";

addChild(textField);
like image 99
Nicolas Siver Avatar answered Oct 27 '25 06:10

Nicolas Siver



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!