From 13c1e7560ac314e7cd623283274e99717d24f238 Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Wed, 16 Jul 2025 20:18:50 -0500 Subject: [PATCH] empty text works --- prosperon/prosperon.cm | 3 ++- scripts/graphics.cm | 4 +--- source/font.c | 2 +- source/jsffi.c | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/prosperon/prosperon.cm b/prosperon/prosperon.cm index 9287a528..90a02c76 100644 --- a/prosperon/prosperon.cm +++ b/prosperon/prosperon.cm @@ -8,7 +8,6 @@ var tilemap = use('tilemap') var geometry = use('geometry') var res = use('resources') - var video = arg[0] var graphics = use('graphics', arg[0]) @@ -228,6 +227,8 @@ function translate_draw_commands(commands) { if (!text_mesh) break + if (text_mesh.xy.length == 0) break + // Transform XY coordinates using camera matrix var camera_params = [camera.a, camera.c, camera.e, camera.f] var transformed_xy = geometry.transform_xy_blob(text_mesh.xy, camera_params) diff --git a/scripts/graphics.cm b/scripts/graphics.cm index 45014b12..e17725fd 100644 --- a/scripts/graphics.cm +++ b/scripts/graphics.cm @@ -206,10 +206,8 @@ function create_image(path){ // Check if it's an untagged animation (multiple frames, no tags) // This happens when ASE has no tags but multiple frames - if(raw.frames && Array.isArray(raw.frames) && raw.loop != null) { - log.console(`[Graphics] Loading untagged ASE animation with ${raw.frames.length} frames`) + if(raw.frames && Array.isArray(raw.frames) && raw.loop != null) return makeAnim(wrapFrames(raw.frames), !!raw.loop); - } // Multiple named animations from ASE (with tags) def anims = {}; diff --git a/source/font.c b/source/font.c index dec25feb..df87dda8 100644 --- a/source/font.c +++ b/source/font.c @@ -233,7 +233,7 @@ HMM_Vec2 measure_text(const char *text, font *f, float letterSpacing, float wrap /* pos given in screen coordinates */ struct text_vert *renderText(const char *text, HMM_Vec2 pos, font *f, colorf color, float wrap) { text_vert *buffer = NULL; - + HMM_Vec2 cursor = pos; float lineHeight = f->ascent - f->descent; float lineWidth = 0; diff --git a/source/jsffi.c b/source/jsffi.c index eef729cc..e9c8753a 100644 --- a/source/jsffi.c +++ b/source/jsffi.c @@ -296,6 +296,8 @@ JSValue quads_to_mesh(JSContext *js, text_vert *buffer) { size_t verts = arrlen(buffer); + JSValue ret = JS_NewObject(js); + // Allocate flat arrays for xy, uv, and color data size_t xy_size = verts * 2 * sizeof(float); size_t uv_size = verts * 2 * sizeof(float); @@ -333,8 +335,6 @@ JSValue quads_to_mesh(JSContext *js, text_vert *buffer) indices[i+5] = v+1; } - JSValue ret = JS_NewObject(js); - // Create blobs for geometry data JS_SetPropertyStr(js, ret, "xy", js_new_blob_stoned_copy(js, xy_data, xy_size)); JS_SetPropertyStr(js, ret, "xy_stride", JS_NewInt32(js, 2 * sizeof(float)));