freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] GSoC-2018-parth e3bdbb3: [pk] Fixes.


From: Parth Wazurkar
Subject: [freetype2] GSoC-2018-parth e3bdbb3: [pk] Fixes.
Date: Mon, 13 Aug 2018 00:47:49 -0400 (EDT)

branch: GSoC-2018-parth
commit e3bdbb32681d730ac4d0a3355e93a3660ae60662
Author: Parth Wazurkar <address@hidden>
Commit: Parth Wazurkar <address@hidden>

    [pk] Fixes.
    
    * src/pk/pkdrivr.c(PK_Glyph_Load):
      - Remove unnecessary test for code_{min, max} values.
      - Use pointer to get metric values.
    
    * src/pk/pklib.c(pk_load_font):
      - Improve tracing.
      - Remove unnecessary variables and parameters.
---
 src/pk/pkdrivr.c | 36 ++++++++++++----------------------
 src/pk/pklib.c   | 60 ++++++++++++++++++++++++++++++++++++++------------------
 2 files changed, 54 insertions(+), 42 deletions(-)

diff --git a/src/pk/pkdrivr.c b/src/pk/pkdrivr.c
index bbb4b93..23a69bc 100644
--- a/src/pk/pkdrivr.c
+++ b/src/pk/pkdrivr.c
@@ -432,7 +432,7 @@
     FT_Face      face   = FT_FACE( pk );
     FT_Error     error  = FT_Err_Ok;
     FT_Bitmap*   bitmap = &slot->bitmap;
-    PK_BitmapRec bm;
+    PK_Bitmap    bm;
     PK_Glyph     go;
 
     go = pk->pk_glyph;
@@ -454,16 +454,6 @@
 
     FT_TRACE1(( "PK_Glyph_Load: glyph index %d\n", glyph_index ));
 
-    if ( glyph_index < 0 )
-      glyph_index = 0;
-
-    if ((glyph_index < go->code_min) || (go->code_max < glyph_index))
-    {
-      FT_TRACE2(( "invalid glyph index\n" ));
-      error = FT_THROW( Invalid_Argument );
-      goto Exit;
-    }
-
     if ( !go->bm_table )
     {
       FT_TRACE2(( "invalid bitmap table\n" ));
@@ -472,36 +462,36 @@
     }
 
     /* slot, bitmap => freetype, bm => pklib */
-    bm = pk->pk_glyph->bm_table[glyph_index];
+    bm = &pk->pk_glyph->bm_table[glyph_index];
 
-    bitmap->rows       = bm.bbx_height;
-    bitmap->width      = bm.bbx_width;
+    bitmap->rows       = bm->bbx_height;
+    bitmap->width      = bm->bbx_width;
     bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
 
-    if ( !bm.raster )
+    if ( !bm->raster )
     {
       FT_TRACE2(( "invalid bitmap width\n" ));
       error = FT_THROW( Invalid_File_Format );
       goto Exit;
     }
 
-    bitmap->pitch = (int)bm.raster ;
+    bitmap->pitch = (int)bm->raster ;
 
     /* note: we don't allocate a new array to hold the bitmap; */
     /*       we can simply point to it                         */
-    ft_glyphslot_set_bitmap( slot, bm.bitmap );
+    ft_glyphslot_set_bitmap( slot, bm->bitmap );
 
     slot->format      = FT_GLYPH_FORMAT_BITMAP;
-    slot->bitmap_left = bm.off_x ;
-    slot->bitmap_top  = bm.off_y ;
+    slot->bitmap_left = bm->off_x ;
+    slot->bitmap_top  = bm->off_y ;
 
-    slot->metrics.horiAdvance  = (FT_Pos) (bm.mv_x ) * 64;
-    slot->metrics.horiBearingX = (FT_Pos) (bm.off_x ) * 64;
-    slot->metrics.horiBearingY = (FT_Pos) (bm.bbx_height) * 64;
+    slot->metrics.horiAdvance  = (FT_Pos) (bm->mv_x ) * 64;
+    slot->metrics.horiBearingX = (FT_Pos) (bm->off_x ) * 64;
+    slot->metrics.horiBearingY = (FT_Pos) (bm->bbx_height) * 64;
     slot->metrics.width        = (FT_Pos) ( bitmap->width * 64 );
     slot->metrics.height       = (FT_Pos) ( bitmap->rows * 64 );
 
-    ft_synthesize_vertical_metrics( &slot->metrics, bm.bbx_height * 64 );
+    ft_synthesize_vertical_metrics( &slot->metrics, bm->bbx_height * 64 );
 
   Exit:
     return error;
diff --git a/src/pk/pklib.c b/src/pk/pklib.c
index dd5a23b..8ede289 100644
--- a/src/pk/pklib.c
+++ b/src/pk/pklib.c
@@ -177,11 +177,8 @@ FT_Byte  bits_table[] = {
 
   FT_Int
   pk_read_14( FT_Stream stream,
-              FT_Int dyn_f,
-              FT_Int bw,
               FT_ULong rs,
-              PK_Bitmap bm,
-              FT_Long cc )
+              PK_Bitmap bm )
   {
     FT_Long   x, y, x8, xm;
     FT_Byte   *bm_ptr;
@@ -199,6 +196,7 @@ FT_Byte  bits_table[] = {
     bm_ptr = bm->bitmap;
 
     bit16_buff = READ_UINT1( stream ) << 8;
+    FT_TRACE2(( "pk_read_14: bit16_buff is %ld\n",bit16_buff ));
     rest_bit16_buff = 8;
     --rs;
 
@@ -240,8 +238,7 @@ FT_Byte  bits_table[] = {
                FT_Int dyn_f,
                FT_Int bw,
                FT_ULong rs,
-               PK_Bitmap bm,
-               FT_Long cc )
+               PK_Bitmap bm )
   {
     FT_Long   x, y, xx, yy, repeat;
     FT_Int    bits, b_p;
@@ -298,16 +295,16 @@ FT_Byte  bits_table[] = {
                FT_Memory       extmemory,
                PK_Glyph        *goptr )
   {
-    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 */
-    PK_Encoding   encoding = NULL;
+    PK_Glyph    go;
+    FT_Byte     instr, pre, id;
+    FT_Long     ds, check_sum, hppp, vppp, k;
+    FT_Long     cc, tfm, dx, dy, dm, w, h, rs;
+    FT_Int      flag, dny_f, bw, ess, size;
+    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 */
+    PK_Encoding encoding = NULL;
 
     go = NULL;
     nchars = -1;
@@ -329,6 +326,8 @@ FT_Byte  bits_table[] = {
       goto Exit;
     }
 
+    FT_TRACE2(( "pk_load_font: PK_ID(89) found\n" ));
+
     k = READ_UINT1( stream );
     if ( FT_STREAM_SKIP( k ) )
       goto Exit;
@@ -338,6 +337,8 @@ FT_Byte  bits_table[] = {
     hppp      = READ_INT4( stream );
     vppp      = READ_INT4( stream );
 
+    FT_TRACE2(( "pk_load_font: checksum is %ld\n",check_sum ));
+
     gptr = stream->pos;
 
     #if 0
@@ -393,12 +394,18 @@ FT_Byte  bits_table[] = {
     if( FT_ALLOC(go, sizeof(PK_GlyphRec)) )
       goto Exit;
 
+    FT_TRACE2(( "pk_load_font: Allocated sufficient memory in go\n" ));
+
     if( FT_ALLOC_MULT(go->bm_table, sizeof(PK_BitmapRec), nchars) )
       goto Exit;
 
+    FT_TRACE2(( "pk_load_font: Allocated sufficient memory in go->bm_table\n" 
));
+
     if ( FT_NEW_ARRAY( encoding, nchars ) )
       return error;
 
+    FT_TRACE2(( "pk_load_font: Allocated sufficient memory in encoding\n" ));
+
     go->ds   = (FT_UInt)ds/(1<<20);
     go->hppp = (FT_UInt)hppp/(1<<16);
     go->vppp = (FT_UInt)vppp/(1<<16);
@@ -507,13 +514,28 @@ FT_Byte  bits_table[] = {
         go->bm_table[index].off_y  = voff;
         go->bm_table[index].mv_x   = mv_x;
         go->bm_table[index].mv_y   = mv_y;
-        go->bm_table[index].bitmap = (unsigned char*)malloc(h*((w+7)/8));
+        go->bm_table[index].bitmap = (unsigned char*)malloc(h*( (w+7)>>3 ));
         go->bm_table[index].code   = cc ; /* For backward compatibility */
         go->nglyphs               += 1;
 
         encoding[index].enc   = cc ;
         encoding[index].glyph = index;
 
+        FT_TRACE6(( "pk_load_font: go->bm_table values are :\n"
+                    "                       go->bm_table[%d].bbx_width  : 
%ld\n"
+                    "                       go->bm_table[%d].bbx_height : 
%ld\n"
+                    "                       go->bm_table[%d].raster     : %d\n"
+                    "                       go->bm_table[%d].off_x      : %d\n"
+                    "                       go->bm_table[%d].off_y      : %d\n"
+                    "                       go->bm_table[%d].mv_x       : %d\n"
+                    "                       go->bm_table[%d].mv_y       : 
%d\n", index, go->bm_table[index].bbx_width, index,
+                                                                               
  go->bm_table[index].bbx_height, index,
+                                                                               
  go->bm_table[index].raster, index,
+                                                                               
  go->bm_table[index].off_x, index,
+                                                                               
  go->bm_table[index].off_y, index,
+                                                                               
  go->bm_table[index].mv_x, index,
+                                                                               
  go->bm_table[index].mv_y, index ));
+
 
         if (go->bm_table[index].bitmap == NULL)
         {
@@ -525,7 +547,7 @@ FT_Byte  bits_table[] = {
 
         if (dny_f == 14)
         {
-          if (pk_read_14(stream, dny_f, bw, rs, &(go->bm_table[index]), cc) < 
0)
+          if (pk_read_14(stream, rs, &(go->bm_table[index])) < 0)
           {
             FT_ERROR(( "pk_load_font: error in `pk_read_14'\n" ));
             error = FT_THROW( Unknown_File_Format );
@@ -534,7 +556,7 @@ FT_Byte  bits_table[] = {
         }
         else
         {
-          if (pk_read_n14(stream, dny_f, bw, rs, &(go->bm_table[index]), cc) < 
0)
+          if (pk_read_n14(stream, dny_f, bw, rs, &(go->bm_table[index])) < 0)
           {
             FT_ERROR(( "pk_load_font: error in `pk_read_n14'\n" ));
             error = FT_THROW( Unknown_File_Format );



reply via email to

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