freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master 2cb4983: * src/ftcommon.c (FTDemo_Get_Index): H


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master 2cb4983: * src/ftcommon.c (FTDemo_Get_Index): Handle `FT_ENCODING_ORDER'.
Date: Sat, 30 Jun 2018 22:19:14 -0400 (EDT)

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

    * src/ftcommon.c (FTDemo_Get_Index): Handle `FT_ENCODING_ORDER'.
    
    * src/ftcommon.c (FTDemo_Draw_Header, FTDemo_String_Set),
    src/ftview.c (Render_{All,Stroke,Fancy}),
    src/ftgrid.c (grid_status_draw_outline): Simplified accordingly.
---
 ChangeLog      |  9 +++++++++
 src/ftcommon.c | 32 +++++++++++++-------------------
 src/ftgrid.c   |  5 +----
 src/ftview.c   | 16 +++-------------
 4 files changed, 26 insertions(+), 36 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6210e43..c9aad6f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,19 @@
 2018-06-28  Alexei Podtelezhnikov  <address@hidden>
 
+       * src/ftcommon.c (FTDemo_Get_Index): Handle `FT_ENCODING_ORDER'.
+
+       * src/ftcommon.c (FTDemo_Draw_Header, FTDemo_String_Set),
+       src/ftview.c (Render_{All,Stroke,Fancy}),
+       src/ftgrid.c (grid_status_draw_outline): Simplified accordingly.
+
+2018-06-28  Alexei Podtelezhnikov  <address@hidden>
+
        [ftstring] Ditch gamma ramp.
 
        * src/ftstring.c (status): `gamma_ramp' removed.
        (gamma_ramp_draw): Remove.
        (event_gamma_change): Remove setting `gamma_ramp'.
+
        * src/ftstring.1: Mention stress test glyphs.
 
 2018-06-28  Alexei Podtelezhnikov  <address@hidden>
diff --git a/src/ftcommon.c b/src/ftcommon.c
index cb0b212..c360012 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -733,12 +733,17 @@
   FTDemo_Get_Index( FTDemo_Handle*  handle,
                     FT_UInt32       charcode )
   {
-    FTC_FaceID  face_id = handle->scaler.face_id;
-    PFont       font    = handle->current_font;
+    if ( handle->encoding != FT_ENCODING_ORDER )
+    {
+      FTC_FaceID  face_id = handle->scaler.face_id;
+      PFont       font    = handle->current_font;
 
 
-    return FTC_CMapCache_Lookup( handle->cmap_cache, face_id,
-                                 font->cmap_index, charcode );
+      return FTC_CMapCache_Lookup( handle->cmap_cache, face_id,
+                                   font->cmap_index, charcode );
+    }
+    else
+      return (FT_UInt)charcode;
   }
 
 
@@ -849,6 +854,7 @@
     if ( idx >= 0 )
     {
       const char*  encoding = NULL;
+      FT_UInt      glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)idx );
 
 
       switch ( handle->encoding )
@@ -904,24 +910,15 @@
                           encoding, idx );
       else if ( handle->encoding == FT_ENCODING_UNICODE )
         x = sprintf( buf, "%s charcode: U+%04X (glyph idx %d)",
-                          encoding, idx,
-                          FTDemo_Get_Index( handle, (FT_UInt32)idx ) );
+                          encoding, idx, glyph_idx );
       else
         x = sprintf( buf, "%s charcode: 0x%X (glyph idx %d)",
-                          encoding, idx,
-                          FTDemo_Get_Index( handle, (FT_UInt32)idx ) );
+                          encoding, idx, glyph_idx );
 
       if ( FT_HAS_GLYPH_NAMES( face ) )
       {
-        unsigned int  glyph_idx;
-
-
         x += sprintf( buf + x, ", name: " );
 
-        glyph_idx = (unsigned int)idx;
-        if ( handle->encoding != FT_ENCODING_ORDER )
-          glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)idx );
-
         FT_Get_Glyph_Name( face, glyph_idx, buf + x, (FT_UInt)( 256 - x ) );
       }
 
@@ -1314,10 +1311,7 @@
 
       codepoint = (unsigned long)ch;
 
-      if ( handle->encoding != FT_ENCODING_ORDER )
-        glyph->glyph_index = FTDemo_Get_Index( handle, codepoint );
-      else
-        glyph->glyph_index = codepoint;
+      glyph->glyph_index = FTDemo_Get_Index( handle, codepoint );
 
       glyph++;
       handle->string_length++;
diff --git a/src/ftgrid.c b/src/ftgrid.c
index c8b00e0..b998939 100644
--- a/src/ftgrid.c
+++ b/src/ftgrid.c
@@ -579,10 +579,7 @@
     if ( err )
       return;
 
-    if ( handle->encoding == FT_ENCODING_ORDER )
-      glyph_idx = (FT_UInt)st->Num;
-    else
-      glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)st->Num );
+    glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)st->Num );
 
 #ifdef FT_DEBUG_AUTOFIT
     _af_debug_disable_horz_hints = !st->do_horz_hints;
diff --git a/src/ftview.c b/src/ftview.c
index c248ee9..c3682e1 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -212,10 +212,7 @@
       FT_UInt  glyph_idx;
 
 
-      if ( handle->encoding == FT_ENCODING_ORDER )
-        glyph_idx = (FT_UInt)i;
-      else
-        glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)i );
+      glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)i );
 
       error = FT_Load_Glyph( face, glyph_idx,
                              handle->load_flags | FT_LOAD_NO_BITMAP );
@@ -325,10 +322,7 @@
       FT_UInt  glyph_idx;
 
 
-      if ( handle->encoding == FT_ENCODING_ORDER )
-        glyph_idx = (FT_UInt)i;
-      else
-        glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)i );
+      glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)i );
 
       error = FT_Load_Glyph( face, glyph_idx, handle->load_flags );
       if ( error )
@@ -445,10 +439,7 @@
       FT_UInt  layer_color_idx;
 
 
-      if ( handle->encoding == FT_ENCODING_ORDER )
-        glyph_idx = (FT_UInt)i;
-      else
-        glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)i );
+      glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)i );
 
       /* check whether we have glyph color layers */
       iterator.p       = NULL;
@@ -1016,7 +1007,6 @@
   event_encoding_change( void )
   {
     PFont    font = handle->current_font;
-    FT_Face  face;
 
 
     if ( handle->encoding != FT_ENCODING_ORDER )



reply via email to

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