implement centered wrapped text

Wed, 10 Apr 2024 19:43:34 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 10 Apr 2024 19:43:34 +0200
changeset 57
7daec2f067a9
parent 56
428fbb8355eb
child 58
26ebb2f1e6e6

implement centered wrapped text

src/text.c file | annotate | diff | comparison | revisions
--- a/src/text.c	Wed Apr 10 19:35:14 2024 +0200
+++ b/src/text.c	Wed Apr 10 19:43:34 2024 +0200
@@ -57,11 +57,13 @@
     }
 
     // Render text onto a surface
+    TTF_Font *font = asc_font_cache_validate(node->font)->ptr;
+    TTF_SetFontWrappedAlign(
+            font, node->centered ?
+                  TTF_WRAPPED_ALIGN_CENTER : TTF_WRAPPED_ALIGN_LEFT
+    );
     SDL_Surface *surface = TTF_RenderUTF8_Blended_Wrapped(
-            asc_font_cache_validate(node->font)->ptr,
-            node->text,
-            asc_col_sdl(node->color),
-            node->max_width
+            font, node->text, asc_col_sdl(node->color), node->max_width
     );
     if (surface == NULL) {
         asc_error(SDL_GetError());

mercurial