freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master d388735: * src/ftcommon.c (FTDemo_Get_Info): Si


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master d388735: * src/ftcommon.c (FTDemo_Get_Info): Simplify the code.
Date: Thu, 12 Nov 2020 14:17:01 -0500 (EST)

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

    * src/ftcommon.c (FTDemo_Get_Info): Simplify the code.
---
 ChangeLog      |  4 ++++
 src/ftcommon.c | 71 +++++++++++++++++++---------------------------------------
 2 files changed, 27 insertions(+), 48 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 634268a..732b5c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2020-11-12  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       * src/ftcommon.c (FTDemo_Get_Info): Simplify the code.
+
 2020-11-10  Alexei Podtelezhnikov  <apodtele@gmail.com>
 
        * src/ftmemchk.c: Remove internal dependency.
diff --git a/src/ftcommon.c b/src/ftcommon.c
index eb70b7b..f005655 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -21,7 +21,6 @@
 
   /* access driver name and properties */
 #include FT_DRIVER_H
-#include <freetype/internal/ftobjs.h>
 
 #include FT_CACHE_H
 #include FT_CACHE_MANAGER_H
@@ -1045,23 +1044,27 @@
   FTDemo_Get_Info( FTDemo_Handle*  handle,
                    StrBuf*         buf )
   {
-    FT_Library   library = handle->library;
-    FT_Face      face;
-    FT_Module    module;
-    FT_UInt      prop = 0;
-    const char*  hinting_engine = "";
-    const char*  lcd_mode;
+    FT_Library        library = handle->library;
+    FT_Face           face;
+    const FT_String*  module_name;
+    FT_UInt           prop = 0;
+    const char*       hinting_engine = "";
+    const char*       lcd_mode;
 
 
     error = FTC_Manager_LookupFace( handle->cache_manager,
                                     handle->scaler.face_id, &face );
 
-    module = &face->driver->root;
+    module_name = (*(FT_Module_Class**)(face->driver))->module_name;
+
+    if ( !FT_IS_SCALABLE( face ) )
+      hinting_engine = "bitmap";
 
-    if ( !handle->hinted )
+    else if ( !handle->hinted )
       hinting_engine = "unhinted";
 
-    else if ( handle->lcd_mode == LCD_MODE_LIGHT )
+    else if ( handle->lcd_mode == LCD_MODE_LIGHT          ||
+              handle->lcd_mode == LCD_MODE_LIGHT_SUBPIXEL )
       hinting_engine = "auto";
 
     else if ( handle->autohint )
@@ -1070,37 +1073,26 @@
       hinting_engine = prop ? "warp" : "auto";
     }
 
-    else if ( !strcmp( module->clazz->module_name, "cff" ) )
+    else if ( !FT_Property_Get( library, module_name,
+                                         "interpreter-version", &prop ) )
     {
-      FT_Property_Get( library, "cff", "hinting-engine", &prop );
       switch ( prop )
       {
-      case FT_HINTING_FREETYPE:
-        hinting_engine = "FreeType";
-        break;
-      case FT_HINTING_ADOBE:
-        hinting_engine = "Adobe";
+      case TT_INTERPRETER_VERSION_35:
+        hinting_engine = "v35";
         break;
-      }
-    }
-
-    else if ( !strcmp( module->clazz->module_name, "type1" ) )
-    {
-      FT_Property_Get( library, "type1", "hinting-engine", &prop );
-      switch ( prop )
-      {
-      case FT_HINTING_FREETYPE:
-        hinting_engine = "FreeType";
+      case TT_INTERPRETER_VERSION_38:
+        hinting_engine = "v38";
         break;
-      case FT_HINTING_ADOBE:
-        hinting_engine = "Adobe";
+      case TT_INTERPRETER_VERSION_40:
+        hinting_engine = "v40";
         break;
       }
     }
 
-    else if ( !strcmp( module->clazz->module_name, "t1cid" ) )
+    else if ( !FT_Property_Get( library, module_name,
+                                         "hinting-engine", &prop ) )
     {
-      FT_Property_Get( library, "t1cid", "hinting-engine", &prop );
       switch ( prop )
       {
       case FT_HINTING_FREETYPE:
@@ -1112,23 +1104,6 @@
       }
     }
 
-    else if ( !strcmp( module->clazz->module_name, "truetype" ) )
-    {
-      FT_Property_Get( library, "truetype", "interpreter-version", &prop );
-      switch ( prop )
-      {
-      case TT_INTERPRETER_VERSION_35:
-        hinting_engine = "v35";
-        break;
-      case TT_INTERPRETER_VERSION_38:
-        hinting_engine = "v38";
-        break;
-      case TT_INTERPRETER_VERSION_40:
-        hinting_engine = "v40";
-        break;
-      }
-    }
-
     switch ( handle->lcd_mode )
     {
     case LCD_MODE_AA:



reply via email to

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