freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] parthw-wip d959c10 1/6: [tfm] Define tfm_cmap_class function


From: Parth Wazurkar
Subject: [freetype2] parthw-wip d959c10 1/6: [tfm] Define tfm_cmap_class functions.
Date: Fri, 29 Jun 2018 08:59:14 -0400 (EDT)

branch: parthw-wip
commit d959c10eca9476cfb634102b92ace342ad886e8f
Author: Parth Wazurkar <address@hidden>
Commit: Parth Wazurkar <address@hidden>

    [tfm] Define tfm_cmap_class functions.
    
    * Define structure TFM_CMapRec for TeX tfm font format.
    * src/tfm/tfmdrivr.c: Define tfm_cmap_init, tfm_cmap_done,
    tfm_cmap_char_index, tfm_cmap_char_next.
---
 src/tfm/tfmdrivr.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 46 insertions(+), 5 deletions(-)

diff --git a/src/tfm/tfmdrivr.c b/src/tfm/tfmdrivr.c
index 563d01a..aa7b960 100644
--- a/src/tfm/tfmdrivr.c
+++ b/src/tfm/tfmdrivr.c
@@ -42,7 +42,8 @@
   typedef struct  TFM_CMapRec_
   {
     FT_CMapRec        cmap;
-    /* TO-DO */
+    FT_UInt32         begin_char;       /* Beginning Character */
+    FT_UInt32         end_char  ;       /* End Character */
   } TFM_CMapRec, *TFM_CMap;
 
 
@@ -50,14 +51,24 @@
   tfm_cmap_init(  FT_CMap     tfmcmap,
                   FT_Pointer  init_data )
   {
-    /* TO-DO */
+    TFM_CMap  cmap = (TFM_CMap)tfmcmap;
+    TFM_Face  face = (TFM_Face)FT_CMAP_FACE( cmap );
+    FT_UNUSED( init_data );
+
+    cmap->begin_char     = ;
+    cmap->end_char       = ;
+
+    return FT_Err_Ok;
   }
 
 
   FT_CALLBACK_DEF( void )
   tfm_cmap_done( FT_CMap  tfmcmap )
   {
-    /* TO-DO */
+    TFM_CMap  cmap = (TFM_CMap)tfmcmap;
+
+    cmap->begin_char     = ;
+    cmap->end_char       = ;
   }
 
 
@@ -65,14 +76,44 @@
   tfm_cmap_char_index(  FT_CMap    tfmcmap,
                         FT_UInt32  char_code )
   {
-    /* TO-DO */
+    FT_UInt  gindex = 0;
+    TFM_CMap  cmap   = (TFM_CMap)tfmcmap;
+
+    char_code -= cmap->begin_char;
+
+    if ( char_code < cmap->end_char - cmap->begin_char + 1 )
+      gindex = (FT_UInt)( char_code );
+
+    return gindex;
   }
 
   FT_CALLBACK_DEF( FT_UInt )
   tfm_cmap_char_next(  FT_CMap     tfmcmap,
                        FT_UInt32  *achar_code )
   {
-    /* TO-DO */
+    TFM_CMap    cmap      = (TFM_CMap)tfmcmap;
+    FT_UInt     gindex    = 0;
+    FT_UInt32   result    = 0;
+    FT_UInt32   char_code = *achar_code + 1;
+
+
+    if ( char_code <= cmap->begin_char )
+    {
+      result = cmap->bc;
+      gindex = 1;
+    }
+    else
+    {
+      char_code -= cmap->begin_char;
+      if ( char_code < cmap->end_char - cmap->begin_char + 1 )
+      {
+        result = char_code;
+        gindex = (FT_UInt)( char_code );
+      }
+    }
+
+    *achar_code = result;
+    return gindex;
   }
 
 



reply via email to

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