shithub: freetype+ttf2subf

Download patch

ref: 2bbcb7edd86cd9cb77dbfe8fb09426167df5a275
parent: 763b39496e6453a449374694983d9622a8aad775
author: suzuki toshiya <[email protected]>
date: Fri Jul 31 20:30:15 EDT 2009

bdf: Fix some data types mismatching with their sources.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
 2009-07-31  suzuki toshiya <[email protected]>
 
+	bdf: Fix some data types mismatching with their sources.
+
+	* bdflib.c (_bdf_list_ensure): The type of `num_items'
+	is matched with _bdf_list_t.used.  Also the types of
+	`oldsize', `newsize', `bigsize' are matched too.
+	(_bdf_readstream): `cursor' is used as an offset to
+	the pointer, it should be typed as FT_Offset.  Also
+	the types of `bytes', `start', `end', `avail' are matched.
+
+	* bdfdrivr.c: The type of BDF_CMap->num_encodings is
+	matched with FT_CMap->clazz->size.
+	(bdf_cmap_char_index): The types of `min', `max', `mid'
+	are matched with BDF_CMap->num_encodings.  The type of
+	`result' is matched with encoding->glyph.
+	(bdf_cmap_char_next): Ditto, the type of `code' is
+	matched with BDF_encoding_el.enc.
+	(bdf_interpret_style): The type of `lengths' is changed
+	to size_t, to take the value by ft_strlen().  Also the
+	types of `len', `nn', `mm' are matched.
+
+2009-07-31  suzuki toshiya <[email protected]>
+
 	sfnt: Count the size of the memory object by ptrdiff_t.
 
 	* src/sfnt/ttbdf.c (tt_face_find_bdf_prop): The type of
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -53,7 +53,7 @@
   typedef struct  BDF_CMapRec_
   {
     FT_CMapRec        cmap;
-    FT_UInt           num_encodings;
+    FT_ULong          num_encodings; /* ftobjs.h: FT_CMap->clazz->size */
     BDF_encoding_el*  encodings;
 
   } BDF_CMapRec, *BDF_CMap;
@@ -92,8 +92,8 @@
   {
     BDF_CMap          cmap      = (BDF_CMap)bdfcmap;
     BDF_encoding_el*  encodings = cmap->encodings;
-    FT_UInt           min, max, mid;
-    FT_UInt           result    = 0;
+    FT_ULong          min, max, mid; /* num_encodings */
+    FT_UShort         result    = 0; /* encodings->glyph */
 
 
     min = 0;
@@ -131,9 +131,9 @@
   {
     BDF_CMap          cmap      = (BDF_CMap)bdfcmap;
     BDF_encoding_el*  encodings = cmap->encodings;
-    FT_UInt           min, max, mid;
+    FT_ULong          min, max, mid; /* num_encodings */
+    FT_UShort         result   = 0;  /* encodings->glyph */
     FT_UInt32         charcode = *acharcode + 1;
-    FT_UInt           result   = 0;
 
 
     min = 0;
@@ -141,7 +141,7 @@
 
     while ( min < max )
     {
-      FT_UInt32  code;
+      FT_ULong  code; /* same as BDF_encoding_el.enc */
 
 
       mid  = ( min + max ) >> 1;
@@ -196,9 +196,8 @@
     bdf_font_t*      font   = bdf->bdffont;
     bdf_property_t*  prop;
 
-    int    nn, len;
-    char*  strings[4] = { NULL, NULL, NULL, NULL };
-    int    lengths[4];
+    char*   strings[4] = { NULL, NULL, NULL, NULL };
+    size_t  nn, len, lengths[4];
 
 
     face->style_flags = 0;
@@ -284,7 +283,7 @@
         /* add_style_name and setwidth_name     */
         if ( nn == 0 || nn == 3 )
         {
-          int  mm;
+          size_t  mm;
 
 
           for ( mm = 0; mm < len; mm++ )
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -415,18 +415,18 @@
 
 
   static FT_Error
-  _bdf_list_ensure( _bdf_list_t*  list,
-                    int           num_items )
+  _bdf_list_ensure( _bdf_list_t*   list,
+                    unsigned long  num_items ) /* same as _bdf_list_t.used */
   {
     FT_Error  error = BDF_Err_Ok;
 
 
-    if ( num_items > (int)list->size )
+    if ( num_items > list->size )
     {
-      int        oldsize = list->size;
-      int        newsize = oldsize + ( oldsize >> 1 ) + 4;
-      int        bigsize = FT_INT_MAX / sizeof ( char* );
-      FT_Memory  memory  = list->memory;
+      unsigned long  oldsize = list->size; /* same as _bdf_list_t.size */
+      unsigned long  newsize = oldsize + ( oldsize >> 1 ) + 4;
+      unsigned long  bigsize = (unsigned long)( FT_INT_MAX / sizeof ( char* ) );
+      FT_Memory      memory  = list->memory;
 
 
       if ( oldsize == bigsize )
@@ -614,8 +614,8 @@
   {
     _bdf_line_func_t  cb;
     unsigned long     lineno, buf_size;
-    int               refill, bytes, hold, to_skip;
-    int               start, end, cursor, avail;
+    int               refill, hold, to_skip;
+    ptrdiff_t         bytes, start, end, cursor, avail;
     char*             buf = 0;
     FT_Memory         memory = stream->memory;
     FT_Error          error = BDF_Err_Ok;
@@ -648,8 +648,8 @@
     {
       if ( refill )
       {
-        bytes  = (int)FT_Stream_TryRead( stream, (FT_Byte*)buf + cursor,
-                                         (FT_ULong)(buf_size - cursor) );
+        bytes  = (ptrdiff_t)FT_Stream_TryRead( stream, (FT_Byte*)buf + cursor,
+                                               (FT_ULong)(buf_size - cursor) );
         avail  = cursor + bytes;
         cursor = 0;
         refill = 0;