Add Assets.getFont, temporarily for Flash/OpenFL only

This commit is contained in:
Joshua Granick
2014-08-12 20:35:55 -07:00
parent 36d55dad79
commit afcb3354a4
2 changed files with 116 additions and 8 deletions

View File

@@ -224,6 +224,35 @@ class DefaultAssetLibrary extends AssetLibrary {
}
public override function getFont (id:String):Dynamic /*Font*/ {
// TODO: Complete Lime Font API
#if openfl
#if (flash || js)
return cast (Type.createInstance (className.get (id), []), openfl.text.Font);
#else
if (className.exists (id)) {
var fontClass = className.get (id);
openfl.text.Font.registerFont (fontClass);
return cast (Type.createInstance (fontClass, []), openfl.text.Font);
} else {
return new openfl.text.Font (path.get (id));
}
#end
#end
}
public override function getImage (id:String):Image {
#if flash
@@ -610,8 +639,10 @@ class DefaultAssetLibrary extends AssetLibrary {
#elseif html5
::foreach assets::::if (type == "font")::@:keep class __ASSET__::flatName:: extends lime.graphics.Font { public function new () { super ("::id::"); } }::end::
#if openfl
::foreach assets::::if (type == "font")::@:keep class __ASSET__::flatName:: extends openfl.text.Font { public function new () { super (); fontName = "::id::"; } } ::end::
::end::
#end
#elseif (windows || mac || linux)