Handle font assets in project format
This commit is contained in:
@@ -10,6 +10,7 @@ typedef TProjectFormat = {
|
||||
@:optional public var material_nodes: Array<TNodeCanvas>;
|
||||
@:optional public var material_icons: Array<haxe.io.Bytes>;
|
||||
@:optional public var assets: Array<String>; // texture_assets
|
||||
@:optional public var font_assets: Array<String>;
|
||||
@:optional public var layer_datas: Array<TLayerData>;
|
||||
@:optional public var mesh_datas: Array<TMeshData>;
|
||||
@:optional public var mesh_assets: Array<String>;
|
||||
|
||||
@@ -4,6 +4,7 @@ import haxe.Json;
|
||||
import zui.Nodes;
|
||||
import iron.data.SceneFormat;
|
||||
import iron.system.ArmPack;
|
||||
import arm.data.FontSlot;
|
||||
import arm.ui.UISidebar;
|
||||
import arm.format.Lz4;
|
||||
import arm.sys.Path;
|
||||
@@ -38,6 +39,7 @@ class ExportArm {
|
||||
for (p in Project.paintObjects) md.push(p.data.raw);
|
||||
|
||||
var texture_files = assetsToFiles(Project.assets);
|
||||
var font_files = fontsToFiles(Project.fonts);
|
||||
var mesh_files = meshesToFiles();
|
||||
|
||||
var bitsPos = App.bitsHandle.position;
|
||||
@@ -81,6 +83,7 @@ class ExportArm {
|
||||
mesh_datas: md,
|
||||
layer_datas: ld,
|
||||
assets: texture_files,
|
||||
font_assets: font_files,
|
||||
mesh_assets: mesh_files,
|
||||
#if (kha_metal || kha_vulkan)
|
||||
is_bgra: true
|
||||
@@ -209,4 +212,20 @@ class ExportArm {
|
||||
}
|
||||
return mesh_files;
|
||||
}
|
||||
|
||||
static function fontsToFiles(fonts: Array<FontSlot>): Array<String> {
|
||||
var font_files: Array<String> = [];
|
||||
for (i in 1...fonts.length) {
|
||||
var f = fonts[i];
|
||||
// Convert font path from absolute to relative
|
||||
var sameDrive = Project.filepath.charAt(0) == f.file.charAt(0);
|
||||
if (sameDrive) {
|
||||
font_files.push(Path.toRelative(Project.filepath, f.file));
|
||||
}
|
||||
else {
|
||||
font_files.push(f.file);
|
||||
}
|
||||
}
|
||||
return font_files;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,6 +123,7 @@ class ImportArm {
|
||||
var format = l0.bpp == 8 ? TextureFormat.RGBA32 : l0.bpp == 16 ? TextureFormat.RGBA64 : TextureFormat.RGBA128;
|
||||
|
||||
var base = Path.baseDir(path);
|
||||
|
||||
for (file in project.assets) {
|
||||
#if krom_windows
|
||||
file = file.replace("/", "\\");
|
||||
@@ -137,6 +138,21 @@ class ImportArm {
|
||||
ImportTexture.run(abs);
|
||||
}
|
||||
|
||||
if (project.font_assets != null) {
|
||||
for (file in project.font_assets) {
|
||||
#if krom_windows
|
||||
file = file.replace("/", "\\");
|
||||
#else
|
||||
file = file.replace("\\", "/");
|
||||
#end
|
||||
// Convert font path from relative to absolute
|
||||
var abs = Data.isAbsolute(file) ? file : base + file;
|
||||
if (File.exists(abs)) {
|
||||
ImportFont.run(abs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Synchronous for now
|
||||
new MeshData(project.mesh_datas[0], function(md: MeshData) {
|
||||
Context.paintObject.setData(md);
|
||||
|
||||
Reference in New Issue
Block a user