freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2-demos] master 624d6e9: [ftstring] Loop through a custom strin


From: Werner Lemberg
Subject: [freetype2-demos] master 624d6e9: [ftstring] Loop through a custom string if present.
Date: Thu, 26 Aug 2021 17:09:05 -0400 (EDT)

branch: master
commit 624d6e9b03e8aa3b0828ecf17b13a4fb64b7ac41
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>

    [ftstring] Loop through a custom string if present.
    
    * src/ftstring.c (Sample): Use the initial pointer for a custom string.
    (parse_cmdline): Assing the pointer here if any.
    (event_text_change): Loop through the pointer if set.
    (main): Minor tweak.
---
 src/ftstring.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/ftstring.c b/src/ftstring.c
index 802d225..57c6326 100644
--- a/src/ftstring.c
+++ b/src/ftstring.c
@@ -30,6 +30,9 @@
 
   static const char*  Sample[] =
   {
+    /* Custom string if any */
+    NULL,
+
     "The quick brown fox jumps over the lazy dog",
 
     /* Luís argüia à Júlia que «brações, fé, chá, óxido, pôr, zângão» */
@@ -428,15 +431,14 @@
   static void
   event_text_change( void )
   {
-    static int  i = 0;
+    static int  i = INT_MAX - 1;
 
-    status.text = Sample[i];
 
-    i++;
-    if ( i >= (int)( sizeof( Sample ) / sizeof( Sample[0] ) ) )
-      i = 0;
-  }
+    if ( ++i >= (int)( sizeof( Sample ) / sizeof( Sample[0] ) ) )
+      i = Sample[0] == NULL ? 1 : 0;
 
+    status.text = Sample[i];
+  }
 
   static void
   event_size_change( int  delta )
@@ -732,7 +734,7 @@
       case 'm':
         if ( *argc < 3 )
           usage( execname );
-        status.text = optarg;
+        Sample[0] = optarg;
         break;
 
       case 'r':
@@ -980,8 +982,7 @@
 
     status.header = NULL;
 
-    if ( !status.text )
-      event_text_change();
+    event_text_change();
 
     event_color_change();
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]