以编程方式在文本字段中嵌入汉字

发布于 2024-07-13 16:21:23 字数 103 浏览 9 评论 0原文

在Flash环境的“嵌入...字符嵌入”窗口中,您可以选择嵌入日语汉字。 有谁知道使用 Actionscript 创建的 TextField 嵌入相同内容的方法吗?

In the "Embed...Character Embedding" window in the Flash environment, you can select to embed Japanese Kanji. Does anyone know of a way to embed the same using a TextField created with Actionscript?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

薔薇婲 2024-07-20 16:21:23

您需要在库中创建一个字体符号并分配一个链接类(在本例中为“Font1”):

var myFont:Font = new Font1();
var myFormat:TextFormat = new TextFormat();
myFormat.font = myFont.fontName;

var myTextField:TextField = new TextField();
myTextField.defaultTextFormat = myFormat;
myTextField.embedFonts = true;
myTextField.text = "Hello World!";
addChild(myTextField);

请参阅有关 嵌入字体

You need to create a font symbol in your library and assign a linkage class (in this case "Font1"):

var myFont:Font = new Font1();
var myFormat:TextFormat = new TextFormat();
myFormat.font = myFont.fontName;

var myTextField:TextField = new TextField();
myTextField.defaultTextFormat = myFormat;
myTextField.embedFonts = true;
myTextField.text = "Hello World!";
addChild(myTextField);

See article on Embedding fonts

小嗷兮 2024-07-20 16:21:23

我通常使用这个会成功:

    package
{


        import flash.display.Sprite;
        import flash.display.TextField;
        import flash.display.TextFieldAutoSize;

        import flash.text.TextFormat;
        import flash.text.AntiAliasType;



        public class EmbedFontTest extends Sprite
        {



                [Embed(source="C:\WINDOWS\Fonts\ARIAL.TTF", fontFamily="Arial")]
                private var _arial_str:String;

                private var _arial_fmt:TextFormat;
                private var _text_txt:TextField;



                public function EmbedFontTest()
                {
                        super();

                        this.initEmbedFontTest();
                }



                private function initEmbedFontTest():Void
                {
                        this._arial_fmt = new TextFormat();
                        this._arial_fmt.font = "Arial";
                        this._arial_fmt.size = 40;

                        this._text_txt = new TextField();
                        this._text_txt.embedFonts = true;
                        this._text_txt.autoSize = TextFieldAutoSize.LEFT;
                        this._text_txt.defaultTextFormat = this._arial_fmt;
                        this._text_txt.text = "Test Arial Format";

                        this.addChild(this._text_txt);
                }
        }



}

I usually use this with succes:

    package
{


        import flash.display.Sprite;
        import flash.display.TextField;
        import flash.display.TextFieldAutoSize;

        import flash.text.TextFormat;
        import flash.text.AntiAliasType;



        public class EmbedFontTest extends Sprite
        {



                [Embed(source="C:\WINDOWS\Fonts\ARIAL.TTF", fontFamily="Arial")]
                private var _arial_str:String;

                private var _arial_fmt:TextFormat;
                private var _text_txt:TextField;



                public function EmbedFontTest()
                {
                        super();

                        this.initEmbedFontTest();
                }



                private function initEmbedFontTest():Void
                {
                        this._arial_fmt = new TextFormat();
                        this._arial_fmt.font = "Arial";
                        this._arial_fmt.size = 40;

                        this._text_txt = new TextField();
                        this._text_txt.embedFonts = true;
                        this._text_txt.autoSize = TextFieldAutoSize.LEFT;
                        this._text_txt.defaultTextFormat = this._arial_fmt;
                        this._text_txt.text = "Test Arial Format";

                        this.addChild(this._text_txt);
                }
        }



}
七度光 2024-07-20 16:21:23

实际上,我最终发现支持汉字(就我而言)的最佳方法是根本不嵌入字体,而只在 TextField 中使用 _sans 选项。

Actually, I ended up finding out that the best way to support Kanji (in my case) was to not embed the font at all and just use the _sans option in the TextField.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文