freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master c6a518b: Finish hinting engine selection code f


From: Werner LEMBERG
Subject: [freetype2-demos] master c6a518b: Finish hinting engine selection code for Type 1 and CID fonts.
Date: Thu, 14 Dec 2017 06:24:17 -0500 (EST)

branch: master
commit c6a518b5d1ecd2d2123bf555201ad48cfb880b23
Author: Ewald Hew <address@hidden>
Commit: Werner Lemberg <address@hidden>

    Finish hinting engine selection code for Type 1 and CID fonts.
    
    * src/ftview.c (event_cff_hinting_engine_change,
    event_type1_hinting_engine_change,
    event_t1cid_hinting_engine_change): Moved and renamed to...
    
    * src/ftcommon.c (FTDemo_Event_Cff_Hinting_Engine_Change,
    FTDemo_Event_Type1_Hinting_Engine_Change,
    FTDemo_Event_T1cid_Hinting_Engine_Change): ...these.
    Include FT_MODULE_H.
    
    * src/ftcommon.h: Declarations.
    * src/ftmulti.c: Forward declarations.
    
    * Makefile: Updated to link above.
    
    * src/ftview.c (event_tt_interpreter_version_change): Updated.
    (Process_Event)<'H'>: Updated.
    
    * src/ftbench.c: s/cff_hinting_/ps_hinting_/.
    (main): Set `hinting-engine' property for all PostScript format
    drivers.
    
    * src/ftdiff.c (ColumnStateRec): New fields `type1_hinting_engine'
    and `t1cid_hinting_engine'.
    (render_state_init): Initialize new fields.
    (render_state_draw): Use new fields.
    Update footer string.
    (process_event) <'H'>: Updated.
    
    * src/ftgrid.c (GridStatusRec): New fields `type1_hinting_engine'
    and `t1cid_hinting_engine'.
    (main): Initialize new fields.
    (event_cff_hinting_engine_change): Removed.
    (Process_Event) <'H'>: Updated.
    
    * src/ftmulti.c (type1_hinting_engine, t1cid_hinting_engine): New
    fields.
    (main): Initialize new fields.
    Update header string.
    (cff_hinting_engine_change): Removed.
    (Process_Event) <'H'>: Updated.
---
 ChangeLog      |  46 ++++++++++++++++++++++
 Makefile       |   4 +-
 src/ftbench.c  |  50 ++++++++++++++---------
 src/ftcommon.c |  88 +++++++++++++++++++++++++++++++++++++++++
 src/ftcommon.h |  15 +++++++
 src/ftdiff.c   |  77 ++++++++++++++++++++++++++++++------
 src/ftgrid.c   | 104 +++++++++++++++++++++++++++++++-----------------
 src/ftmulti.c  |  85 +++++++++++++++++++++++++---------------
 src/ftview.c   | 122 ++++++++++-----------------------------------------------
 9 files changed, 389 insertions(+), 202 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d6f4c1c..931b851 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,49 @@
+2017-12-14  Ewald Hew  <address@hidden>
+           Werner Lemberg  <address@hidden>
+
+       Finish hinting engine selection code for Type 1 and CID fonts.
+
+       * src/ftview.c (event_cff_hinting_engine_change,
+       event_type1_hinting_engine_change,
+       event_t1cid_hinting_engine_change): Moved and renamed to...
+
+       * src/ftcommon.c (FTDemo_Event_Cff_Hinting_Engine_Change,
+       FTDemo_Event_Type1_Hinting_Engine_Change,
+       FTDemo_Event_T1cid_Hinting_Engine_Change): ...these.
+       Include FT_MODULE_H.
+
+       * src/ftcommon.h: Declarations.
+       * src/ftmulti.c: Forward declarations.
+
+       * Makefile: Updated to link above.
+
+       * src/ftview.c (event_tt_interpreter_version_change): Updated.
+       (Process_Event) <'H'>: Updated.
+
+       * src/ftbench.c: s/cff_hinting_/ps_hinting_/.
+       (main): Set `hinting-engine' property for all PostScript format
+       drivers.
+
+       * src/ftdiff.c (ColumnStateRec): New fields `type1_hinting_engine'
+       and `t1cid_hinting_engine'.
+       (render_state_init): Initialize new fields.
+       (render_state_draw): Use new fields.
+       Update footer string.
+       (process_event) <'H'>: Updated.
+
+       * src/ftgrid.c (GridStatusRec): New fields `type1_hinting_engine'
+       and `t1cid_hinting_engine'.
+       (main): Initialize new fields.
+       (event_cff_hinting_engine_change): Removed.
+       (Process_Event) <'H'>: Updated.
+
+       * src/ftmulti.c (type1_hinting_engine, t1cid_hinting_engine): New
+       fields.
+       (main): Initialize new fields.
+       Update header string.
+       (cff_hinting_engine_change): Removed.
+       (Process_Event) <'H'>: Updated.
+
 2017-12-08  Werner Lemberg  <address@hidden>
 
        [ftview] Allow hinting engine selection for Type 1 and CID fonts.
diff --git a/Makefile b/Makefile
index e55dcfe..627ce3a 100644
--- a/Makefile
+++ b/Makefile
@@ -534,8 +534,8 @@ else
          $(LINK_NEW)
 
   $(BIN_DIR_2)/ftmulti$E: $(OBJ_DIR_2)/ftmulti.$(SO) $(FTLIB) \
-                          $(GRAPH_LIB) $(COMMON_OBJ)
-         $(LINK_GRAPH)
+                          $(GRAPH_LIB) $(COMMON_OBJ) $(FTCOMMON_OBJ)
+         $(LINK_NEW)
 
   $(BIN_DIR_2)/ftstring$E: $(OBJ_DIR_2)/ftstring.$(SO) $(FTLIB) \
                            $(GRAPH_LIB) $(COMMON_OBJ) $(FTCOMMON_OBJ)
diff --git a/src/ftbench.c b/src/ftbench.c
index 219e7e2..3d73d32 100644
--- a/src/ftbench.c
+++ b/src/ftbench.c
@@ -141,12 +141,12 @@
   static int           num_tt_interpreter_versions;
   static unsigned int  dflt_tt_interpreter_version;
 
-  static unsigned int  cff_hinting_engines[2];
-  static int           num_cff_hinting_engines;
-  static unsigned int  dflt_cff_hinting_engine;
+  static unsigned int  ps_hinting_engines[2];
+  static int           num_ps_hinting_engines;
+  static unsigned int  dflt_ps_hinting_engine;
 
-  static char  cff_hinting_engine_names[2][10] = { "freetype",
-                                                   "adobe" };
+  static char  ps_hinting_engine_names[2][10] = { "freetype",
+                                                  "adobe" };
 
 
   /*
@@ -801,15 +801,15 @@
               tt_interpreter_versions[2] );
 
     /* we expect that at least one hinting engine is available */
-    if ( num_cff_hinting_engines == 1 )
+    if ( num_ps_hinting_engines == 1 )
       sprintf(hinting_engines,
               "`%s'",
-              cff_hinting_engine_names[cff_hinting_engines[0]] );
+              ps_hinting_engine_names[ps_hinting_engines[0]] );
     else
       sprintf(hinting_engines,
               "`%s' and `%s'",
-              cff_hinting_engine_names[cff_hinting_engines[0]],
-              cff_hinting_engine_names[cff_hinting_engines[1]] );
+              ps_hinting_engine_names[ps_hinting_engines[0]],
+              ps_hinting_engine_names[ps_hinting_engines[1]] );
 
 
     fprintf( stderr,
@@ -823,7 +823,7 @@
       "  -c N      Use at most N iterations for each test\n"
       "            (0 means time limited).\n"
       "  -f L      Use hex number L as load flags (see `FT_LOAD_XXX').\n"
-      "  -H NAME   Use CFF hinting engine NAME.\n"
+      "  -H NAME   Use PS hinting engine NAME.\n"
       "            Available versions are %s; default is `%s'.\n"
       "  -I VER    Use TT interpreter version VER.\n"
       "            Available versions are %s; default is version %d.\n"
@@ -833,7 +833,7 @@
       "              0: none, 1: default, 2: light, 16: legacy\n"
       "  -m M      Set maximum cache size to M KiByte (default is %d).\n",
              hinting_engines,
-             cff_hinting_engine_names[dflt_cff_hinting_engine],
+             ps_hinting_engine_names[dflt_ps_hinting_engine],
              interpreter_versions,
              dflt_tt_interpreter_version,
              CACHE_SIZE );
@@ -925,22 +925,28 @@
 
     FT_Property_Get( lib,
                      "cff",
-                     "hinting-engine", &dflt_cff_hinting_engine );
+                     "hinting-engine", &dflt_ps_hinting_engine );
     for ( j = 0; j < 2; j++ )
     {
       error = FT_Property_Set( lib,
                                "cff",
                                "hinting-engine", &engines[j] );
       if ( !error )
-        cff_hinting_engines[num_cff_hinting_engines++] = engines[j];
+        ps_hinting_engines[num_ps_hinting_engines++] = engines[j];
     }
     FT_Property_Set( lib,
                      "cff",
-                     "hinting-engine", &dflt_cff_hinting_engine );
+                     "hinting-engine", &dflt_ps_hinting_engine );
+    FT_Property_Set( lib,
+                     "type1",
+                     "hinting-engine", &dflt_ps_hinting_engine );
+    FT_Property_Set( lib,
+                     "t1cid",
+                     "hinting-engine", &dflt_ps_hinting_engine );
 
 
     version = (int)dflt_tt_interpreter_version;
-    engine  = cff_hinting_engine_names[dflt_cff_hinting_engine];
+    engine  = ps_hinting_engine_names[dflt_ps_hinting_engine];
 
     while ( 1 )
     {
@@ -975,20 +981,26 @@
       case 'H':
         engine = optarg;
 
-        for ( j = 0; j < num_cff_hinting_engines; j++ )
+        for ( j = 0; j < num_ps_hinting_engines; j++ )
         {
-          if ( !strcmp( engine, cff_hinting_engine_names[j] ) )
+          if ( !strcmp( engine, ps_hinting_engine_names[j] ) )
           {
             FT_Property_Set( lib,
                              "cff",
                              "hinting-engine", &j );
+            FT_Property_Set( lib,
+                             "type1",
+                             "hinting-engine", &j );
+            FT_Property_Set( lib,
+                             "t1cid",
+                             "hinting-engine", &j );
             break;
           }
         }
 
-        if ( j == num_cff_hinting_engines )
+        if ( j == num_ps_hinting_engines )
           fprintf( stderr,
-                   "warning: couldn't set CFF hinting engine\n" );
+                   "warning: couldn't set hinting engine\n" );
         break;
 
       case 'I':
diff --git a/src/ftcommon.c b/src/ftcommon.c
index db4bd89..24b92c9 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -17,6 +17,7 @@
 
 #include <ft2build.h>
 #include FT_FREETYPE_H
+#include FT_MODULE_H
 
 #include FT_CACHE_H
 #include FT_CACHE_MANAGER_H
@@ -44,6 +45,9 @@
 #endif
 
 
+#define N_HINTING_ENGINES  2
+
+
   FT_Error  error;
 
 
@@ -1685,4 +1689,88 @@
   }
 
 
+  unsigned int
+  FTDemo_Event_Cff_Hinting_Engine_Change( FT_Library     library,
+                                          unsigned int*  current,
+                                          unsigned int   delta )
+  {
+    unsigned int  new_cff_hinting_engine = 0;
+
+
+    if ( delta )
+      new_cff_hinting_engine = ( *current          +
+                                 delta             +
+                                 N_HINTING_ENGINES ) % N_HINTING_ENGINES;
+
+    error = FT_Property_Set( library,
+                             "cff",
+                             "hinting-engine",
+                             &new_cff_hinting_engine );
+
+    if ( !error )
+    {
+      *current = new_cff_hinting_engine;
+      return 1;
+    }
+
+    return 0;
+  }
+
+
+  unsigned int
+  FTDemo_Event_Type1_Hinting_Engine_Change( FT_Library     library,
+                                            unsigned int*  current,
+                                            unsigned int   delta )
+  {
+    unsigned int  new_type1_hinting_engine = 0;
+
+
+    if ( delta )
+      new_type1_hinting_engine = ( *current          +
+                                   delta             +
+                                   N_HINTING_ENGINES ) % N_HINTING_ENGINES;
+
+    error = FT_Property_Set( library,
+                             "type1",
+                             "hinting-engine",
+                             &new_type1_hinting_engine );
+
+    if ( !error )
+    {
+      *current = new_type1_hinting_engine;
+      return 1;
+    }
+
+    return 0;
+  }
+
+
+  unsigned int
+  FTDemo_Event_T1cid_Hinting_Engine_Change( FT_Library     library,
+                                            unsigned int*  current,
+                                            unsigned int   delta )
+  {
+    unsigned int  new_t1cid_hinting_engine = 0;
+
+
+    if ( delta )
+      new_t1cid_hinting_engine = ( *current          +
+                                   delta             +
+                                   N_HINTING_ENGINES ) % N_HINTING_ENGINES;
+
+    error = FT_Property_Set( library,
+                             "t1cid",
+                             "hinting-engine",
+                             &new_t1cid_hinting_engine );
+
+    if ( !error )
+    {
+      *current = new_t1cid_hinting_engine;
+      return 1;
+    }
+
+    return 0;
+  }
+
+
 /* End */
diff --git a/src/ftcommon.h b/src/ftcommon.h
index 312a5b0..f7a00b5 100644
--- a/src/ftcommon.h
+++ b/src/ftcommon.h
@@ -353,6 +353,21 @@
   FTDemo_Make_Encoding_Tag( const char*  s );
 
 
+  unsigned int
+  FTDemo_Event_Cff_Hinting_Engine_Change( FT_Library     library,
+                                          unsigned int*  current,
+                                          unsigned int   delta );
+  unsigned int
+  FTDemo_Event_Type1_Hinting_Engine_Change( FT_Library     library,
+                                            unsigned int*  current,
+                                            unsigned int   delta );
+  unsigned int
+  FTDemo_Event_T1cid_Hinting_Engine_Change( FT_Library     library,
+                                            unsigned int*  current,
+                                            unsigned int   delta );
+
+
 #endif /* FTCOMMON_H_ */
 
+
 /* End */
diff --git a/src/ftdiff.c b/src/ftdiff.c
index 00b1799..96ee9cb 100644
--- a/src/ftdiff.c
+++ b/src/ftdiff.c
@@ -189,6 +189,8 @@
     int            fw_index;
 
     unsigned int   cff_hinting_engine;
+    unsigned int   type1_hinting_engine;
+    unsigned int   t1cid_hinting_engine;
     unsigned int   tt_interpreter_versions[3];
     int            num_tt_interpreter_versions;
     int            tt_interpreter_version_idx;
@@ -235,6 +237,8 @@
                      FT_Library   library )
   {
     FT_UInt  cff_hinting_engine;
+    FT_UInt  type1_hinting_engine;
+    FT_UInt  t1cid_hinting_engine;
     FT_Bool  warping;
 
     unsigned int  tt_interpreter_versions[3]  = { 0, 0, 0 };
@@ -264,6 +268,12 @@
     FT_Property_Get( library,
                      "cff",
                      "hinting-engine", &cff_hinting_engine );
+    FT_Property_Get( library,
+                     "type1",
+                     "hinting-engine", &type1_hinting_engine );
+    FT_Property_Get( library,
+                     "t1cid",
+                     "hinting-engine", &t1cid_hinting_engine );
 
     /* collect all available versions, then set again the default */
     FT_Property_Get( library,
@@ -294,6 +304,8 @@
     state->columns[0].lcd_filter             = FT_LCD_FILTER_DEFAULT;
     state->columns[0].hint_mode              = HINT_MODE_BYTECODE;
     state->columns[0].cff_hinting_engine     = cff_hinting_engine;
+    state->columns[0].type1_hinting_engine   = type1_hinting_engine;
+    state->columns[0].t1cid_hinting_engine   = t1cid_hinting_engine;
 
     state->columns[0].tt_interpreter_versions[0] =
       tt_interpreter_versions[0];
@@ -579,6 +591,15 @@
                      "hinting-engine",
                      &column->cff_hinting_engine );
     FT_Property_Set( state->library,
+                     "type1",
+                     "hinting-engine",
+                     &column->type1_hinting_engine );
+    FT_Property_Set( state->library,
+                     "t1cid",
+                     "hinting-engine",
+                     &column->t1cid_hinting_engine );
+
+    FT_Property_Set( state->library,
                      "truetype",
                      "interpreter-version",
                      &column->tt_interpreter_versions
@@ -814,6 +835,32 @@
           }
         }
 
+        else if ( !strcmp( module->clazz->module_name, "type1" ) )
+        {
+          switch ( column->type1_hinting_engine )
+          {
+          case FT_HINTING_FREETYPE:
+            extra = " (T1 FT)";
+            break;
+          case FT_HINTING_ADOBE:
+            extra = " (T1 Adobe)";
+            break;
+          }
+        }
+
+        else if ( !strcmp( module->clazz->module_name, "t1cid" ) )
+        {
+          switch ( column->t1cid_hinting_engine )
+          {
+          case FT_HINTING_FREETYPE:
+            extra = " (CID FT)";
+            break;
+          case FT_HINTING_ADOBE:
+            extra = " (CID Adobe)";
+            break;
+          }
+        }
+
         else if ( !strcmp( module->clazz->module_name, "truetype" ) )
         {
           switch ( column->tt_interpreter_versions[
@@ -1275,18 +1322,24 @@
         {
           if ( !strcmp( module->clazz->module_name, "cff" ) )
           {
-            FT_UInt  new_cff_hinting_engine;
-
-
-            new_cff_hinting_engine =
-              ( column->cff_hinting_engine + 1 ) % HINTING_ENGINE_MAX;
-
-            error = FT_Property_Set( state->library,
-                                     "cff",
-                                     "hinting-engine",
-                                     &new_cff_hinting_engine );
-            if ( !error )
-              column->cff_hinting_engine = new_cff_hinting_engine;
+            FTDemo_Event_Cff_Hinting_Engine_Change(
+              state->library,
+              &column->cff_hinting_engine,
+              1 );
+          }
+          else if ( !strcmp( module->clazz->module_name, "type1" ) )
+          {
+            FTDemo_Event_Type1_Hinting_Engine_Change(
+              state->library,
+              &column->type1_hinting_engine,
+              1 );
+          }
+          else if ( !strcmp( module->clazz->module_name, "t1cid" ) )
+          {
+            FTDemo_Event_T1cid_Hinting_Engine_Change(
+              state->library,
+              &column->t1cid_hinting_engine,
+              1 );
           }
           else if ( !strcmp( module->clazz->module_name, "truetype" ) )
           {
diff --git a/src/ftgrid.c b/src/ftgrid.c
index 29cdbaf..19ea56f 100644
--- a/src/ftgrid.c
+++ b/src/ftgrid.c
@@ -140,6 +140,8 @@
     FT_Stroker   stroker;
 
     unsigned int cff_hinting_engine;
+    unsigned int type1_hinting_engine;
+    unsigned int t1cid_hinting_engine;
     unsigned int tt_interpreter_versions[3];
     int          num_tt_interpreter_versions;
     int          tt_interpreter_version_idx;
@@ -1211,41 +1213,6 @@
 
 
   static void
-  event_cff_hinting_engine_change( int  delta )
-  {
-    int  new_cff_hinting_engine = 0;
-
-
-    if ( delta )
-      new_cff_hinting_engine =
-        ( (int)status.cff_hinting_engine +
-          delta                          +
-          N_HINTING_ENGINES              ) % N_HINTING_ENGINES;
-
-    error = FT_Property_Set( handle->library,
-                             "cff",
-                             "hinting-engine",
-                             &new_cff_hinting_engine );
-
-    if ( !error )
-    {
-      /* Resetting the cache is perhaps a bit harsh, but I'm too  */
-      /* lazy to walk over all loaded fonts to check whether they */
-      /* are of type CFF, then unloading them explicitly.         */
-      FTC_Manager_Reset( handle->cache_manager );
-      status.cff_hinting_engine = (FT_UInt)new_cff_hinting_engine;
-      event_font_change( 0 );
-    }
-
-    sprintf( status.header_buffer, "CFF engine changed to %s",
-             status.cff_hinting_engine == FT_HINTING_FREETYPE
-               ? "FreeType" : "Adobe" );
-
-    status.header = (const char *)status.header_buffer;
-  }
-
-
-  static void
   event_tt_interpreter_version_change( void )
   {
     status.tt_interpreter_version_idx += 1;
@@ -1676,7 +1643,65 @@
           module = &face->driver->root;
 
           if ( !strcmp( module->clazz->module_name, "cff" ) )
-            event_cff_hinting_engine_change( 1 );
+          {
+            if ( FTDemo_Event_Cff_Hinting_Engine_Change(
+                   handle->library,
+                   &status.cff_hinting_engine,
+                   1 ) )
+            {
+              /* Resetting the cache is perhaps a bit harsh, but I'm too  */
+              /* lazy to walk over all loaded fonts to check whether they */
+              /* are of type CFF, then unloading them explicitly.         */
+              FTC_Manager_Reset( handle->cache_manager );
+              event_font_change( 0 );
+            }
+
+            sprintf( status.header_buffer, "CFF engine changed to %s",
+                     status.cff_hinting_engine == FT_HINTING_FREETYPE
+                       ? "FreeType" : "Adobe" );
+
+            status.header = (const char *)status.header_buffer;
+          }
+          else if ( !strcmp( module->clazz->module_name, "type1" ) )
+          {
+            if ( FTDemo_Event_Type1_Hinting_Engine_Change(
+                   handle->library,
+                   &status.type1_hinting_engine,
+                   1 ) )
+            {
+              /* Resetting the cache is perhaps a bit harsh, but I'm too  */
+              /* lazy to walk over all loaded fonts to check whether they */
+              /* are of type Type1, then unloading them explicitly.       */
+              FTC_Manager_Reset( handle->cache_manager );
+              event_font_change( 0 );
+            }
+
+            sprintf( status.header_buffer, "Type 1 engine changed to %s",
+                     status.type1_hinting_engine == FT_HINTING_FREETYPE
+                       ? "FreeType" : "Adobe" );
+
+            status.header = (const char *)status.header_buffer;
+          }
+          else if ( !strcmp( module->clazz->module_name, "t1cid" ) )
+          {
+            if ( FTDemo_Event_T1cid_Hinting_Engine_Change(
+                   handle->library,
+                   &status.t1cid_hinting_engine,
+                   1 ) )
+            {
+              /* Resetting the cache is perhaps a bit harsh, but I'm too  */
+              /* lazy to walk over all loaded fonts to check whether they */
+              /* are of type CID, then unloading them explicitly.         */
+              FTC_Manager_Reset( handle->cache_manager );
+              event_font_change( 0 );
+            }
+
+            sprintf( status.header_buffer, "CID engine changed to %s",
+                     status.t1cid_hinting_engine == FT_HINTING_FREETYPE
+                       ? "FreeType" : "Adobe" );
+
+            status.header = (const char *)status.header_buffer;
+          }
           else if ( !strcmp( module->clazz->module_name, "truetype" ) )
             event_tt_interpreter_version_change();
         }
@@ -1984,6 +2009,13 @@
     FT_Property_Get( handle->library,
                      "cff",
                      "hinting-engine", &status.cff_hinting_engine );
+    FT_Property_Get( handle->library,
+                     "type1",
+                     "hinting-engine", &status.type1_hinting_engine );
+    FT_Property_Get( handle->library,
+                     "t1cid",
+                     "hinting-engine", &status.t1cid_hinting_engine );
+
 
     /* collect all available versions, then set again the default */
     FT_Property_Get( handle->library,
diff --git a/src/ftmulti.c b/src/ftmulti.c
index 351cfd5..e6f9309 100644
--- a/src/ftmulti.c
+++ b/src/ftmulti.c
@@ -38,6 +38,20 @@
 
 #define N_HINTING_ENGINES  2
 
+  /* definitions in ftcommon.c */
+  unsigned int
+  FTDemo_Event_Cff_Hinting_Engine_Change( FT_Library     library,
+                                          unsigned int*  current,
+                                          unsigned int   delta );
+  unsigned int
+  FTDemo_Event_Type1_Hinting_Engine_Change( FT_Library     library,
+                                            unsigned int*  current,
+                                            unsigned int   delta );
+  unsigned int
+  FTDemo_Event_T1cid_Hinting_Engine_Change( FT_Library     library,
+                                            unsigned int*  current,
+                                            unsigned int   delta );
+
 
   static char   Header[256];
   static char*  new_header = NULL;
@@ -56,6 +70,8 @@
   static unsigned long  encoding = FT_ENCODING_NONE;
 
   static unsigned int  cff_hinting_engine;
+  static unsigned int  type1_hinting_engine;
+  static unsigned int  t1cid_hinting_engine;
   static unsigned int  tt_interpreter_versions[3];
   static unsigned int  num_tt_interpreter_versions;
   static unsigned int  tt_interpreter_version_idx;
@@ -465,27 +481,6 @@
 
 
   static void
-  cff_hinting_engine_change( int  delta )
-  {
-    int  new_cff_hinting_engine = 0;
-
-
-    if ( delta )
-      new_cff_hinting_engine =
-        ( (int)cff_hinting_engine +
-          delta                   +
-          N_HINTING_ENGINES       ) % N_HINTING_ENGINES;
-
-    error = FT_Property_Set( library,
-                             "cff",
-                             "hinting-engine",
-                             &new_cff_hinting_engine );
-    if ( !error )
-      cff_hinting_engine = (FT_UInt)new_cff_hinting_engine;
-  }
-
-
-  static void
   tt_interpreter_version_change( void )
   {
     tt_interpreter_version_idx += 1;
@@ -548,7 +543,17 @@
 
     case grKEY( 'H' ):
       if ( !strcmp( font_format, "CFF" ) )
-        cff_hinting_engine_change( 1 );
+        FTDemo_Event_Cff_Hinting_Engine_Change( library,
+                                                &cff_hinting_engine,
+                                                1);
+      else if ( !strcmp( font_format, "Type 1" ) )
+        FTDemo_Event_Type1_Hinting_Engine_Change( library,
+                                                  &type1_hinting_engine,
+                                                  1);
+      else if ( !strcmp( font_format, "CID Type 1" ) )
+        FTDemo_Event_T1cid_Hinting_Engine_Change( library,
+                                                  &t1cid_hinting_engine,
+                                                  1);
       else if ( !strcmp( font_format, "TrueType" ) )
         tt_interpreter_version_change();
       break;
@@ -806,6 +811,12 @@
     FT_Property_Get( library,
                      "cff",
                      "hinting-engine", &cff_hinting_engine );
+    FT_Property_Get( library,
+                     "type1",
+                     "hinting-engine", &type1_hinting_engine );
+    FT_Property_Get( library,
+                     "t1cid",
+                     "hinting-engine", &t1cid_hinting_engine );
 
     /* collect all available versions, then set again the default */
     FT_Property_Get( library,
@@ -1069,19 +1080,31 @@
           unsigned int  tt_ver = tt_interpreter_versions[
                                    tt_interpreter_version_idx];
 
+          const char*  format_str = NULL;
+
+          if ( !strcmp( font_format, "CFF" ) )
+            format_str = ( cff_hinting_engine == FT_HINTING_FREETYPE
+                         ? "CFF (FreeType)"
+                         : "CFF (Adobe)" );
+          else if ( !strcmp( font_format, "Type 1" ) )
+            format_str = ( type1_hinting_engine == FT_HINTING_FREETYPE
+                         ? "Type 1 (FreeType)"
+                         : "Type 1 (Adobe)" );
+          else if ( !strcmp( font_format, "CID Type 1" ) )
+            format_str = ( t1cid_hinting_engine == FT_HINTING_FREETYPE
+                         ? "CID Type 1 (FreeType)"
+                         : "CID Type 1 (Adobe)" );
+          else if ( !strcmp( font_format, "TrueType" ) )
+            format_str = ( tt_ver == TT_INTERPRETER_VERSION_35
+                                   ? "TrueType (v35)"
+                                   : ( tt_ver == TT_INTERPRETER_VERSION_38
+                                       ? "TrueType (v38)"
+                                       : "TrueType (v40)" ) );
 
           sprintf( Header, "at %d points, first glyph = %d, format = %s",
                            ptsize,
                            Num,
-                           strcmp( font_format, "CFF" )
-                             ? ( tt_ver == TT_INTERPRETER_VERSION_35
-                                   ? "TrueType (v35)"
-                                   : ( tt_ver == TT_INTERPRETER_VERSION_38
-                                       ? "TrueType (v38)"
-                                       : "TrueType (v40)" ) )
-                             : ( cff_hinting_engine == FT_HINTING_FREETYPE
-                                   ? "CFF (FreeType)"
-                                   : "CFF (Adobe)" ) );
+                           format_str );
         }
       }
       else
diff --git a/src/ftview.c b/src/ftview.c
index 9b94d7b..d6cd8f9 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -769,99 +769,6 @@
 
 
   static int
-  event_cff_hinting_engine_change( unsigned int  delta )
-  {
-    unsigned int  new_cff_hinting_engine = 0;
-
-
-    if ( delta )
-      new_cff_hinting_engine =
-        ( status.cff_hinting_engine +
-          delta                     +
-          N_HINTING_ENGINES         ) % N_HINTING_ENGINES;
-
-    error = FT_Property_Set( handle->library,
-                             "cff",
-                             "hinting-engine",
-                             &new_cff_hinting_engine );
-
-    if ( !error )
-    {
-      /* Resetting the cache is perhaps a bit harsh, but I'm too  */
-      /* lazy to walk over all loaded fonts to check whether they */
-      /* are of type CFF, then unloading them explicitly.         */
-      FTC_Manager_Reset( handle->cache_manager );
-      status.cff_hinting_engine = new_cff_hinting_engine;
-      return 1;
-    }
-
-    return 0;
-  }
-
-
-  static int
-  event_type1_hinting_engine_change( unsigned int  delta )
-  {
-    unsigned int  new_type1_hinting_engine = 0;
-
-
-    if ( delta )
-      new_type1_hinting_engine =
-        ( status.type1_hinting_engine +
-          delta                       +
-          N_HINTING_ENGINES           ) % N_HINTING_ENGINES;
-
-    error = FT_Property_Set( handle->library,
-                             "type1",
-                             "hinting-engine",
-                             &new_type1_hinting_engine );
-
-    if ( !error )
-    {
-      /* Resetting the cache is perhaps a bit harsh, but I'm too  */
-      /* lazy to walk over all loaded fonts to check whether they */
-      /* are of type Type1, then unloading them explicitly.       */
-      FTC_Manager_Reset( handle->cache_manager );
-      status.type1_hinting_engine = new_type1_hinting_engine;
-      return 1;
-    }
-
-    return 0;
-  }
-
-
-  static int
-  event_t1cid_hinting_engine_change( unsigned int  delta )
-  {
-    unsigned int  new_t1cid_hinting_engine = 0;
-
-
-    if ( delta )
-      new_t1cid_hinting_engine =
-        ( status.t1cid_hinting_engine +
-          delta                       +
-          N_HINTING_ENGINES           ) % N_HINTING_ENGINES;
-
-    error = FT_Property_Set( handle->library,
-                             "t1cid",
-                             "hinting-engine",
-                             &new_t1cid_hinting_engine );
-
-    if ( !error )
-    {
-      /* Resetting the cache is perhaps a bit harsh, but I'm too  */
-      /* lazy to walk over all loaded fonts to check whether they */
-      /* are of type t1cid, then unloading them explicitly.       */
-      FTC_Manager_Reset( handle->cache_manager );
-      status.t1cid_hinting_engine = new_t1cid_hinting_engine;
-      return 1;
-    }
-
-    return 0;
-  }
-
-
-  static int
   event_tt_interpreter_version_change( void )
   {
     status.tt_interpreter_version_idx += 1;
@@ -874,13 +781,7 @@
                                status.tt_interpreter_version_idx] );
 
     if ( !error )
-    {
-      /* Resetting the cache is perhaps a bit harsh, but I'm too  */
-      /* lazy to walk over all loaded fonts to check whether they */
-      /* are of type TTF, then unloading them explicitly.         */
-      FTC_Manager_Reset( handle->cache_manager );
       return 1;
-    }
 
     return 0;
   }
@@ -1204,13 +1105,30 @@
           module = &face->driver->root;
 
           if ( !strcmp( module->clazz->module_name, "cff" ) )
-            status.update = event_cff_hinting_engine_change( 1 );
+            status.update = FTDemo_Event_Cff_Hinting_Engine_Change(
+                              handle->library,
+                              &status.cff_hinting_engine,
+                              1 );
           else if ( !strcmp( module->clazz->module_name, "type1" ) )
-            status.update = event_type1_hinting_engine_change( 1 );
+            status.update = FTDemo_Event_Type1_Hinting_Engine_Change(
+                              handle->library,
+                              &status.type1_hinting_engine,
+                              1 );
           else if ( !strcmp( module->clazz->module_name, "t1cid" ) )
-            status.update = event_t1cid_hinting_engine_change( 1 );
+            status.update = FTDemo_Event_T1cid_Hinting_Engine_Change(
+                              handle->library,
+                              &status.t1cid_hinting_engine,
+                              1 );
           else if ( !strcmp( module->clazz->module_name, "truetype" ) )
             status.update = event_tt_interpreter_version_change();
+
+          if ( status.update )
+          {
+            /* Resetting the cache is perhaps a bit harsh, but I'm too  */
+            /* lazy to walk over all loaded fonts to check whether they */
+            /* are of type TTF, then unloading them explicitly.         */
+            FTC_Manager_Reset( handle->cache_manager );
+          }
         }
       }
       break;



reply via email to

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