freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] parthw-wip ec1e12b: [gf] Complete stream support and some mi


From: Parth Wazurkar
Subject: [freetype2] parthw-wip ec1e12b: [gf] Complete stream support and some minor changes for testing.
Date: Tue, 26 Jun 2018 14:03:17 -0400 (EDT)

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

    [gf] Complete stream support and some minor changes for testing.
---
 src/gf/gfdrivr.c                   |  20 ++--
 src/gf/gflib.c                     | 169 ++++++++++++++--------------
 src/gf/{gflib.c => gflib2.c}       | 219 ++++++++++++++++---------------------
 src/gf/{gflib.c => gflibstream1.c} |  41 +++----
 4 files changed, 209 insertions(+), 240 deletions(-)

diff --git a/src/gf/gfdrivr.c b/src/gf/gfdrivr.c
index a7c0d51..1d2f0ff 100644
--- a/src/gf/gfdrivr.c
+++ b/src/gf/gfdrivr.c
@@ -142,7 +142,7 @@
 
     memory = FT_FACE_MEMORY( face );
 
-    gf_free_font( face->gf_glyph );
+    gf_free_font( face->gf_glyph, memory );
 
     /* FT_FREE(  ); */
   }
@@ -167,7 +167,7 @@
     FT_TRACE2(( "GF driver\n" ));
 
     /* load font */
-    error = gf_load_font( stream, memory, &go 
);/*printf("face->gf_glyph->code_max %d",go->code_max);printf("Hi I am 
here1\n");*/
+    error = gf_load_font( stream, memory, &go 
);printf("face->gf_glyph->code_max %d",go->code_max);printf("Hi I am here1\n");
 
     if ( error )
       goto Exit;
@@ -195,14 +195,14 @@
      * XXX: TO-DO: gfface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
      * XXX: I have to check for this.
      */
-/*printf("Hi I am here2\n");*/
+printf("Hi I am here2\n");
     gfface->family_name = NULL;
     gfface->num_glyphs = (FT_Long)(go->code_max - go->code_min + 1 );
     gfface->num_fixed_sizes = 1;
-/*printf("Hi I am here3\n");*/
+printf("Hi I am here3\n");
     if ( FT_NEW_ARRAY( gfface->available_sizes, 1 ) )
       goto Exit;
-/*printf("Hi I am here4\n");*/
+printf("Hi I am here4\n");
     {
       FT_Bitmap_Size*  bsize = gfface->available_sizes;
       FT_UShort        x_res, y_res;
@@ -218,7 +218,7 @@
       bsize->y_ppem = face->gf_glyph->font_bbx_yoff ;
       bsize->x_ppem = face->gf_glyph->font_bbx_xoff ;
     }
-/*printf("Hi I am here5\n");*/
+printf("Hi I am here5\n");
 
       /* Charmaps */
 
@@ -236,14 +236,14 @@
 
       if ( error )
         goto Fail;
-            /*printf("Hi I am here completed GF_Face_Init1\n");*/
+            printf("Hi I am here completed GF_Face_Init1\n");
     }
-/*printf("Hi I am here6\n");*/
+printf("Hi I am here6\n");
   Fail:
-    GF_Face_Done( gfface );
+  /*  GF_Face_Done( gfface ); */
 
   Exit:
-/*    printf("Hi I am here completed GF_Face_Init2 
%ld\n",gfface->num_glyphs);*/
+   printf("Hi I am here completed GF_Face_Init2 %ld\n",gfface->num_glyphs);
     return error;
   }
 
diff --git a/src/gf/gflib.c b/src/gf/gflib.c
index ffcb372..fccf9e5 100644
--- a/src/gf/gflib.c
+++ b/src/gf/gflib.c
@@ -43,77 +43,68 @@
 unsigned char   bit_table[] = {
   0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
 
-  /**************************************************************************
-   *
-   * GF font utility functions.
-   *
-   */
-
   long           gf_read_intn(FT_Stream,int);
-  unsigned long  gf_read_uintn(FT_Stream,int);
   void           gf_skip_n(FT_Stream,int);
 
 #define READ_INT1( stream )          (INT1)gf_read_intn(( stream ), 1)
-#define READ_UINT1( stream )         (UINT1)gf_read_uintn(( stream ), 1)
 #define READ_INT2( stream )          (INT2)gf_read_intn(( stream ), 2)
-#define READ_UINT2( stream )         (UINT2)gf_read_uintn(( stream ), 2)
 #define READ_INT3( stream )          (INT3)gf_read_intn(( stream ), 3)
-#define READ_UINT3( stream )         (UINT3)gf_read_uintn(( stream ), 3)
 #define READ_INT4( stream )          (INT4)gf_read_intn(( stream ), 4)
-#define READ_UINT4( stream )         (UINT4)gf_read_uintn(( stream ), 4)
 #define READ_INTN( stream ,n)        (INT4)gf_read_intn(( stream ), (n))
+#define SKIP_N( stream ,k)            gf_skip_n(( stream ), (k))
 #define READ_UINTN( stream ,n)       (UINT4)gf_read_uintn(( stream ), (n))
-#define SKIP_N( stream ,k)           gf_skip_n(( stream ), (k))
-
 
 /*
  * Reading a Number from stream
  */
   unsigned long
-  gf_read_uintn(FT_Stream stream, int size)
+  READ_UINT1(FT_Stream stream)
   {
-    unsigned long  v;
-    FT_Error error = FT_Err_Ok;
-    v = 0L;
-    while (size >= 1)
-    {
-      v = v*256L + (unsigned long)FT_Stream_ReadULong(stream, &error);
-      stream->pos-=3;
-      --size;
-    }
+    unsigned long  v,k;
+    FT_Error error= FT_Err_Ok;
+    FT_Byte tp;
+    FT_READ_BYTE(tp);
+    v =(unsigned long)tp;
     return v;
   }
 
-/* Preliminary */
-  unsigned long
-  gf_read_uint4(FT_Stream stream, int size)
+  long
+  gf_read_intn(FT_Stream stream, int size)
   {
-    unsigned long  v;
-    FT_Error error = FT_Err_Ok;
-    v = 0L;
+    long           v;
+    FT_Byte tp;
+    FT_Error error= FT_Err_Ok;
+    unsigned long z ;
+    FT_READ_BYTE(tp);
+    z= (unsigned long)tp;
+    v = (long)z & 0xffL;
+    if (v & 0x80L)
+      v = v - 256L;
+    --size;
     while (size >= 1)
     {
-      v = v*256L + (unsigned long)FT_Stream_ReadULong(stream, &error);
+      FT_READ_BYTE(tp);
+      z= (unsigned long)tp;
+      v = v*256L + z;
       --size;
-    }
+               }
     return v;
   }
 
-
-  long
-  gf_read_intn(FT_Stream stream, int size)
+  unsigned long
+  gf_read_uintn(FT_Stream stream, int size)
   {
-    long           v;
+    unsigned long  v,k;
     FT_Error error = FT_Err_Ok;
-    v = (long)FT_Stream_ReadULong(stream, &error) & 0xffL;
-    if (v & 0x80L)
-      v = v - 256L;
-    --size;
+    FT_Byte tp;
+    v = 0L;
     while (size >= 1)
     {
-      v = v*256L + (unsigned long)FT_Stream_ReadULong(stream, &error);
+      FT_READ_BYTE(tp);
+      k =(unsigned long)tp;
+      v = v*256L + (unsigned long)k;
       --size;
-               }
+    }
     return v;
   }
 
@@ -157,6 +148,7 @@ unsigned char   bit_table[] = {
       max_m = READ_INT4( stream );
       min_n = READ_INT4( stream );
       max_n = READ_INT4( stream );
+
       break;
     case GF_BOC1:
       SKIP_N( stream , 1);
@@ -166,9 +158,10 @@ unsigned char   bit_table[] = {
       max_n = (INT4)READ_UINT1( stream );
       min_m = max_m - del_m;
       min_n = max_n - del_n;
+
       break;
     default:
-      goto Exit;
+      return -1;
     }
 
     w = max_m - min_m + 1;
@@ -176,13 +169,13 @@ unsigned char   bit_table[] = {
     if ((w < 0) || (h < 0))
     {
       error = FT_THROW( Invalid_File_Format );
-      goto Exit;
+      return -1;
     }
 
     if ((bm->bitmap = (unsigned char*)malloc(h*((w+7)/8))) == NULL)
     {
       error = FT_THROW( Invalid_File_Format );
-      goto Exit;
+      return -1;
     }
 
     memset(bm->bitmap, 0, h*((w+7)/8));
@@ -275,13 +268,12 @@ unsigned char   bit_table[] = {
           /* FT_FREE(bm->bitmap); */ /* Returning unnecessary errors TO BE 
CHECKED */
           bm->bitmap = NULL;
           error = FT_THROW( Invalid_File_Format );
-          goto Exit;
+          return -1;
          }
       }
     }
 
-    Exit:
-      return error;
+      return 0;
   }
 
 
@@ -298,75 +290,82 @@ unsigned char   bit_table[] = {
     INT4            w;
     UINT4           code;
     double          dx, dy;
-    long            ptr_post, ptr_p, ptr, optr, gptr,tp;
+    long            ptr_post, ptr_p, ptr, optr, gptr;
     int             bc, ec, nchars, i;
-    FT_Error        error  = FT_Err_Ok;
+    FT_Error        error  = FT_Err_Ok, error1;
     FT_Memory       memory = extmemory; /* needed for FT_NEW */
     FT_ULong        offset;
+    FT_Byte tp;
 
     go = NULL;
     nchars = -1;
-printf("\nHi I am here in gf_load_font -1\n\n");
+
     /* seek to post_post instr. */
     /* fseek(fp, -5, SEEK_END); */
-    FT_STREAM_SEEK( stream->size - 5 );
+    FT_STREAM_SEEK( stream->size - 1 );
+
 
-printf("\nHi I am here in gf_load_font 0\n\n");
-    while ((d = READ_UINT1( stream )) == 223)
+    while ( d= READ_UINT1( stream ) == 223)
     {
       FT_STREAM_SEEK( stream->pos -2 );
+
       /* fseek(fp, -2, SEEK_CUR); */
     }
+    FT_STREAM_SEEK( stream->pos -1 );
+    d= READ_UINT1( stream );
 
-printf("\nHi I am here in gf_load_font 1\n\n");
     if (d != GF_ID)
     {
       error = FT_THROW( Invalid_File_Format );
       goto ErrExit;
     }
 
-printf("\nHi I am here in gf_load_font 2\n\n");
+
     /* fseek(fp, -6, SEEK_CUR); */
     FT_STREAM_SEEK( stream->pos -6 );
 
-printf("\nHi I am here in gf_load_font 3\n\n");
+
     /* check if the code is post_post */
+
     if (READ_UINT1( stream ) != GF_POST_POST)
     {
       error = FT_THROW( Invalid_File_Format );
       goto ErrExit;
     }
 
-printf("\nHi I am here in gf_load_font 4\n\n");
+
     /* read pointer to post instr. */
-    if ((ptr_post = gf_read_uint4( stream,4 )) == -1)
+    FT_READ_ULONG( ptr_post );
+    if (ptr_post == -1)
     {
       error = FT_THROW( Invalid_File_Format );
       goto ErrExit;
     }
 
-printf("\nHi I am here in gf_load_font 5\n\n");
+
     /* goto post instr. and read it */
     /* fseek(fp, ptr_post, SEEK_SET); */
     FT_STREAM_SEEK( ptr_post );
 
-    if (d=READ_UINT1( stream ) != GF_POST)
+
+
+    if (READ_UINT1( stream ) != GF_POST)
     {
       error = FT_THROW( Invalid_File_Format );
       goto ErrExit;
     }
 
-printf("\nHi I am here in gf_load_font 6\n\n");
-    ptr_p     = READ_UINT4( stream );
-    ds        = READ_UINT4( stream );
-    check_sum = READ_UINT4( stream );
-    hppp      = READ_UINT4( stream );
-    vppp      = READ_UINT4( stream );
+
+    FT_READ_ULONG( ptr_p )    ;
+    FT_READ_ULONG( ds )       ;
+    FT_READ_ULONG( check_sum );
+    FT_READ_ULONG( hppp )     ;
+    FT_READ_ULONG( vppp )     ;
     min_m     = READ_INT4( stream );
     max_m     = READ_INT4( stream );
     min_n     = READ_INT4( stream );
     max_n     = READ_INT4( stream );
-printf("\nHi I am here in gf_load_font 7\n\n");
+
     #if 0
       gptr = ftell(fp);
     #endif
@@ -408,11 +407,15 @@ printf("\nHi I am here in gf_load_font 7\n\n");
     #endif
 
     nchars = ec - bc + 1;
-    go= malloc(sizeof(GF_GlyphRec)); /* FT_ALLOC(go, sizeof(GF_GlyphRec)); 
goto ErrExit; */
-                                               /* Returning unnecessary errors 
TO BE CHECKED */
+    /*go= malloc(sizeof(GF_GlyphRec));*/
+    if( FT_ALLOC(go, sizeof(GF_GlyphRec)) )
+      goto ErrExit;
+
+
+    /*go->bm_table = (GF_Bitmap)malloc(nchars* sizeof(GF_BitmapRec));*/
+    if( FT_ALLOC_MULT(go->bm_table, sizeof(GF_BitmapRec), nchars) )
+      goto ErrExit;
 
-    go->bm_table = (GF_Bitmap)malloc(nchars* sizeof(GF_BitmapRec));/* 
FT_ALLOC_MULT(go->bm_table, sizeof(GF_BitmapRec), nchars); goto ErrExit; */
-                                                                   /* 
Returning unnecessary errors TO BE CHECKED */
 
     for (i = 0; i < nchars; i++)
       go->bm_table[i].bitmap = NULL;
@@ -469,12 +472,10 @@ printf("\nHi I am here in gf_load_font 7\n\n");
       bm->mv_x = dx;
       bm->mv_y = dy;
       /* ft_fseek(fp, optr, SEEK_SET); */
-      FT_STREAM_SEEK( ptr );
+      FT_STREAM_SEEK( optr );
     }
-
     *goptr          = go;
-    tp = ( go->code_max );
-    printf("tp go->code_max %d\n",go->code_max);
+
   return error;
 
                ErrExit:
@@ -483,29 +484,29 @@ printf("\nHi I am here in gf_load_font 7\n\n");
       {
         if (go->bm_table != NULL)
         {
-          for (i = 0; i < nchars; i++){}
-          /*  FT_FREE(go->bm_table[i].bitmap);*/
+          for (i = 0; i < nchars; i++)
+            FT_FREE(go->bm_table[i].bitmap);
         }
-       /* FT_FREE(go->bm_table);*/ /* Returning unnecessary errors TO BE 
CHECKED */
+        FT_FREE(go->bm_table);
       }
-     /* FT_FREE(go); *//* Returning unnecessary errors TO BE CHECKED */
+      FT_FREE(go);
   }
 
 
   FT_LOCAL_DEF( void )
-  gf_free_font( GF_Glyph  go )
+  gf_free_font( GF_Glyph  go, FT_Memory memory)
   {
     int i=0, nchars =sizeof(go->bm_table);
     if (go != NULL)
     {
       if (go->bm_table != NULL)
       {
-        for (i = 0; i < nchars; i++){}
-          /* FT_FREE(go->bm_table[i].bitmap); */ /* To be verified from Vflib 
*/
+        for (i = 0; i < nchars; i++)
+          FT_FREE(go->bm_table[i].bitmap);  /* To be verified from Vflib */
       }
-      /* FT_FREE(go->bm_table); */ /* Returning unnecessary errors TO BE 
CHECKED */
+      FT_FREE(go->bm_table);
     }
-    /* FT_FREE(go); */ /* Returning unnecessary errors TO BE CHECKED */
+    FT_FREE(go);
   }
 
 
diff --git a/src/gf/gflib.c b/src/gf/gflib2.c
similarity index 65%
copy from src/gf/gflib.c
copy to src/gf/gflib2.c
index ffcb372..5ec4ada 100644
--- a/src/gf/gflib.c
+++ b/src/gf/gflib2.c
@@ -43,91 +43,71 @@
 unsigned char   bit_table[] = {
   0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
 
+#define STREAM_FILE( stream )  ( (FT_FILE*)stream->descriptor.pointer )
+
   /**************************************************************************
    *
    * GF font utility functions.
    *
    */
 
-  long           gf_read_intn(FT_Stream,int);
-  unsigned long  gf_read_uintn(FT_Stream,int);
-  void           gf_skip_n(FT_Stream,int);
+  long           gf_read_intn(FILE*,int);
+  unsigned long  gf_read_uintn(FILE*,int);
+  void           gf_skip_n(FILE*,int);
 
-#define READ_INT1( stream )          (INT1)gf_read_intn(( stream ), 1)
-#define READ_UINT1( stream )         (UINT1)gf_read_uintn(( stream ), 1)
-#define READ_INT2( stream )          (INT2)gf_read_intn(( stream ), 2)
-#define READ_UINT2( stream )         (UINT2)gf_read_uintn(( stream ), 2)
-#define READ_INT3( stream )          (INT3)gf_read_intn(( stream ), 3)
-#define READ_UINT3( stream )         (UINT3)gf_read_uintn(( stream ), 3)
-#define READ_INT4( stream )          (INT4)gf_read_intn(( stream ), 4)
-#define READ_UINT4( stream )         (UINT4)gf_read_uintn(( stream ), 4)
-#define READ_INTN( stream ,n)        (INT4)gf_read_intn(( stream ), (n))
-#define READ_UINTN( stream ,n)       (UINT4)gf_read_uintn(( stream ), (n))
-#define SKIP_N( stream ,k)           gf_skip_n(( stream ), (k))
+#define READ_INT1(fp)          (INT1)gf_read_intn((fp), 1)
+#define READ_UINT1(fp)         (UINT1)gf_read_uintn((fp), 1)
+#define READ_INT2(fp)          (INT2)gf_read_intn((fp), 2)
+#define READ_UINT2(fp)         (UINT2)gf_read_uintn((fp), 2)
+#define READ_INT3(fp)          (INT3)gf_read_intn((fp), 3)
+#define READ_UINT3(fp)         (UINT3)gf_read_uintn((fp), 3)
+#define READ_INT4(fp)          (INT4)gf_read_intn((fp), 4)
+#define READ_UINT4(fp)         (UINT4)gf_read_uintn((fp), 4)
+#define READ_INTN(fp,n)        (INT4)gf_read_intn((fp), (n))
+#define READ_UINTN(fp,n)       (UINT4)gf_read_uintn((fp), (n))
+#define SKIP_N(fp,k)           gf_skip_n((fp), (k))
 
 
 /*
- * Reading a Number from stream
+ * Reading a Number from file
  */
   unsigned long
-  gf_read_uintn(FT_Stream stream, int size)
+  gf_read_uintn(FILE* fp, int size)
   {
-    unsigned long  v;
-    FT_Error error = FT_Err_Ok;
+    unsigned long  v ;
     v = 0L;
     while (size >= 1)
     {
-      v = v*256L + (unsigned long)FT_Stream_ReadULong(stream, &error);
-      stream->pos-=3;
+      v = v*256L + (unsigned long)getc(fp);
       --size;
     }
     return v;
   }
 
-/* Preliminary */
-  unsigned long
-  gf_read_uint4(FT_Stream stream, int size)
-  {
-    unsigned long  v;
-    FT_Error error = FT_Err_Ok;
-    v = 0L;
-    while (size >= 1)
-    {
-      v = v*256L + (unsigned long)FT_Stream_ReadULong(stream, &error);
-      --size;
-    }
-    return v;
-  }
-
-
   long
-  gf_read_intn(FT_Stream stream, int size)
+  gf_read_intn(FILE* fp, int size)
   {
     long           v;
-    FT_Error error = FT_Err_Ok;
-    v = (long)FT_Stream_ReadULong(stream, &error) & 0xffL;
+    v = (long)getc(fp) & 0xffL;
     if (v & 0x80L)
       v = v - 256L;
     --size;
     while (size >= 1)
     {
-      v = v*256L + (unsigned long)FT_Stream_ReadULong(stream, &error);
+      v = v*256L + (unsigned long)getc(fp);
       --size;
                }
     return v;
   }
 
   void
-  gf_skip_n(FT_Stream stream, int size)
+  gf_skip_n(FILE* fp, int size)
   {
-    FT_Stream_Skip(stream, (FT_Long)size );
-    #if 0
     while (size > 0)
     {
       (void)getc(fp);
       --size;
     }
-    #endif
   }
 
   /**************************************************************************
@@ -137,7 +117,7 @@ unsigned char   bit_table[] = {
    */
 
   FT_LOCAL_DEF( FT_Error )
-  gf_read_glyph(FT_Stream stream, GF_Bitmap bm)
+  gf_read_glyph(FT_FILE* fp, GF_Bitmap bm)
   {
     long           m, n;
     int            paint_sw;
@@ -148,22 +128,22 @@ unsigned char   bit_table[] = {
     unsigned char  *ptr;
     FT_Error        error  = FT_Err_Ok;
 
-    switch (READ_UINT1( stream ))
+    switch (READ_UINT1(fp))
     {
     case GF_BOC:
-      SKIP_N( stream , 4);
-      SKIP_N( stream , 4);
-      min_m = READ_INT4( stream );
-      max_m = READ_INT4( stream );
-      min_n = READ_INT4( stream );
-      max_n = READ_INT4( stream );
+      SKIP_N(fp, 4);
+      SKIP_N(fp, 4);
+      min_m = READ_INT4(fp);
+      max_m = READ_INT4(fp);
+      min_n = READ_INT4(fp);
+      max_n = READ_INT4(fp);
       break;
     case GF_BOC1:
-      SKIP_N( stream , 1);
-      del_m = (INT4)READ_UINT1( stream );
-      max_m = (INT4)READ_UINT1( stream );
-      del_n = (INT4)READ_UINT1( stream );
-      max_n = (INT4)READ_UINT1( stream );
+      SKIP_N(fp, 1);
+      del_m = (INT4)READ_UINT1(fp);
+      max_m = (INT4)READ_UINT1(fp);
+      del_n = (INT4)READ_UINT1(fp);
+      max_n = (INT4)READ_UINT1(fp);
       min_m = max_m - del_m;
       min_n = max_n - del_n;
       break;
@@ -199,7 +179,7 @@ unsigned char   bit_table[] = {
     m        = min_m;
     n        = max_n;
     paint_sw = 0;
-    while ((instr = (int)READ_UINT1( stream )) != GF_EOC)
+    while ((instr = (int)READ_UINT1(fp)) != GF_EOC)
     {
       if (instr == GF_PAINT_0)
       {
@@ -223,7 +203,7 @@ unsigned char   bit_table[] = {
         case GF_PAINT1:
         case GF_PAINT2:
         case GF_PAINT3:
-          d = (UINT4)READ_UINTN( stream, (instr - GF_PAINT1 + 1));
+          d = (UINT4)READ_UINTN(fp, (instr - GF_PAINT1 + 1));
           Paint:
             if (paint_sw == 0)
             {
@@ -256,18 +236,18 @@ unsigned char   bit_table[] = {
         case GF_SKIP2:
         case GF_SKIP3:
           m = min_m;
-          n = n - (UINT4)READ_UINTN( stream, (instr - GF_SKIP1 + 1)) - 1;
+          n = n - (UINT4)READ_UINTN(fp, (instr - GF_SKIP1 + 1)) - 1;
           paint_sw = 0;
           break;
         case GF_XXX1:
         case GF_XXX2:
         case GF_XXX3:
         case GF_XXX4:
-          k = READ_UINTN( stream, instr - GF_XXX1 + 1);
-          SKIP_N( stream, k);
+          k = READ_UINTN(fp, instr - GF_XXX1 + 1);
+          SKIP_N(fp, k);
           break;
         case GF_YYY:
-          SKIP_N( stream, 4);
+          SKIP_N(fp, 4);
           break;
         case GF_NO_OP:
           break;
@@ -304,72 +284,61 @@ unsigned char   bit_table[] = {
     FT_Memory       memory = extmemory; /* needed for FT_NEW */
     FT_ULong        offset;
 
+    FT_FILE *fp = STREAM_FILE( stream ) ;
+
     go = NULL;
     nchars = -1;
-printf("\nHi I am here in gf_load_font -1\n\n");
-    /* seek to post_post instr. */
-    /* fseek(fp, -5, SEEK_END); */
-    FT_STREAM_SEEK( stream->size - 5 );
-
-printf("\nHi I am here in gf_load_font 0\n\n");
-    while ((d = READ_UINT1( stream )) == 223)
-    {
-      FT_STREAM_SEEK( stream->pos -2 );
-      /* fseek(fp, -2, SEEK_CUR); */
-    }
 
-printf("\nHi I am here in gf_load_font 1\n\n");
+    char* st =  (char*)stream->pathname.pointer;
+    fp=fopen(st,"rb");
+printf("\nHi I am here in gf_load_font -1 fp is %d\n\n",ftell(fp));
+    /* seek to post_post instr. */
+    fseek(fp, -5, SEEK_END);
+printf("\nHi I am here in gf_load_font 0 fp is %d\n\n",ftell(fp));
+    while ((d = READ_UINT1(fp)) == 223)
+      fseek(fp, -2, SEEK_CUR);
+printf("\nHi I am here in gf_load_font 1 fp is %d\n\n",ftell(fp));
     if (d != GF_ID)
     {
       error = FT_THROW( Invalid_File_Format );
       goto ErrExit;
     }
-
-printf("\nHi I am here in gf_load_font 2\n\n");
-    /* fseek(fp, -6, SEEK_CUR); */
-    FT_STREAM_SEEK( stream->pos -6 );
-
-printf("\nHi I am here in gf_load_font 3\n\n");
+printf("\nHi I am here in gf_load_font 2 fp is %d\n\n",ftell(fp));
+    fseek(fp, -6, SEEK_CUR);
+printf("\nHi I am here in gf_load_font 3 fp is %d\n\n",ftell(fp));
     /* check if the code is post_post */
-    if (READ_UINT1( stream ) != GF_POST_POST)
+    if (READ_UINT1(fp) != GF_POST_POST)
     {
       error = FT_THROW( Invalid_File_Format );
       goto ErrExit;
     }
-
-printf("\nHi I am here in gf_load_font 4\n\n");
+printf("\nHi I am here in gf_load_font 4 fp is %d\n\n",ftell(fp));
     /* read pointer to post instr. */
-    if ((ptr_post = gf_read_uint4( stream,4 )) == -1)
+    if ((ptr_post = READ_UINT4(fp)) == -1)
     {
       error = FT_THROW( Invalid_File_Format );
       goto ErrExit;
     }
-
-printf("\nHi I am here in gf_load_font 5\n\n");
+printf("\nHi I am here in gf_load_font 5 fp is %d\n\n",ftell(fp));
     /* goto post instr. and read it */
-    /* fseek(fp, ptr_post, SEEK_SET); */
-    FT_STREAM_SEEK( ptr_post );
-
-    if (d=READ_UINT1( stream ) != GF_POST)
+    fseek(fp, ptr_post, SEEK_SET);
+    if (READ_UINT1(fp) != GF_POST)
     {
       error = FT_THROW( Invalid_File_Format );
       goto ErrExit;
     }
-
-printf("\nHi I am here in gf_load_font 6\n\n");
-    ptr_p     = READ_UINT4( stream );
-    ds        = READ_UINT4( stream );
-    check_sum = READ_UINT4( stream );
-    hppp      = READ_UINT4( stream );
-    vppp      = READ_UINT4( stream );
-    min_m     = READ_INT4( stream );
-    max_m     = READ_INT4( stream );
-    min_n     = READ_INT4( stream );
-    max_n     = READ_INT4( stream );
-printf("\nHi I am here in gf_load_font 7\n\n");
-    #if 0
-      gptr = ftell(fp);
-    #endif
+printf("\nHi I am here in gf_load_font 6 fp is %d\n\n",ftell(fp));
+    ptr_p     = READ_UINT4(fp);
+    ds        = READ_UINT4(fp);
+    check_sum = READ_UINT4(fp);
+    hppp      = READ_UINT4(fp);
+    vppp      = READ_UINT4(fp);
+    min_m     = READ_INT4(fp);
+    max_m     = READ_INT4(fp);
+    min_n     = READ_INT4(fp);
+    max_n     = READ_INT4(fp);
+
+    gptr = ftell(fp);
 
     #if 0
       /* read min & max char code */
@@ -434,48 +403,44 @@ printf("\nHi I am here in gf_load_font 7\n\n");
 
     for (  ;  ;  )
     {
-      if ((instr = READ_UINT1( stream )) == GF_POST_POST)
+      if ((instr = READ_UINT1(fp)) == GF_POST_POST)
         break;
       switch ((int)instr)
       {
       case GF_CHAR_LOC:
-        code = READ_UINT1( stream );
-        dx   = (double)READ_INT4( stream )/(double)(1<<16);
-        dy   = (double)READ_INT4( stream )/(double)(1<<16);
-        w    = READ_INT4( stream );
-        ptr  = READ_INT4( stream );
+        code = READ_UINT1(fp);
+        dx   = (double)READ_INT4(fp)/(double)(1<<16);
+        dy   = (double)READ_INT4(fp)/(double)(1<<16);
+        w    = READ_INT4(fp);
+        ptr  = READ_INT4(fp);
         break;
       case GF_CHAR_LOC0:
-        code = READ_UINT1( stream );
-        dx   = (double)READ_INT1( stream );
+        code = READ_UINT1(fp);
+        dx   = (double)READ_INT1(fp);
         dy   = (double)0;
-        w    = READ_INT4( stream );
-        ptr  = READ_INT4( stream );
+        w    = READ_INT4(fp);
+        ptr  = READ_INT4(fp);
         break;
       default:
         error = FT_THROW( Invalid_File_Format );
         goto ErrExit;
       }
 
-      /* optr = ft_ftell(fp); */
-      optr = stream->pos;
-      /* ft_fseek(fp, ptr, SEEK_SET); */
-      FT_STREAM_SEEK( ptr );
+      optr = ft_ftell(fp);
+      ft_fseek(fp, ptr, SEEK_SET);
 
       bm = &go->bm_table[code - bc];
-      if (gf_read_glyph( stream, bm ) < 0)
+      if (gf_read_glyph(fp, bm) < 0)
         goto ErrExit;
 
       bm->mv_x = dx;
       bm->mv_y = dy;
-      /* ft_fseek(fp, optr, SEEK_SET); */
-      FT_STREAM_SEEK( ptr );
+      ft_fseek(fp, optr, SEEK_SET);
     }
-
     *goptr          = go;
-    tp = ( go->code_max );
-    printf("tp go->code_max %d\n",go->code_max);
-  return error;
+        tp = ( go->code_max );
+        printf("tp go->code_max %d\n",go->code_max);
+return error;
 
                ErrExit:
       printf("*ERROR\n");
diff --git a/src/gf/gflib.c b/src/gf/gflibstream1.c
similarity index 90%
copy from src/gf/gflib.c
copy to src/gf/gflibstream1.c
index ffcb372..e36e60e 100644
--- a/src/gf/gflib.c
+++ b/src/gf/gflibstream1.c
@@ -72,12 +72,14 @@ unsigned char   bit_table[] = {
   unsigned long
   gf_read_uintn(FT_Stream stream, int size)
   {
-    unsigned long  v;
+    unsigned long  v,k;
     FT_Error error = FT_Err_Ok;
     v = 0L;
     while (size >= 1)
     {
-      v = v*256L + (unsigned long)FT_Stream_ReadULong(stream, &error);
+      k=FT_Stream_ReadULong(stream, &error);printf("k is %d",k);
+      v = v*256L + (unsigned long)k;
+      printf("v is %lu",v);
       stream->pos-=3;
       --size;
     }
@@ -90,12 +92,11 @@ unsigned char   bit_table[] = {
   {
     unsigned long  v;
     FT_Error error = FT_Err_Ok;
-    v = 0L;
-    while (size >= 1)
-    {
-      v = v*256L + (unsigned long)FT_Stream_ReadULong(stream, &error);
-      --size;
-    }
+    v = 0L;stream->pos+=3;
+    printf("stream->pos is %d",stream->pos);
+      v = v*256L + (unsigned long)FT_Stream_ReadULong(stream, 
&error);stream->pos-=3; printf("\tstream->pos 22 is %d v is %d",stream->pos,v);
+
+      stream->pos-=3;
     return v;
   }
 
@@ -300,36 +301,36 @@ unsigned char   bit_table[] = {
     double          dx, dy;
     long            ptr_post, ptr_p, ptr, optr, gptr,tp;
     int             bc, ec, nchars, i;
-    FT_Error        error  = FT_Err_Ok;
+    FT_Error        error  = FT_Err_Ok, error1;
     FT_Memory       memory = extmemory; /* needed for FT_NEW */
     FT_ULong        offset;
 
     go = NULL;
     nchars = -1;
-printf("\nHi I am here in gf_load_font -1\n\n");
+printf("\nHi I am here in gf_load_font -1 stream->pos is %d\n\n", stream->pos);
     /* seek to post_post instr. */
     /* fseek(fp, -5, SEEK_END); */
     FT_STREAM_SEEK( stream->size - 5 );
 
-printf("\nHi I am here in gf_load_font 0\n\n");
+printf("\nHi I am here in gf_load_font 0 stream->pos is %d\n\n", stream->pos);
     while ((d = READ_UINT1( stream )) == 223)
     {
       FT_STREAM_SEEK( stream->pos -2 );
       /* fseek(fp, -2, SEEK_CUR); */
     }
 
-printf("\nHi I am here in gf_load_font 1\n\n");
+printf("\nHi I am here in gf_load_font 1 stream->pos is %d\n\n", stream->pos);
     if (d != GF_ID)
     {
       error = FT_THROW( Invalid_File_Format );
       goto ErrExit;
     }
 
-printf("\nHi I am here in gf_load_font 2\n\n");
+printf("\nHi I am here in gf_load_font 2 stream->pos is %d\n\n", stream->pos);
     /* fseek(fp, -6, SEEK_CUR); */
     FT_STREAM_SEEK( stream->pos -6 );
 
-printf("\nHi I am here in gf_load_font 3\n\n");
+printf("\nHi I am here in gf_load_font 3 stream->pos is %d\n\n", stream->pos);
     /* check if the code is post_post */
     if (READ_UINT1( stream ) != GF_POST_POST)
     {
@@ -337,7 +338,7 @@ printf("\nHi I am here in gf_load_font 3\n\n");
       goto ErrExit;
     }
 
-printf("\nHi I am here in gf_load_font 4\n\n");
+printf("\nHi I am here in gf_load_font 4 before ptr_post stream->pos is 
%d\n\n",stream->pos);
     /* read pointer to post instr. */
     if ((ptr_post = gf_read_uint4( stream,4 )) == -1)
     {
@@ -345,18 +346,20 @@ printf("\nHi I am here in gf_load_font 4\n\n");
       goto ErrExit;
     }
 
-printf("\nHi I am here in gf_load_font 5\n\n");
+printf("\nHi I am here in gf_load_font 5 ptr_post is %d stream->pos is 
%d\n\n",ptr_post, stream->pos);
     /* goto post instr. and read it */
     /* fseek(fp, ptr_post, SEEK_SET); */
     FT_STREAM_SEEK( ptr_post );
-
-    if (d=READ_UINT1( stream ) != GF_POST)
+printf("\nHi I am here in gf_load_font 6 ptr_post is %d stream->pos is 
%d\n\n",ptr_post, stream->pos);
+    d=FT_Stream_ReadULong( stream , &error1) ;
+    printf("\nHi I am here in gf_load_font 6.6 d is %d stream->pos is 
%d\n\n",d, stream->pos);
+    if (d!= GF_POST)
     {
       error = FT_THROW( Invalid_File_Format );
       goto ErrExit;
     }
 
-printf("\nHi I am here in gf_load_font 6\n\n");
+printf("\nHi I am here in gf_load_font 7\n\n");
     ptr_p     = READ_UINT4( stream );
     ds        = READ_UINT4( stream );
     check_sum = READ_UINT4( stream );



reply via email to

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