加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flash – AS3 TextField设置文本的上边距,因为有些字符被删除了

发布时间:2020-12-15 07:27:56 所属栏目:百科 来源:网络整理
导读:我想弄清楚为什么有些字母(比如挪威语?(?))在顶部“o”的中间切出: 我的代码是这样的: var titleFormat:TextFormat = new TextFormat(); titleFormat.size = textSize; // this is embedded font,and exported for action script,declared titleFormat.fon
我想弄清楚为什么有些字母(比如挪威语?(?))在顶部“o”的中间切出:

我的代码是这样的:

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;

所以,我尝试了不同的东西,如设置高度硬编码和大于文本,但顶部我们再次削减,我尝试用CSS但没有成功.任何人都知道为什么这封信没有完全显示,为什么我放大swf(2-3放大)它显示正常(以及我试图实现的)像这样:

我认为它与topMargin有关,但不幸的是我在as3文档中没有找到类似的东西.

解决方法

不确定这是否有帮助,但我使用Verdana字体测试了以下完整的自包含代码,没有嵌入,它工作正常.也许您嵌入的字体本身存在问题,或者嵌入是由于某种原因导致问题?

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;    

        }
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读