freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] parthw-cleaned fbaaeb8: [pk] Cleanup commit.


From: Parth Wazurkar
Subject: [freetype2] parthw-cleaned fbaaeb8: [pk] Cleanup commit.
Date: Sat, 4 Aug 2018 04:21:12 -0400 (EDT)

branch: parthw-cleaned
commit fbaaeb812b0e2227f7021065da3da33222284566
Author: Parth Wazurkar <address@hidden>
Commit: Parth Wazurkar <address@hidden>

    [pk] Cleanup commit.
    
    * Remove all the unnecessary typedefs and comments.
    * Rename `pk' files' headers.
---
 src/pk/pk.c      |   2 +-
 src/pk/pk.h      |  14 +---
 src/pk/pkdrivr.c |  10 ++-
 src/pk/pkdrivr.h |  12 ++--
 src/pk/pkerror.h |   2 +-
 src/pk/pklib.c   | 198 +++++++++++++++++++++++++++++--------------------------
 6 files changed, 119 insertions(+), 119 deletions(-)

diff --git a/src/pk/pk.c b/src/pk/pk.c
index 79c11cb..5cf58b2 100644
--- a/src/pk/pk.c
+++ b/src/pk/pk.c
@@ -2,7 +2,7 @@
  *
  * pk.c
  *
- *   FreeType font driver for TeX's PK FONT files.
+ *   FreeType font driver METAFONT PK FONT files.
  *
  * Copyright 1996-2018 by
  * David Turner, Robert Wilhelm, and Werner Lemberg.
diff --git a/src/pk/pk.h b/src/pk/pk.h
index d9c5a72..69cb4cd 100644
--- a/src/pk/pk.h
+++ b/src/pk/pk.h
@@ -2,7 +2,7 @@
  *
  * pk.h
  *
- *   FreeType font driver for TeX's PK FONT files.
+ *   FreeType font driver for METAFONT PK FONT files.
  *
  * Copyright 1996-2018 by
  * David Turner, Robert Wilhelm, and Werner Lemberg.
@@ -27,7 +27,6 @@
 
 FT_BEGIN_HEADER
 
-#define  FONT_DRIVER_PK   1
 
 #define  PK_PRE   247
 #define  PK_ID    89
@@ -41,17 +40,6 @@ FT_BEGIN_HEADER
 
 #define toint(x)  (int)(((x)>0)?(x+0.5):(x-0.5))
 
-/* Temporary TO BE REMOVED */
-
-typedef  char           INT1;
-typedef  unsigned char  UINT1;
-typedef  int            INT2;
-typedef  unsigned int   UINT2;
-typedef  long           INT3;
-typedef  unsigned long  UINT3;
-typedef  long           INT4;
-typedef  unsigned long  UINT4;
-
 
 FT_END_HEADER
 
diff --git a/src/pk/pkdrivr.c b/src/pk/pkdrivr.c
index 306d29d..ca1d27e 100644
--- a/src/pk/pkdrivr.c
+++ b/src/pk/pkdrivr.c
@@ -2,7 +2,7 @@
  *
  * pkdrivr.c
  *
- *   FreeType font driver for TeX's PK FONT files.
+ *   FreeType font driver for METAFONT PK FONT files.
  *
  * Copyright 1996-2018 by
  * David Turner, Robert Wilhelm, and Werner Lemberg.
@@ -89,6 +89,7 @@
     return gindex;
   }
 
+
   FT_CALLBACK_DEF( FT_UInt )
   pk_cmap_char_next(  FT_CMap    pkcmap,
                        FT_UInt32  *achar_code )
@@ -262,7 +263,7 @@
       y_res = toint( face->pk_glyph->vppp * 72.27 );
 
       bsize->y_ppem = (FT_Pos) toint((face->pk_glyph->ds * y_res)/ 72.27) << 6 
;
-      bsize->x_ppem = (FT_Pos)FT_MulDiv( bsize->y_ppem,
+      bsize->x_ppem = (FT_Pos) FT_MulDiv( bsize->y_ppem,
                                          x_res,
                                          y_res ); ;
     }
@@ -298,6 +299,7 @@
     return FT_THROW( Unknown_File_Format );
   }
 
+
   FT_CALLBACK_DEF( FT_Error )
   PK_Size_Select(  FT_Size   size,
                    FT_ULong  strike_index )
@@ -315,6 +317,7 @@
     return FT_Err_Ok;
   }
 
+
   FT_CALLBACK_DEF( FT_Error )
   PK_Size_Request( FT_Size          size,
                    FT_Size_Request  req )
@@ -352,7 +355,6 @@
   }
 
 
-
   FT_CALLBACK_DEF( FT_Error )
   PK_Glyph_Load(   FT_GlyphSlot  slot,
                    FT_Size       size,
@@ -440,6 +442,7 @@
     return error;
   }
 
+
   FT_LOCAL_DEF( void )
   TFM_Done_Metrics( FT_Memory     memory,
                     TFM_FontInfo  fi )
@@ -450,6 +453,7 @@
     FT_FREE( fi );
   }
 
+
   /* parse a TFM metrics file */
   FT_LOCAL_DEF( FT_Error )
   TFM_Read_Metrics( FT_Face    pk_face,
diff --git a/src/pk/pkdrivr.h b/src/pk/pkdrivr.h
index 8ee6a10..1e48d43 100644
--- a/src/pk/pkdrivr.h
+++ b/src/pk/pkdrivr.h
@@ -2,7 +2,7 @@
  *
  * pkdrivr.h
  *
- *   FreeType font driver for TeX's PK FONT files.
+ *   FreeType font driver for METAFONT PK FONT files.
  *
  * Copyright 1996-2018 by
  * David Turner, Robert Wilhelm, and Werner Lemberg.
@@ -29,11 +29,11 @@ FT_BEGIN_HEADER
 
   typedef struct PK_BitmapRec_
   {
-    FT_UInt              bbx_width, bbx_height;
-    FT_UInt              off_x, off_y;
-    FT_UInt              mv_x,  mv_y;
-    FT_Byte              *bitmap;
-    FT_UInt              raster;
+    FT_UInt         bbx_width, bbx_height;
+    FT_UInt         off_x, off_y;
+    FT_UInt         mv_x,  mv_y;
+    FT_Byte         *bitmap;
+    FT_UInt         raster;
 
   } PK_BitmapRec, *PK_Bitmap;
 
diff --git a/src/pk/pkerror.h b/src/pk/pkerror.h
index 00d200e..79ae726 100644
--- a/src/pk/pkerror.h
+++ b/src/pk/pkerror.h
@@ -2,7 +2,7 @@
  *
  * pkerror.h
  *
- *   FreeType font driver for TeX's PK FONT files.
+ *   FreeType font driver for METAFONT PK FONT files.
  *
  * Copyright 1996-2018 by
  * David Turner, Robert Wilhelm, and Werner Lemberg.
diff --git a/src/pk/pklib.c b/src/pk/pklib.c
index c4fcfbd..c62c667 100644
--- a/src/pk/pklib.c
+++ b/src/pk/pklib.c
@@ -2,7 +2,7 @@
  *
  * pklib.c
  *
- *   FreeType font driver for TeX's PK FONT files.
+ *   FreeType font driver for METAFONT PK FONT files.
  *
  * Copyright 1996-2018 by
  * David Turner, Robert Wilhelm, and Werner Lemberg.
@@ -40,7 +40,7 @@
 #undef  FT_COMPONENT
 #define FT_COMPONENT  trace_pklib
 
-unsigned char   bits_table[] = {
+FT_Byte  bits_table[] = {
   0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
 
 
@@ -50,79 +50,80 @@ unsigned char   bits_table[] = {
    *
    */
 
-  long           pk_read_intn(FT_Stream,int);
-  unsigned long  pk_read_uintn(FT_Stream,int);
+  FT_Long   pk_read_intn( FT_Stream, FT_Int );
+  FT_ULong  pk_read_uintn( FT_Stream, FT_Int );
 
-#define READ_UINT1( stream )    (UINT1)pk_read_uintn( stream, 1)
-#define READ_UINT2( stream )    (UINT1)pk_read_uintn( stream, 2)
-#define READ_UINT3( stream )    (UINT1)pk_read_uintn( stream, 3)
-#define READ_UINT4( stream )    (UINT1)pk_read_uintn( stream, 4)
-#define READ_UINTN( stream,n)   (UINT4)pk_read_uintn( stream, n)
-#define READ_INT1( stream )     (INT1)pk_read_intn( stream, 1)
-#define READ_INT2( stream )     (INT1)pk_read_intn( stream, 2)
-#define READ_INT4( stream )     (INT4)pk_read_intn( stream, 4)
+#define READ_UINT1( stream )    (FT_Byte)pk_read_uintn( stream, 1)
+#define READ_UINT2( stream )    (FT_Byte)pk_read_uintn( stream, 2)
+#define READ_UINT3( stream )    (FT_Byte)pk_read_uintn( stream, 3)
+#define READ_UINT4( stream )    (FT_Byte)pk_read_uintn( stream, 4)
+#define READ_UINTN( stream,n)   (FT_ULong)pk_read_uintn( stream, n)
+#define READ_INT1( stream )     (FT_String)pk_read_intn( stream, 1)
+#define READ_INT2( stream )     (FT_String)pk_read_intn( stream, 2)
+#define READ_INT4( stream )     (FT_Long)pk_read_intn( stream, 4)
 
 /*
  * Reading a Number from file
  */
-  unsigned long
-  pk_read_uintn(FT_Stream stream, int size)
+  FT_ULong
+  pk_read_uintn(FT_Stream stream, FT_Int size)
   {
-    unsigned long  v,k;
-    FT_Error error;
+    FT_ULong  v,k;
+    FT_Error  error;
     FT_Byte tp;
     v = 0L;
     while (size >= 1)
     {
       if ( FT_READ_BYTE(tp) )
-        return 0; /* To be changed */
-      k =(unsigned long)tp;
+        return 0;
+      k =(FT_ULong)tp;
       v = v*256L + k;
       --size;
     }
     return v;
   }
 
-  long
-  pk_read_intn(FT_Stream stream, int size)
+  FT_Long
+  pk_read_intn(FT_Stream stream, FT_Int size)
   {
-    long           v;
-    FT_Byte tp;
+    FT_Long  v;
+    FT_Byte  tp;
     FT_Error error;
-    unsigned long z ;
+    FT_ULong z ;
+
     if ( FT_READ_BYTE(tp) )
-        return 0;/* To be changed */
-    z= (unsigned long)tp;
-    v = (long)z & 0xffL;
+        return 0;
+    z= (FT_ULong)tp;
+    v = (FT_Long)z & 0xffL;
     if (v & 0x80L)
       v = v - 256L;
     --size;
     while (size >= 1)
     {
       if ( FT_READ_BYTE(tp) )
-        return 0;/* To be changed */
-      z= (unsigned long)tp;
+        return 0;
+      z= (FT_ULong)tp;
       v = v*256L + z;
       --size;
                }
     return v;
   }
 
-  int  pk_read_nyble_rest_cnt;
-  int  pk_read_nyble_max_bytes;
+  FT_Int  pk_read_nyble_rest_cnt;
+  FT_Int  pk_read_nyble_max_bytes;
 
   void
-  pk_read_nyble_init(int max)
+  pk_read_nyble_init( FT_Int max )
   {
     pk_read_nyble_rest_cnt  = 0;
     pk_read_nyble_max_bytes = max;
   }
 
-  int
+  FT_Int
   pk_read_nyble(FT_Stream stream)
   {
-    static UINT1  d;
-    int           v;
+    static FT_Byte  d;
+    FT_Int          v;
 
     switch (pk_read_nyble_rest_cnt)
     {
@@ -143,11 +144,11 @@ unsigned char   bits_table[] = {
   return v;
   }
 
-  long
-  pk_read_packed_number(long* repeat, FT_Stream stream, int dyn_f)
+  FT_Long
+  pk_read_packed_number(FT_Long* repeat, FT_Stream stream, int dyn_f)
   {
-    int   d, n;
-    long  di;
+    FT_Int   d, n;
+    FT_Long  di;
 
     entry:
       d = pk_read_nyble( stream );
@@ -174,14 +175,20 @@ unsigned char   bits_table[] = {
     goto entry;
   }
 
-  int
-  pk_read_14(FT_Stream stream, int dyn_f, int bw, UINT4 rs, PK_Bitmap bm, long 
cc)
+  FT_Int
+  pk_read_14( FT_Stream stream,
+              FT_Int dyn_f,
+              FT_Int bw,
+              FT_ULong rs,
+              PK_Bitmap bm,
+              FT_Long cc )
   {
-    long           x, y, x8, xm;
-    unsigned char  *bm_ptr;
-    unsigned long  bit16_buff;
-    int            rest_bit16_buff;
-    static unsigned int mask_table[] =
+    FT_Long   x, y, x8, xm;
+    FT_Byte   *bm_ptr;
+    FT_ULong  bit16_buff;
+    FT_Int    rest_bit16_buff;
+
+    static FT_UInt mask_table[] =
       { 0xdead,   0x80,   0xc0,   0xe0,   0xf0,   0xf8,   0xfc,   0xfe, 0xdead 
};
 
     if (rs == 0)
@@ -228,12 +235,17 @@ unsigned char   bits_table[] = {
     return 0;
   }
 
-  int
-  pk_read_n14(FT_Stream stream, int dyn_f, int bw, UINT4 rs, PK_Bitmap bm, 
long cc)
+  FT_Int
+  pk_read_n14( FT_Stream stream,
+               FT_Int dyn_f,
+               FT_Int bw,
+               FT_ULong rs,
+               PK_Bitmap bm,
+               FT_Long cc )
   {
-    long           x, y, xx, yy, repeat;
-    int            bits, b_p;
-    unsigned char  *p, *p0, *p1;
+    FT_Long   x, y, xx, yy, repeat;
+    FT_Int    bits, b_p;
+    FT_Byte   *p, *p0, *p1;
 
     pk_read_nyble_init(rs);
     p    = bm->bitmap;
@@ -286,16 +298,15 @@ unsigned char   bits_table[] = {
                FT_Memory       extmemory,
                PK_Glyph        *goptr )
   {
-    PK_Glyph      go;
-    UINT1         instr, pre, id;;
-    unsigned long ds, check_sum, hppp, vppp, k;
-    unsigned int  flag, dny_f, bw, ess, size;
-    UINT4         cc, tfm, dx, dy, dm, w, h, rs;
-    INT4          hoff, voff, mv_x, mv_y;
-    long          gptr;
-    int           bc, ec, nchars, index, i;
-    FT_Error      error  = FT_Err_Ok;
-    FT_Memory     memory = extmemory; /* needed for FT_NEW */
+    PK_Glyph   go;
+    FT_Byte    instr, pre, id;;
+    FT_ULong   ds, check_sum, hppp, vppp, k;
+    FT_UInt    flag, dny_f, bw, ess, size;
+    FT_ULong   cc, tfm, dx, dy, dm, w, h, rs;
+    FT_Long    hoff, voff, mv_x, mv_y, gptr;
+    FT_Int     bc, ec, nchars, index, i;
+    FT_Error   error  = FT_Err_Ok;
+    FT_Memory  memory = extmemory; /* needed for FT_NEW */
 
     go = NULL;
     nchars = -1;
@@ -320,12 +331,12 @@ unsigned char   bits_table[] = {
     k = READ_UINT1( stream );
     if ( FT_STREAM_SKIP( k ) )
       goto Exit;
+
     ds        = READ_INT4( stream );
     check_sum = READ_INT4( stream );
     hppp      = READ_INT4( stream );
     vppp      = READ_INT4( stream );
 
-    /* gptr = ftell(fp); */
     gptr = stream->pos;
 
     #if 0
@@ -339,10 +350,10 @@ unsigned char   bits_table[] = {
         break;
         switch ((int) instr)
         {
-          case PK_XXX1:  k = (UINT4)READ_UINT1( stream ); if ( FT_STREAM_SKIP( 
k ) ) goto Exit; break;
-          case PK_XXX2:  k = (UINT4)READ_UINT2( stream ); if ( FT_STREAM_SKIP( 
k ) ) goto Exit; break;
-          case PK_XXX3:  k = (UINT4)READ_UINT3( stream ); if ( FT_STREAM_SKIP( 
k ) ) goto Exit; break;
-          case PK_XXX4:  k = (UINT4)READ_UINT4( stream ); if ( FT_STREAM_SKIP( 
k ) ) goto Exit; break;
+          case PK_XXX1:  k = (FT_ULong)READ_UINT1( stream ); if ( 
FT_STREAM_SKIP( k ) ) goto Exit; break;
+          case PK_XXX2:  k = (FT_ULong)READ_UINT2( stream ); if ( 
FT_STREAM_SKIP( k ) ) goto Exit; break;
+          case PK_XXX3:  k = (FT_ULong)READ_UINT3( stream ); if ( 
FT_STREAM_SKIP( k ) ) goto Exit; break;
+          case PK_XXX4:  k = (FT_ULong)READ_UINT4( stream ); if ( 
FT_STREAM_SKIP( k ) ) goto Exit; break;
           case PK_YYY:   if ( FT_STREAM_SKIP( 4 ) ) goto Exit; break;
           case PK_NO_OP: break;
           default:
@@ -350,18 +361,18 @@ unsigned char   bits_table[] = {
             ess   = instr & 0x1;
           if (ess == 0)
           {                          /* short */
-                 rs = (UINT4)(size*256) + (UINT4)READ_UINT1( stream );
-                 cc   = (UINT4)READ_UINT1( stream );
+                 rs = (FT_ULong)(size*256) + (FT_ULong)READ_UINT1( stream );
+                 cc   = (FT_ULong)READ_UINT1( stream );
           }
           else if ((ess == 1) && (size != 3))
           {                          /* extended short */
-                 rs = (UINT4)(size*65536) + (UINT4)READ_UINT2( stream );
-                 cc   = (UINT4)READ_UINT1( stream );
+                 rs = (FT_ULong)(size*65536) + (FT_ULong)READ_UINT2( stream );
+                 cc   = (FT_ULong)READ_UINT1( stream );
           }
           else
           {                          /* standard */
                  rs   = READ_UINT4( stream );
-                 cc   = (UINT4)READ_UINT4( stream );
+                 cc   = (FT_ULong)READ_UINT4( stream );
           }
           if ( FT_STREAM_SKIP( rs ) )
             goto Exit;
@@ -398,7 +409,6 @@ unsigned char   bits_table[] = {
     go->code_max = ec;
 
     /* read glyphs */
-    /* fseek(fp, gptr, SEEK_SET); */
     if( FT_STREAM_SEEK( gptr ) )
         goto Exit;
 
@@ -406,25 +416,25 @@ unsigned char   bits_table[] = {
     {
       if ((instr = READ_UINT1( stream )) == PK_POST)
         break;
-      switch ((int)instr)
+      switch ((FT_Int)instr)
       {
         case PK_XXX1:
-          k = (UINT4)READ_UINT1( stream );
+          k = (FT_ULong)READ_UINT1( stream );
           if ( FT_STREAM_SKIP( k ) )
             goto Exit;
           break;
         case PK_XXX2:
-          k = (UINT4)READ_UINT2( stream );
+          k = (FT_ULong)READ_UINT2( stream );
           if ( FT_STREAM_SKIP( k ) )
             goto Exit;
           break;
         case PK_XXX3:
-          k = (UINT4)READ_UINT3( stream );
+          k = (FT_ULong)READ_UINT3( stream );
           if ( FT_STREAM_SKIP( k ) )
             goto Exit;
           break;
         case PK_XXX4:
-          k = (UINT4)READ_UINT4( stream );
+          k = (FT_ULong)READ_UINT4( stream );
           if ( FT_STREAM_SKIP( k ) )
             goto Exit;
           break;
@@ -442,33 +452,33 @@ unsigned char   bits_table[] = {
           dny_f = flag % 0x10;
         if (ess == 0)
         {                          /* short */
-          rs = (UINT4)(size*256) + (UINT4)READ_UINT1( stream ) - (UINT4)8;
-          cc   = (UINT4)READ_UINT1( stream );
-          tfm  = (UINT4)READ_UINT3( stream );
-          dm   = (UINT4)READ_UINT1( stream );
-          w    = (UINT4)READ_UINT1( stream );
-          h    = (UINT4)READ_UINT1( stream );
-          hoff = (INT4)READ_INT1( stream );
-          voff = (INT4)READ_INT1( stream );
+          rs = (FT_ULong)(size*256) + (FT_ULong)READ_UINT1( stream ) - 
(FT_ULong)8;
+          cc   = (FT_ULong)READ_UINT1( stream );
+          tfm  = (FT_ULong)READ_UINT3( stream );
+          dm   = (FT_ULong)READ_UINT1( stream );
+          w    = (FT_ULong)READ_UINT1( stream );
+          h    = (FT_ULong)READ_UINT1( stream );
+          hoff = (FT_Long)READ_INT1( stream );
+          voff = (FT_Long)READ_INT1( stream );
           mv_x = dm;
           mv_y = 0;
         }
         else if ((ess == 1) && (size != 3))
         {                          /* extended short */
-          rs = (UINT4)(size*65536) + (UINT4)READ_UINT2( stream ) - (UINT4)13;
-          cc   = (UINT4)READ_UINT1( stream );
-          tfm  = (UINT4)READ_UINT3( stream );
-          dm   = (UINT4)READ_UINT2( stream );
-          w    = (UINT4)READ_UINT2( stream );
-          h    = (UINT4)READ_UINT2( stream );
-          hoff = (INT4)READ_INT2( stream );
-          voff = (INT4)READ_INT2( stream );
+          rs = (FT_ULong)(size*65536) + (FT_ULong)READ_UINT2( stream ) - 
(FT_ULong)13;
+          cc   = (FT_ULong)READ_UINT1( stream );
+          tfm  = (FT_ULong)READ_UINT3( stream );
+          dm   = (FT_ULong)READ_UINT2( stream );
+          w    = (FT_ULong)READ_UINT2( stream );
+          h    = (FT_ULong)READ_UINT2( stream );
+          hoff = (FT_Long)READ_INT2( stream );
+          voff = (FT_Long)READ_INT2( stream );
           mv_x = dm;
           mv_y = 0;
         }
         else
         {                           /* standard */
-          rs   = READ_UINT4( stream ) - (UINT4)28;
+          rs   = READ_UINT4( stream ) - (FT_ULong)28;
           cc   = READ_UINT4( stream );
           tfm  = READ_UINT4( stream );
           dx   = READ_UINT4( stream );
@@ -509,7 +519,6 @@ unsigned char   bits_table[] = {
         {
           if (pk_read_14(stream, dny_f, bw, rs, &(go->bm_table[index]), cc) < 
0)
           {
-            /* vf_error = VF_ERR_ILL_FONT_FILE; (FOR TRACING) */
             FT_ERROR(( "pk_load_font: error in `pk_read_14'\n" ));
             error = FT_THROW( Unknown_File_Format );
             goto Exit;
@@ -519,7 +528,6 @@ unsigned char   bits_table[] = {
         {
           if (pk_read_n14(stream, dny_f, bw, rs, &(go->bm_table[index]), cc) < 
0)
           {
-            /* vf_error = VF_ERR_ILL_FONT_FILE; (FOR TRACING) */
             FT_ERROR(( "pk_load_font: error in `pk_read_n14'\n" ));
             error = FT_THROW( Unknown_File_Format );
             goto Exit;



reply via email to

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