freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master f5fb26e: * src/ftdump.c (main): Fix thinko intr


From: Werner LEMBERG
Subject: [freetype2-demos] master f5fb26e: * src/ftdump.c (main): Fix thinko introduced in commit from
Date: Fri, 8 May 2020 00:38:08 -0400 (EDT)

branch: master
commit f5fb26e40d4844289a9768e603df5cca69b9a00f
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>

    * src/ftdump.c (main): Fix thinko introduced in commit from
    2020-05-01.
---
 ChangeLog    |  5 +++++
 src/ftdump.c | 25 ++++++++++++++-----------
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a9b3499..f75b409 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2020-05-08  Werner Lemberg  <address@hidden>
+
+       * src/ftdump.c (main): Fix thinko introduced in commit from
+       2020-05-01.
+
 2020-05-04  Alexei Podtelezhnikov  <address@hidden>
 
        * ftcommon.c (FTDemo_Draw_Header): Right-flush filename.
diff --git a/src/ftdump.c b/src/ftdump.c
index 27318c7..db97f79 100644
--- a/src/ftdump.c
+++ b/src/ftdump.c
@@ -961,28 +961,31 @@
 
     file = 0;
 
-    /* try to load the file name as is, first */
-    error = FT_New_Face( library, argv[file], 0, &face );
+    snprintf( filename, sizeof ( filename ), "%s", argv[file] );
+
+    /* try to load the file name as is */
+    error = FT_New_Face( library, filename, 0, &face );
     if ( !error )
       goto Success;
 
 #ifndef macintosh
-    i = (int)strlen( argv[file] );
-    while ( i > 0 && argv[file][i] != '\\' && argv[file][i] != '/' )
+    /* try again, with `.ttf' appended if no extension */
+    i = (int)strlen( filename );
+    while ( i > 0 && filename[i] != '\\' && filename[i] != '/' )
     {
-      if ( argv[file][i] == '.' )
+      if ( filename[i] == '.' )
         i = 0;
       i--;
     }
 
-    snprintf( filename, sizeof ( filename ), "%s%s", argv[file],
-              ( i >= 0 ? ".ttf" : "" ) );
-#else
-    snprintf( filename, sizeof ( filename ), "%s", argv[file] );
+    if ( i >= 0 )
+    {
+      snprintf( filename, sizeof ( filename ), "%s%s", argv[file], ".ttf" );
+
+      error = FT_New_Face( library, filename, 0, &face );
+    }
 #endif
 
-    /* Load face */
-    error = FT_New_Face( library, filename, 0, &face );
     if ( error )
       PanicZ( library, "Could not open face." );
 



reply via email to

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