Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AS3 TextField setting top margin of text because some chars are cutted out

I am trying to figure out why some letters (like the norwegian Å (Å)) are cutted out in the middle of the top "o":

My code is this:

        var titleFormat:TextFormat = new TextFormat();
        titleFormat.size = textSize;
           // this is embedded font, and exported for action script, declared
        titleFormat.font = myFontBold.fontName;
        titleFormat.bold = true;
        titleFormat.color = parseInt("0x"+fontColor,16);

        var titleText:TextField = new TextField();
        titleText.defaultTextFormat = titleFormat;
        titleText.embedFonts = true;            
        titleText.antiAliasType = AntiAliasType.ADVANCED;
        titleText.text = "Å"+text;
        addChild(titleText);

        titleText.selectable = false;           
        titleText.wordWrap = true;          
        titleText.width = maskImg.width - 80;           
          // this should autosize to fit all text, but it doesn't the top of text
        titleText.autoSize = TextFieldAutoSize.LEFT;
        titleText.x = x;
        titleText.y = y;

So, i have tried different things like setting height hardcoded and bigger than text, but top us cutted again, i have tried with css but no success. Anyone has idea why the letter is not showed fully and why if i zoom in the swf (2-3 zoom ins) it shows up normal (and what i try to achieve) like this:

I think it has to do with the topMargin, but unfortunately i didn't find something like that in as3 documentation.

like image 294
Daniel Avatar asked Nov 13 '22 15:11

Daniel


1 Answers

Not sure if this helps, but I tested the following complete, self contained code with the Verdana font, not embedded and it works fine. Perhaps the font you are embedding has a problem itself, or the embedding is causing a problem for some reason?

package  {

    import flash.display.MovieClip;
    import flash.text.*;

    public class TestText extends MovieClip {

        public function TestText() {

            var textSize = 20;

            var titleFormat:TextFormat = new TextFormat();
            titleFormat.size = textSize;
            titleFormat.font = "Verdana";
            titleFormat.color = 0xFF0000;

            var titleText:TextField = new TextField();
            titleText.defaultTextFormat = titleFormat;          
            titleText.text = "Åbcdefg";
            titleText.backgroundColor = 0x000000;
            titleText.background = true;
            addChild(titleText);

            titleText.autoSize = TextFieldAutoSize.LEFT;
            titleText.selectable = false;           
            titleText.wordWrap = true;          
            titleText.width = 200;    

        }
    }
}
like image 126
miahelf Avatar answered Dec 09 '22 17:12

miahelf