开发者_JAVA百科I mean, move font file to C/windows/fonts and install it?
No, I am pretty sure letting flash files access C:/Windows is a huge security concern.
Try embedding the font - that's putting the font in the SWF. I don't see why that won't work.
No more do you have to have fonts in your library you can embed them directly from the folder where they reside using the [Embed] in your ActionScript Project.
You supply the path to the font in the ‘source’ param and then store a name to be referenced to access the font in ‘fontFamily’. You also need to declare a variable of type String or Class for the [Embed] to be assigned to, although you don’t need to reference it in your code.
To access the embeded font you use the String you assigned to the var ‘fontFamily’
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);
}
}
精彩评论