ActionScript 3 嵌入外部字体说明:方法1

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 嵌入外部字体说明:方法1相关的知识,希望对你有一定的参考价值。

//This line can be in the timeline or if your using a class, within the class, Not within a function.

[Embed(source='/assets/fonts/NeoSans.ttf', fontName="TheCrazyMan", mimeType="application/x-font-truetype")]
public static var FONT_NEOSANS:Class;  //<------------Variable must be static in-order for this to work.


//////////////////////////////////////////////////////TextFormat Creation

var format:TextFormat = new TextFormat();

format.font = "TheCrazyMan";
format.color = "0xB10101";
format.size = 14;

//////////////////////////////////////////////////////Dynamic Text Field
var tf:TextField = new TextField();
tf.embedFonts = true;  //<----------------------------embedFonts must be true;
tf.selectable = false;
tf.x = 8;
tf.y = 20;
tf.defaultTextFormat = format;  //<-------------------Must be defaultTextFormat;
tf.text = "A new font";
addChild(tf);

//////////////////////////////////////////////////////Text Field already on stage titled testText1
testText1.defaultTextFormat = format;
testText1.text = "A new font";		
testText2.embedFonts = true;   //<--------------------embedFonts must be true;
testText2.defaultTextFormat = format2;  //<-----------Must be defaultTextFormat;
testText2.text = "A new font";

//////////////////////////////////////////////////////If Using AssetManagement Solution

import AssetManager;

public class Main extends MovieClip
{
 var FT:Class = AssetManager.FONT_NEOSANS;  //<-------Gives access to font in AssetManager class.
 public function Main()
 {
  // Continue with TextFormat and Text Field code above.
 }
}

以上是关于ActionScript 3 嵌入外部字体说明:方法1的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3 盖亚嵌入字体资产

ActionScript 3 AS3递归字体嵌入

ActionScript 3 查看所有嵌入字体

ActionScript 3 从库中嵌入字体

ActionScript 3 嵌入字体Flash

ActionScript 3 嵌入字体