freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] master b653a23 3/4: [sfnt] Split off another bit of `sfnt_ge


From: Werner LEMBERG
Subject: [freetype2] master b653a23 3/4: [sfnt] Split off another bit of `sfnt_get_ps_name'.
Date: Tue, 28 Feb 2017 09:28:12 -0500 (EST)

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

    [sfnt] Split off another bit of `sfnt_get_ps_name'.
    
    * src/sfnt/sfdriver.c (sfnt_get_ps_name): Split off some
    functionality into...
    (search_name_id): ... New function.
---
 ChangeLog           |  8 ++++++++
 src/sfnt/sfdriver.c | 43 +++++++++++++++++++++++++++++--------------
 2 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8b715c8..8c81015 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2017-02-23  Werner Lemberg  <address@hidden>
 
+       [sfnt] Split off another bit of `sfnt_get_ps_name'.
+
+       * src/sfnt/sfdriver.c (sfnt_get_ps_name): Split off some
+       functionality into...
+       (search_name_id): ... New function.
+
+2017-02-23  Werner Lemberg  <address@hidden>
+
        [sfnt] Modularize `sfnt_get_ps_name'.
 
        * src/sfnt/sfdriver.c (sfnt_get_ps_name): Split off some
diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c
index a7bde16..5c70de9 100644
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -306,36 +306,51 @@
   }
 
 
-  static const char*
-  sfnt_get_ps_name( TT_Face  face )
+  static int
+  search_name_id( TT_Face  face,
+                  FT_Int   id,
+                  FT_Int  *win,
+                  FT_Int  *apple )
   {
-    FT_Int       n, found_win, found_apple;
-    const char*  result = NULL;
+    FT_Int  n;
 
 
-    if ( face->postscript_name )
-      return face->postscript_name;
-
-    /* scan the name table to see whether we have a Postscript name here, */
-    /* either in Macintosh or Windows platform encodings                  */
-    found_win   = -1;
-    found_apple = -1;
+    *win   = -1;
+    *apple = -1;
 
     for ( n = 0; n < face->num_names; n++ )
     {
       TT_Name  name = face->name_table.names + n;
 
 
-      if ( name->nameID == 6 && name->stringLength > 0 )
+      if ( name->nameID == id && name->stringLength > 0 )
       {
         if ( IS_WIN( name ) )
-          found_win = n;
+          *win = n;
 
         if ( IS_APPLE( name ) )
-          found_apple = n;
+          *apple = n;
       }
     }
 
+    return *win || *apple;
+  }
+
+
+  static const char*
+  sfnt_get_ps_name( TT_Face  face )
+  {
+    FT_Int       found_win, found_apple;
+    const char*  result = NULL;
+
+
+    if ( face->postscript_name )
+      return face->postscript_name;
+
+    /* scan the name table to see whether we have a Postscript name here, */
+    /* either in Macintosh or Windows platform encodings                  */
+    search_name_id( face, 6, &found_win, &found_apple );
+
     /* prefer Windows entries over Apple */
     if ( found_win != -1 )
       result = get_win_string( face->root.memory,



reply via email to

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