freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master ce9e491: [ftview] Clean up charmap handling.


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master ce9e491: [ftview] Clean up charmap handling.
Date: Sat, 3 Jun 2017 22:51:30 -0400 (EDT)

branch: master
commit ce9e4918575c1e1fc21d84c47550c253db521148
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>

    [ftview] Clean up charmap handling.
    
    * src/ftcommon.h (FT_ENCODING_ORDER): Introduce this special encoding
    for glyph order because `FT_ENCODING_NONE' has other meanings.
    * src/ftcommon.c (FTDemo_Install_Font): Fall back to
    `FT_ENCODING_ORDER' if encoding is not recognized.
    (FTDemo_Draw_Header): Updated.
    
    * src/ftview.c (status): Remove redundant `encoding' field and update
    all references.
    (FT_ENCODING_OTHER): Removed in favor of `FT_ENCODING_NONE'.
---
 ChangeLog      | 14 ++++++++++++++
 src/ftcommon.c | 19 ++++++++-----------
 src/ftcommon.h |  3 +++
 src/ftview.c   | 32 +++++++++++---------------------
 4 files changed, 36 insertions(+), 32 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d4f0744..48e7ab6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2017-06-03  Alexei Podtelezhnikov  <address@hidden>
+
+       [ftview] Clean up charmap handling.
+
+       * src/ftcommon.h (FT_ENCODING_ORDER): Introduce this special encoding
+       for glyph order because `FT_ENCODING_NONE' has other meanings.
+       * src/ftcommon.c (FTDemo_Install_Font): Fall back to
+       `FT_ENCODING_ORDER' if encoding is not recognized.
+       (FTDemo_Draw_Header): Updated.
+
+       * src/ftview.c (status): Remove redundant `encoding' field and update
+       all references.
+       (FT_ENCODING_OTHER): Removed in favor of `FT_ENCODING_NONE'.
+
 2017-06-01  Alexei Podtelezhnikov  <address@hidden>
 
        [ftgrid, ftstring, ftview] Further top header consolidation.
diff --git a/src/ftcommon.c b/src/ftcommon.c
index 82ace86..20072a5 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -296,7 +296,7 @@
 
     FT_Stroker_New( handle->library, &handle->stroker );
 
-    handle->encoding = FT_ENCODING_NONE;
+    handle->encoding = FT_ENCODING_ORDER;
 
     handle->hinted    = 1;
     handle->use_sbits = 1;
@@ -415,14 +415,11 @@
           continue;
         }
 
-        if ( handle->encoding != FT_ENCODING_NONE )
+        if ( handle->encoding != FT_ENCODING_ORDER )
         {
           error = FT_Select_Charmap( face, (FT_Encoding)handle->encoding );
           if ( error )
-          {
-            FT_Done_Face( face );
-            continue;
-          }
+            handle->encoding = FT_ENCODING_ORDER;
         }
 
         font = (PFont)malloc( sizeof ( *font ) );
@@ -488,7 +485,7 @@
 
         switch ( handle->encoding )
         {
-        case FT_ENCODING_NONE:
+        case FT_ENCODING_ORDER:
           font->num_indices = face->num_glyphs;
           break;
 
@@ -834,7 +831,7 @@
 
       switch ( handle->encoding )
       {
-      case FT_ENCODING_NONE:
+      case FT_ENCODING_ORDER:
         encoding = "glyph order";
         break;
       case FT_ENCODING_MS_SYMBOL:
@@ -880,7 +877,7 @@
         encoding = "Other";
       }
 
-      if ( handle->encoding == FT_ENCODING_NONE )
+      if ( handle->encoding == FT_ENCODING_ORDER )
         x = sprintf( buf, "%s idx: %d",
                           encoding, idx );
       else if ( handle->encoding == FT_ENCODING_UNICODE )
@@ -907,7 +904,7 @@
         if ( x >= format_len + 2 )
         {
           glyph_idx = (unsigned int)idx;
-          if ( handle->encoding != FT_ENCODING_NONE )
+          if ( handle->encoding != FT_ENCODING_ORDER )
             glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)idx );
 
           strcpy( p, format );
@@ -1312,7 +1309,7 @@
 
       codepoint = (unsigned long)ch;
 
-      if ( handle->encoding != FT_ENCODING_NONE )
+      if ( handle->encoding != FT_ENCODING_ORDER )
         glyph->glyph_index = FTDemo_Get_Index( handle, codepoint );
       else
         glyph->glyph_index = codepoint;
diff --git a/src/ftcommon.h b/src/ftcommon.h
index b2f4522..72008aa 100644
--- a/src/ftcommon.h
+++ b/src/ftcommon.h
@@ -68,6 +68,9 @@
   /* default gamma setting */
 #define GAMMA  1.8
 
+  /* special encoding to display glyphs in order */
+#define FT_ENCODING_ORDER  0xFFFF
+
 #include "graph.h"
 #include "grobjs.h"
 #include "grfont.h"
diff --git a/src/ftview.c b/src/ftview.c
index aba047e..28b148d 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -103,7 +103,6 @@
     int            width;
     int            height;
     int            render_mode;
-    unsigned long  encoding;
 
     int            res;
     int            ptsize;            /* current point size, 26.6 format */
@@ -130,7 +129,7 @@
     int            fw_idx;
 
   } status = { 1,
-               DIM_X, DIM_Y, RENDER_MODE_ALL, FT_ENCODING_NONE,
+               DIM_X, DIM_Y, RENDER_MODE_ALL,
                72, 48, 1, 0.04, 0.04, 0.02, 0.22,
                0, { 0 }, 0, 0, 0, /* default values are set at runtime */
                0, 0, 0, 0, 0,
@@ -140,8 +139,6 @@
   static FTDemo_Display*  display;
   static FTDemo_Handle*   handle;
 
-  static unsigned long  FT_ENC_TAG( FT_ENCODING_OTHER, 'o', 't', 'h', 'e' );
-
 
   /*
      In UTF-8 encoding:
@@ -216,7 +213,7 @@
       FT_UInt  glyph_idx;
 
 
-      if ( status.encoding == FT_ENCODING_NONE )
+      if ( handle->encoding == FT_ENCODING_ORDER )
         glyph_idx = (FT_UInt)i;
       else
         glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)i );
@@ -327,7 +324,7 @@
       FT_UInt  glyph_idx;
 
 
-      if ( status.encoding == FT_ENCODING_NONE )
+      if ( handle->encoding == FT_ENCODING_ORDER )
         glyph_idx = (FT_UInt)i;
       else
         glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)i );
@@ -438,7 +435,7 @@
       FT_UInt  glyph_idx;
 
 
-      if ( status.encoding == FT_ENCODING_NONE )
+      if ( handle->encoding == FT_ENCODING_ORDER )
         glyph_idx = (FT_UInt)i;
       else
         glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)i );
@@ -979,7 +976,7 @@
     FT_Face  face;
 
 
-    if ( status.encoding != FT_ENCODING_NONE )
+    if ( handle->encoding != FT_ENCODING_ORDER )
       font->cmap_index++;
     else
       font->cmap_index = 0;
@@ -989,21 +986,18 @@
 
     if ( font->cmap_index < face->num_charmaps )
     {
-      status.encoding  = face->charmaps[font->cmap_index]->encoding;
+      handle->encoding = face->charmaps[font->cmap_index]->encoding;
       status.offset    = 0x20;
-
-      if ( status.encoding == FT_ENCODING_NONE )  /* OTHER, really */
-        status.encoding = FT_ENCODING_OTHER;
     }
     else
     {
-      status.encoding  = FT_ENCODING_NONE;
+      handle->encoding = FT_ENCODING_ORDER;
       status.offset    = 0;
     }
 
-    switch ( status.encoding )
+    switch ( handle->encoding )
     {
-    case FT_ENCODING_NONE:
+    case FT_ENCODING_ORDER:
       font->num_indices = face->num_glyphs;
       break;
 
@@ -1025,8 +1019,6 @@
       font->num_indices = 0x10000L;
     }
 
-    handle->encoding = status.encoding;
-
     return 1;
   }
 
@@ -1678,11 +1670,11 @@
       switch ( option )
       {
       case 'e':
-        status.encoding = FTDemo_Make_Encoding_Tag( optarg );
+        handle->encoding = FTDemo_Make_Encoding_Tag( optarg );
         break;
 
       case 'f':
-        status.offset  = atoi( optarg );
+        status.offset = atoi( optarg );
         break;
 
       case 'h':
@@ -1805,8 +1797,6 @@
                      "autofitter",
                      "warping", &status.warping );
 
-    handle->encoding = status.encoding;
-
     if ( status.preload )
       FTDemo_Set_Preload( handle, 1 );
 



reply via email to

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