I keep getting an error when trying to used embedded font. Here is the error message “[Fault] exception, information=TypeError: Error #1006: __fromBytes is not a function.
” I’ve tried using 3 different ways and none of them worked.
Calling the embedded class that I extended from the Font class.
@:font("./assets/becc/font/arialbd.ttf")
class ArialFontBold extends Font { }
UIStyleManager.BUTTON_TEXT_EMBED = new ArialFontBold();
Font.registerFont method
@:font("./assets/becc/font/arial.ttf")
class ArialFontReg extends Font { }
Font.registerFont(ArialFontReg);
I even tried the Asset.loadFont and Asset.getFont but they returned null.
Assets.loadFont("./assets/becc/font/arial.ttf");
trace(Assets.getFont("./assets/becc/font/arial.ttf").fontType );
To use the Assets
class, you need to add an <assets />
tag to project.xml. For instance:
<assets path="assets" />
This will embed everything (besides a few specific exceptions) from inside your assets folder. However, when it does this, it will assign an identifier starting with “assets
”, not “./assets
.”
Try this instead:
trace(Assets.getFont("assets/becc/font/arial.ttf"));
Or, to see which assets were embedded successfully, try this:
trace(Assets.list());
I really wanted to go with the embed option just because one of the the tools I have compile things down into a single .swf or binary file. My goal is to embed the assets that are needed once the developer import the class that require them.
In that case, try <assets path="assets" embed="true" />
to make Lime generate the correct @:font()
tags.
I got everything working using asset tag but is there a way to embed the font without using it?
You can see how Lime does it by going to Export/[platform]/release/haxe/DefaultAssetLibrary.hx
. The @:font
tags will be near the bottom.
Ok, that sounds good man. Thanks for the help.
5 posts were split to a new topic: Issue loading HTML5 font at runtime