Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using operating system fonts inside a flash application without embedding it

I'm starting to localize my flash application. I'm trying to see if there is a way to rollback on default operating system fonts for languages like japanese so I don't have to embed them. So far I didn't find anything online. I'm currently using css to define the font family like :

@font-face
{
   fontFamily: "Tuffy Regular";
   src:url("/assets/fonts/Tuffy-Regular.ttf");
   embedAsCFF: true;
}

Any advice on this ?

Thanks

Olivier

like image 987
Olivier Avatar asked Nov 04 '22 16:11

Olivier


1 Answers

In AS3 you can style text 2 ways, with TextFormat, and with StyleSheet. You want to use StyleSheet: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/StyleSheet.html?filter_flash=cs5&filter_flashplayer=10.2&filter_air=2.6

And you want to use the fontFamily attribute to specify the font families you want.

Here is a working example:

package {
import flash.display.Sprite;
import flash.text.StyleSheet;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;

public class Main extends Sprite {

    public function Main() {
        var style:StyleSheet = new StyleSheet();

        var heading:Object = new Object();
        heading.fontWeight = "bold";
        heading.color = "#FF0000";
        heading.fontFamily = "Trebuchet MS, Arial, Helvetica, sans-serif";

        var body:Object = new Object();
        body.fontStyle = "italic";
        body.fontFamily = "Courier New, Courier, monospace";



        style.setStyle(".heading", heading);
        style.setStyle("body", body);
        //style.setStyle("fontFamily", 

        var label:TextField = new TextField();
        label.styleSheet = style;
        label.htmlText = "<body><span class='heading'>Hello </span>World...</body>";
        addChild(label);
    }
}

}

like image 98
Plastic Sturgeon Avatar answered Nov 10 '22 14:11

Plastic Sturgeon