[ActionScript 3.0] using embed to embed fonts in a class

Source: Internet
Author: User

1  Package2 {3     ImportFlash.display.Sprite;4     ImportFlash.text.Font;5     ImportFlash.text.TextField;6     ImportFlash.text.TextFormat;7     8     /**9 * @author Frost.yenTen * @e-mail [email protected] One * @create 2015-6-26 pm 3:23:38 A      * -      */ -[SWF (width=" the", height=" the")] the      Public classEmbedfontsextendsSprite -     { -         /** - * source Specifies the path to the font file to embed. You can also use Systemfont to specify the fonts that are installed on a system. In this case, the source parameter is not required.  + FontName This is actually the alias of FontFamily.  - EMBEDASCFF If this parameter is not provided, the default is true. So, if your embedded font is used for TextField, be sure to set it to false.  + Unicoderange The range of text to embed. See table below: A              at Embed font range: - • Uppercase characters u+0020,u+0041-u+005a - • Lowercase characters u+0020,u+0061-u+007a - • Digital u+0030-u+0039,u+002e - • Punctuation u+0020-u+002f,u+003a-u+0040,u+005b-u+0060,u+007b-u+007e - • Basic Latin characters u+0020-u+002f, u+0030-u+0039, u+003a-u+0040, u+0041-u+005a, u+005b-u+0060, u+0061-u+007a, U+007B-U +007e in • Chinese characters u+3000-303f,u+3105-312c,u+31a0-31bf,u+4e00-9faf,u+ff01-ff60,u+f900-faff,u+201c-201d,u+2018-2019,u+20 14,u+2026,u+ffe5,u+00b7 -              to you can find the flexsdk/frameworks/flash-unicode-table.xml of this machine in detail. You can also refer to setting character ranges.  +          */         -[Embed (source="Fonts/msyh.ttf", fontname="Yahei_font", embedascff="false", mimetype="Application/x-font", unicoderange="u+0020-u+002f, u+0030-u+0039, u+003a-u+0040, u+0041-u+005a, u+005b-u+0060, u+0061-u+007a, U+007B-U+007E,U+0020- u+002f,u+003a-u+0040,u+005b-u+0060,u+007b-u+007e,u+0030-u+0039,u+002e,u+0020,u+0061-u+007a,u+0020,u+0041-u+ 005a,u+3000-303f,u+3105-312c,u+31a0-31bf,u+4e00-9faf,u+ff01-ff60,u+f900-faff,u+201c-201d,u+2018-2019,u+2014,u+ 2026,u+ffe5,u+00b7 ")]  the         Private var_font:class; *          Public functionembedfonts () $         {Panax Notoginseng             varFontarr:array= font.enumeratefonts (false); -              foreachvarFont:fontinchFontarr) the Trace (Font.fontname, font.fonttype); +             //Font.registerfont (_font);//Register a font, if you use it in a embed font class, you do not need to register the font, and the above for each can be tested to know A              the test (); +         } -         Private functionTest ():void $         { $             varText:textfield =NewTextField (); -Text.width = 800; -Text.height = 600; theText.selectable =false; -Text.wordwrap =true;Wuyi              the             varTextformat:textformat =NewTextFormat (); -Textformat.font ="Yahei_font"; WuTextformat.size = 24; -Textformat.color = 0xff0000; AboutText.appendtext ("0123456789\n"); $Text.appendtext ("abcdefghijklmnopqrstuvwxyz\n"); -Text.appendtext ("abcdefghijklmnopqrstuvwxyz\n"); -Text.appendtext ("Today is difficult, tomorrow is more difficult, and the day after that is wonderful. But most people die tomorrow night, if you don't try. \ n "); -Text.appendtext ("The clarity of the water is not because it does not contain impurities, but because it understands the starch, and the permeability of the heart is not because it is not, but because it is understood to be rounded." \ n "); AText.appendtext ("/* +-@!#$%^&* () ~>< ';, (*^__^*) O (∩_∩) o well!< ( ̄ˇ ̄)/@@facesymbol@@ ̄▽ ̄) ~*\n"); +Text.embedfonts =true; the Text.settextformat (TextFormat); - addChild (text); $              theTrace (Tooxstring ("ˇ▽")); the         } the         /** the * Return 16 Unicode code - * @param str characters in * @return the          *  the          */         About         Private functiontooxstring (str:string): String the         { the             varresult:string=""; the             varLen:int=str.length;  +              for(vari:int=0; i < Len; i++)   -             {   theResult + ="u+"+ (Str.charcodeat (i)). toString (16);Bayi                 if(I < len-1) the                 { theResult + =","; -                 } -             } the             returnresult; the         } the     } the}

[ActionScript 3.0] using embed to embed fonts in a class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.