freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] parthw-wip 5b74836: [tfm] Fixes.


From: Parth Wazurkar
Subject: [freetype2] parthw-wip 5b74836: [tfm] Fixes.
Date: Tue, 10 Jul 2018 07:08:18 -0400 (EDT)

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

    [tfm] Fixes.
---
 modules.cfg        |  5 +++-
 src/tfm/module.mk  |  2 +-
 src/tfm/tfmdrivr.c |  9 +++----
 src/tfm/tfmdrivr.h |  1 -
 src/tfm/tfmlib.c   | 70 +++++++++++++++++++++++++++++-------------------------
 5 files changed, 47 insertions(+), 40 deletions(-)

diff --git a/modules.cfg b/modules.cfg
index 3337e91..62dbba7 100644
--- a/modules.cfg
+++ b/modules.cfg
@@ -68,7 +68,10 @@ FONT_MODULES += pcf
 FONT_MODULES += bdf
 
 # GF font driver.
-FONT_MODULES += gf
+#FONT_MODULES += gf
+
+# TFM font driver.
+FONT_MODULES += tfm
 
 # SFNT files support.  If used without `truetype' or `cff', it supports
 # bitmap-only fonts within an SFNT wrapper.
diff --git a/src/tfm/module.mk b/src/tfm/module.mk
index 0051304..5315ad5 100644
--- a/src/tfm/module.mk
+++ b/src/tfm/module.mk
@@ -16,7 +16,7 @@ FTMODULE_H_COMMANDS += TFM_DRIVER
 
 define TFM_DRIVER
 $(OPEN_DRIVER) FT_Driver_ClassRec, tfm_driver_class $(CLOSE_DRIVER)
-$(ECHO_DRIVER)tfm        $(ECHO_DRIVER_DESC)tfm TeX's bitmap 
fonts$(ECHO_DRIVER_DONE)
+$(ECHO_DRIVER)tfm       $(ECHO_DRIVER_DESC)METAFONT bitmap 
fonts$(ECHO_DRIVER_DONE)
 endef
 
 # EOF
diff --git a/src/tfm/tfmdrivr.c b/src/tfm/tfmdrivr.c
index aa7b960..905bdde 100644
--- a/src/tfm/tfmdrivr.c
+++ b/src/tfm/tfmdrivr.c
@@ -55,9 +55,9 @@
     TFM_Face  face = (TFM_Face)FT_CMAP_FACE( cmap );
     FT_UNUSED( init_data );
 
-    cmap->begin_char     = ;
+    /*cmap->begin_char     = ;
     cmap->end_char       = ;
-
+    */
     return FT_Err_Ok;
   }
 
@@ -67,8 +67,9 @@
   {
     TFM_CMap  cmap = (TFM_CMap)tfmcmap;
 
-    cmap->begin_char     = ;
+    /*cmap->begin_char     = ;
     cmap->end_char       = ;
+    */
   }
 
 
@@ -99,7 +100,7 @@
 
     if ( char_code <= cmap->begin_char )
     {
-      result = cmap->bc;
+      result = cmap->begin_char;
       gindex = 1;
     }
     else
diff --git a/src/tfm/tfmdrivr.h b/src/tfm/tfmdrivr.h
index 1d3c60c..b81d310 100644
--- a/src/tfm/tfmdrivr.h
+++ b/src/tfm/tfmdrivr.h
@@ -40,7 +40,6 @@ FT_BEGIN_HEADER
   typedef struct TFM_GlyphRec_
   {
     /* Font Info */
-    int             type;         /* METRIC_TYPE_xxx */
     int             type_aux;     /* METRIC_TYPE_AUX_xxx */
     UINT4           cs;
     /* Metrics */
diff --git a/src/tfm/tfmlib.c b/src/tfm/tfmlib.c
index 3ba6b66..31d3a5a 100644
--- a/src/tfm/tfmlib.c
+++ b/src/tfm/tfmlib.c
@@ -65,7 +65,8 @@
     v = 0L;
     while (size >= 1)
     {
-      FT_READ_BYTE(tp);
+      if ( FT_READ_BYTE(tp) )
+        return 0; /* To be changed */
       k =(unsigned long)tp;
       v = v*256L + k;
       --size;
@@ -80,7 +81,8 @@
     FT_Byte tp;
     FT_Error error= FT_Err_Ok;
     unsigned long z ;
-    FT_READ_BYTE(tp);
+    if ( FT_READ_BYTE(tp) )
+        return 0; /* To be changed */
     z= (unsigned long)tp;
     v = (long)z & 0xffL;
     if (v & 0x80L)
@@ -88,7 +90,8 @@
     --size;
     while (size >= 1)
     {
-      FT_READ_BYTE(tp);
+      if ( FT_READ_BYTE(tp) )
+        return 0; /* To be changed */
       z= (unsigned long)tp;
       v = v*256L + z;
       --size;
@@ -102,6 +105,18 @@
    *
    */
 
+  FT_LOCAL_DEF( void )
+  tfm_free_font( TFM_Glyph tfm, FT_Memory memory )
+  {
+    if (tfm == NULL)
+      return;
+
+      FT_FREE(tfm->width);
+      FT_FREE(tfm->height);
+      FT_FREE(tfm->depth);
+      FT_FREE(tfm);
+  }
+
   FT_LOCAL_DEF( FT_Error )
   tfm_load_font(  FT_Stream       stream,
                   FT_Memory       extmemory,
@@ -118,13 +133,11 @@
     FT_Memory       memory = extmemory; /* needed for FT_NEW */
 
     if( FT_ALLOC(tfm, sizeof(TFM_GlyphRec)) )
-      goto ErrExit;
+      goto Exit;
 
     tfm->width  = NULL;
     tfm->height = NULL;
     tfm->depth  = NULL;
-    tfm->ct_kcode = NULL;
-    tfm->ct_ctype = NULL;
 
     tfm->font_bbx_w = 0.0;
     tfm->font_bbx_h = 0.0;
@@ -133,7 +146,8 @@
 
     err = 0;
     /* rewind(fp); */
-    FT_STREAM_SEEK( 0 );
+    if( FT_STREAM_SEEK( 0 ) )
+      return error;
     lf = (UINT4)READ_UINT2( stream );
     #if 0
     if ((lf == 11) || (lf == 9))
@@ -171,7 +185,6 @@
     { }
     #endif
     /* Traditional TeX Metric File */
-    tfm->type        = METRIC_TYPE_TFM;
     tfm->type_aux    = 0;
     lh               = (int)READ_UINT2( stream );
     offset_header    = 4*6;
@@ -215,18 +228,20 @@
     neng = (UINT4)READ_UINT2( stream );
     np   = (UINT4)READ_UINT2( stream );
 
-    if (tfm->type == METRIC_TYPE_TFM)
+    #if 0
+      if (tfm->type == METRIC_TYPE_TFM)
+        {}
+    #endif
+    if (((signed)(tfm->begin_char-1) > (signed)tfm->end_char) ||
+       (tfm->end_char > 255))
     {
-      if (((signed)(tfm->begin_char-1) > (signed)tfm->end_char) ||
-         (tfm->end_char > 255))
-      {
-        error = FT_THROW( Invalid_Argument );
-        goto Exit;
-      }
+      error = FT_THROW( Invalid_Argument );
+      goto Exit;
     }
 
     /* fseek(fp, offset_header, SEEK_SET); */
-    FT_STREAM_SEEK( offset_header );
+    if (FT_STREAM_SEEK( offset_header ) )
+      goto Exit;
     tfm->cs          = READ_UINT4( stream );
     tfm->ds          = READ_UINT4( stream );
     tfm->design_size = (double)(tfm->ds)/(double)(1<<20);
@@ -247,7 +262,8 @@
       goto Exit;
     }
     /* fseek(fp, offset_char_info, SEEK_SET); */
-    FT_STREAM_SEEK( offset_char_info );
+    if( FT_STREAM_SEEK( offset_char_info ) )
+      goto Exit;
     for (i = 0; i < nci; i++)
       ci[i] = READ_UINT4( stream );
 
@@ -345,8 +361,10 @@
     #endif
 
     /* fseek(fp, offset_param, SEEK_SET); */
-    FT_STREAM_SEEK( offset_param );
-    FT_READ_ULONG(tfm->slant);
+    if( FT_STREAM_SEEK( offset_param ) )
+      return error; /* To be changed */
+    if (FT_READ_ULONG(tfm->slant) )
+      return error;
     tfm->slant = (double)tfm->slant/(double)(1<<20);
 
   Exit:
@@ -362,18 +380,4 @@
     }
   }
 
-  FT_LOCAL_DEF( void )
-  tfm_free_font( TFM_Glyph tfm, FT_Memory memory )
-  {
-    if (tfm == NULL)
-      return;
-
-      FT_FREE(tfm->width);
-      FT_FREE(tfm->height);
-      FT_FREE(tfm->depth);
-      FT_FREE(tfm->ct_kcode);
-      FT_FREE(tfm->ct_ctype);
-      FT_FREE(tfm);
-  }
-
 /* END */



reply via email to

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