Console font fixes

This commit is contained in:
Joshua Granick
2018-12-10 21:19:45 -08:00
parent 63cfd23e0b
commit eb0b2df706
2 changed files with 33 additions and 32 deletions

View File

@@ -13,74 +13,77 @@ import sys.FileSystem;
@:keep @:dox(hide) class ManifestResources {
public static var preloadLibraries:Array<AssetLibrary>;
public static var preloadLibraryNames:Array<String>;
public static var rootPath:String;
public static function init (config:Dynamic):Void {
preloadLibraries = new Array ();
preloadLibraryNames = new Array ();
var rootPath = null;
rootPath = null;
if (config != null && Reflect.hasField (config, "rootPath")) {
rootPath = Reflect.field (config, "rootPath");
}
if (rootPath == null) {
#if (ios || tvos || emscripten)
rootPath = "assets/";
#elseif console
rootPath = lime.system.System.applicationDirectory;
#elseif (sys && windows && !cs)
rootPath = FileSystem.absolutePath (haxe.io.Path.directory (#if (haxe_ver >= 3.3) Sys.programPath () #else Sys.executablePath () #end)) + "/";
#else
rootPath = "";
#end
}
Assets.defaultRootPath = rootPath;
#if (openfl && !flash && !display)
::if (assets != null)::::foreach assets::::if (type == "font")::openfl.text.Font.registerFont (__ASSET__OPENFL__::flatName::);
::end::::end::::end::
#end
var data, manifest, library;
#if kha
::manifest::
library = AssetLibrary.fromManifest (manifest);
Assets.registerLibrary ("::library::", library);
if (library != null) preloadLibraries.push (library);
else preloadLibraryNames.push ("::library::");
#else
::if (assets != null)::::foreach assets::::if (type == "manifest")::::if (embed)::data = '::data::';
manifest = AssetManifest.parse (data, rootPath);
library = AssetLibrary.fromManifest (manifest);
Assets.registerLibrary ("::library::", library);
::else::Assets.libraryPaths["::library::"] = rootPath + "::resourceName::";
::end::::end::::end::::end::
::foreach libraries::::if (preload)::library = Assets.getLibrary ("::name::");
if (library != null) preloadLibraries.push (library);
else preloadLibraryNames.push ("::name::");
::end::::end::
#end
}
}
@@ -104,12 +107,12 @@ import sys.FileSystem;
::elseif (type == "font")::@:font("::sourcePath::") #if display private #end class __ASSET__::flatName:: extends lime.text.Font {}
::else::@:file("::sourcePath::") #if display private #end class __ASSET__::flatName:: extends haxe.io.Bytes {}
::end::::end::::end::::end::
::if (assets != null)::::foreach assets::::if (!embed)::::if (type == "font")::@:keep #if display private #end class __ASSET__::flatName:: extends lime.text.Font { public function new () { ::if (targetPath != null)::__fontPath = #if (ios || tvos) "assets/" + #end "::targetPath::";::else::::if (library != null)::__fontID = "::library:::::id::";::else::__fontID = "::id::";::end::::end:: name = "::fontName::"; super (); }}
::if (assets != null)::::foreach assets::::if (!embed)::::if (type == "font")::@:keep #if display private #end class __ASSET__::flatName:: extends lime.text.Font { public function new () { ::if (targetPath != null)::__fontPath = ManifestResources.rootPath + "::targetPath::";::else::::if (library != null)::__fontID = "::library:::::id::";::else::__fontID = "::id::";::end::::end:: ::if (fontName)::name = "::fontName::";::end:: super (); }}
::end::::end::::end::::end::
#else
::if (assets != null)::::foreach assets::::if (type == "font")::@:keep @:expose('__ASSET__::flatName::') #if display private #end class __ASSET__::flatName:: extends lime.text.Font { public function new () { #if !html5 __fontPath = "::targetPath::"; #else ascender = ::ascender::; descender = ::descender::; height = ::height::; numGlyphs = ::numGlyphs::; underlinePosition = ::underlinePosition::; underlineThickness = ::underlineThickness::; unitsPerEM = ::unitsPerEM::; #end name = "::fontName::"; super (); }}
::if (assets != null)::::foreach assets::::if (type == "font")::@:keep @:expose('__ASSET__::flatName::') #if display private #end class __ASSET__::flatName:: extends lime.text.Font { public function new () { #if !html5 __fontPath = "::targetPath::"; #else ascender = ::ascender::; descender = ::descender::; height = ::height::; numGlyphs = ::numGlyphs::; underlinePosition = ::underlinePosition::; underlineThickness = ::underlineThickness::; unitsPerEM = ::unitsPerEM::; #end::if (fontName):: name = "::fontName::";::end::; super (); }}
::end::::end::::end::
#end
@@ -117,10 +120,10 @@ import sys.FileSystem;
#if (openfl && !flash)
#if html5
::if (assets != null)::::foreach assets::::if (type == "font")::@:keep @:expose('__ASSET__OPENFL__::flatName::') #if display private #end class __ASSET__OPENFL__::flatName:: extends openfl.text.Font { public function new () { ::if (embed)::__fromLimeFont (new __ASSET__::flatName:: ());::else::name = "::fontName::";::end:: super (); }}
::if (assets != null)::::foreach assets::::if (type == "font")::@:keep @:expose('__ASSET__OPENFL__::flatName::') #if display private #end class __ASSET__OPENFL__::flatName:: extends openfl.text.Font { public function new () {::if (embed):: __fromLimeFont (new __ASSET__::flatName:: ());::else::::if (fontName):: name = "::fontName::";::end::::end:: super (); }}
::end::::end::::end::
#else
::if (assets != null)::::foreach assets::::if (type == "font")::@:keep @:expose('__ASSET__OPENFL__::flatName::') #if display private #end class __ASSET__OPENFL__::flatName:: extends openfl.text.Font { public function new () { ::if (embed)::__fromLimeFont (new __ASSET__::flatName:: ());::else::::if (targetPath != null)::__fontPath = #if (ios || tvos) "assets/" + #end "::targetPath::";::else::::if (library != null)::__fontID = "::library:::::id::";::else::__fontID = "::id::";::end::::end:: name = "::fontName::";::end:: super (); }}
::if (assets != null)::::foreach assets::::if (type == "font")::@:keep @:expose('__ASSET__OPENFL__::flatName::') #if display private #end class __ASSET__OPENFL__::flatName:: extends openfl.text.Font { public function new () {::if (embed):: __fromLimeFont (new __ASSET__::flatName:: ());::else:: ::if (targetPath != null)::__fontPath = ManifestResources.rootPath + "::targetPath::";::else::::if (library != null)::__fontID = "::library:::::id::";::else::__fontID = "::id::";::end::::end::::if (fontName):: name = "::fontName::";::end::::end:: super (); }}
::end::::end::::end::
#end