freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] ftbench-gsoc-goksu 2c53b92 03/17: [ftdump] Code cleanu


From: Werner Lemberg
Subject: [freetype2-demos] ftbench-gsoc-goksu 2c53b92 03/17: [ftdump] Code cleanup.
Date: Sat, 20 May 2023 08:29:40 -0400 (EDT)

branch: ftbench-gsoc-goksu
commit 2c53b921e0ad3646354ca5e60de4a81b0d358ad5
Author: Werner Lemberg <wl@gnu.org>
Commit: Werner Lemberg <wl@gnu.org>

    [ftdump] Code cleanup.
    
    * src/ftdump.c (Print_MM_Axes): Move code to find an English name entry
    to...
    (get_english_name_entry): ... this new function.
---
 src/ftdump.c | 69 +++++++++++++++++++++++++++++++++---------------------------
 1 file changed, 38 insertions(+), 31 deletions(-)

diff --git a/src/ftdump.c b/src/ftdump.c
index 9b32efa..0c15ff6 100644
--- a/src/ftdump.c
+++ b/src/ftdump.c
@@ -837,20 +837,53 @@
   }
 
 
+  static void
+  get_english_name_entry( FT_Face       face,
+                          FT_UInt       strid,
+                          FT_SfntName*  entry )
+  {
+    FT_UInt  num_names = FT_Get_Sfnt_Name_Count( face );
+    FT_UInt  i;
+
+    FT_SfntName  name;
+
+
+    for ( i = 0; i < num_names; i++ )
+    {
+      error = FT_Get_Sfnt_Name( face, i, &name );
+      if ( error )
+        continue;
+
+      if ( name.name_id == strid )
+      {
+        /* XXX we don't have support for Apple's new `ltag' table yet, */
+        /* thus we ignore TT_PLATFORM_APPLE_UNICODE                    */
+        if ( ( name.platform_id == TT_PLATFORM_MACINTOSH &&
+               name.language_id == TT_MAC_LANGID_ENGLISH )        ||
+             ( name.platform_id == TT_PLATFORM_MICROSOFT        &&
+               ( name.language_id & 0xFF )
+                                == TT_MS_LANGID_ENGLISH_GENERAL ) )
+          break;
+      }
+    }
+
+    if ( i < num_names )
+      *entry = name;
+  }
+
+
   static void
   Print_MM_Axes( FT_Face  face )
   {
     FT_MM_Var*       mm;
     FT_Multi_Master  dummy;
-    FT_UInt          is_GX, i, num_names;
+    FT_UInt          is_GX, i;
 
 
     /* MM or GX axes */
     error = FT_Get_Multi_Master( face, &dummy );
     is_GX = error ? 1 : 0;
 
-    printf( "%s axes\n", is_GX ? "GX" : "MM" );
-
     error = FT_Get_MM_Var( face, &mm );
     if ( error )
     {
@@ -858,7 +891,7 @@
       return;
     }
 
-    num_names = FT_Get_Sfnt_Name_Count( face );
+    printf( "%s axes\n", is_GX ? "GX" : "MM" );
 
     for ( i = 0; i < mm->num_axis; i++ )
     {
@@ -868,33 +901,7 @@
       name.string = NULL;
 
       if ( is_GX )
-      {
-        FT_UInt  strid = mm->axis[i].strid;
-        FT_UInt  j;
-
-
-        /* iterate over all name entries        */
-        /* to find an English entry for `strid' */
-
-        for ( j = 0; j < num_names; j++ )
-        {
-          error = FT_Get_Sfnt_Name( face, j, &name );
-          if ( error )
-            continue;
-
-          if ( name.name_id == strid )
-          {
-            /* XXX we don't have support for Apple's new `ltag' table yet, */
-            /* thus we ignore TT_PLATFORM_APPLE_UNICODE                    */
-            if ( ( name.platform_id == TT_PLATFORM_MACINTOSH &&
-                   name.language_id == TT_MAC_LANGID_ENGLISH )        ||
-                 ( name.platform_id == TT_PLATFORM_MICROSOFT        &&
-                   ( name.language_id & 0xFF )
-                                    == TT_MS_LANGID_ENGLISH_GENERAL ) )
-              break;
-          }
-        }
-      }
+        get_english_name_entry( face, mm->axis[i].strid, &name );
 
       if ( name.string )
       {



reply via email to

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