Copy link to clipboard
Copied
Hi!
Im trying to embed a font in a actionScript project in Flash Builder like this:
package {
import flash.display.*;
import flash.text.*;
public class HelloWorldEmbedded extends Sprite {
// Embed the font Verdana
[Embed(source="Verdana.ttf", fontFamily="Verdana")]
private var verdana:Class;
public function HelloWorldEmbedded() {
var t:TextField = new TextField();
// Tell Flash Player to use embedded fonts when rendering t's content
t.embedFonts = true;
t.htmlText = "<FONT FACE='Verdana'>Hello world</FONT>";
t.text = "Hello World";
addChild(t)
}
}
}
But when i debug my application i can't see any text!
This is the link of my project http://www.emmelledesign.it/eas3_fonts_embedding.fxp
Thanks so much!
Matteo
Copy link to clipboard
Copied
Oh, I see. This is SDK issue. You didn't have to do that in versions prior to 4. I am using 3.5
Copy link to clipboard
Copied
Good to know!
Thanks!
Copy link to clipboard
Copied
This is regarding your previous post with "in assets folder i have Pilgiche.ttf file!"
You will not see text
"<FONT FACE='Pilgiche'>Hello world</FONT>"
because it doesn't work in principal, it is not supposed to work without either TextFormat or StyleSheet
Copy link to clipboard
Copied
The following two classes prove that embedded fonts are available globally:
package {
import flash.display.Sprite;
public class FontTest extends Sprite {
[Embed(source="Verdana.TTF", fontFamily="Verdana")]
public var verdana:String;
[Embed(source="CURLZ___.TTF", fontFamily="Arial")]
public var arial:String;
public function FontTest() {
var fontTest:FontTestChild = new FontTestChild();
addChild(fontTest);
}
}
}
External class:
package
{
import flash.display.Sprite;
import flash.text.AntiAliasType;
import flash.text.GridFitType;
import flash.text.StyleSheet;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
public class FontTestChild extends Sprite
{
public function FontTestChild()
{
var style:StyleSheet = new StyleSheet();
style.setStyle(".redFont", { fontFamily: "Verdana", fontSize: 50, color: "#ff0000" } );
style.setStyle(".greenFont", { fontFamily: "Arial", fontSize: 30, color: "#008000"} );
style.setStyle("p", { fontFamily: "Arial", fontSize: 100, color: "#000080"} );
var label:TextField = new TextField();
label.embedFonts = true;
label.autoSize = TextFieldAutoSize.LEFT;
label.antiAliasType = AntiAliasType.ADVANCED;
label.gridFitType = GridFitType.PIXEL;
label.sharpness = -200;
label.styleSheet = style;
label.htmlText = "<p>AHA!!! <span class='redFont'>Hello world!</span><span class='greenFont'> It works!</span></p>";
addChild(label);
}
}
}
Copy link to clipboard
Copied
Solved!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now