src/text.c

changeset 135
062703d3f5cc
parent 122
1b118cd3e369
child 137
f8e6e0ae61a8
--- a/src/text.c	Sun Jun 01 14:33:58 2025 +0200
+++ b/src/text.c	Sun Jun 01 14:53:59 2025 +0200
@@ -60,16 +60,20 @@
         text->offx = newoffx;
     }
 
+    // Transfer Image Data
+    asc_texture_from_surface(sprite->texture, surface);
+
     // If dimensions changed, update the mesh
     if (text->dimension.x != (unsigned)surface->w || text->dimension.y != (unsigned)surface->h) {
         text->dimension.x = surface->w;
         text->dimension.y = surface->h;
-        asc_mesh_plane_2d(&text->base.mesh, .size = asc_vec2f_new(surface->w, surface->h));
+        const asc_vec2f uv_scale = asc_texture_calculate_uv_scale(sprite->texture, text->dimension, asc_vec2f_one);
+        asc_mesh_plane_2d(&text->base.mesh,
+            .size = asc_vec2f_new(surface->w, surface->h),
+            .uv_scale = uv_scale
+        );
     }
 
-    // Transfer Image Data
-    asc_texture_from_surface(sprite->texture, surface);
-
     // Free the surface
     SDL_FreeSurface(surface);
 

mercurial