Commit d2e1573706cd2f9a28250f8f98e943da3fba9d8f

Werner Lemberg 2007-12-30T23:49:14

* src/smooth/ftgrays.c (gray_raster_render): Check `outline' correctly. Whitespace.

diff --git a/ChangeLog b/ChangeLog
index 2f0f31c..d4051d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,20 +1,24 @@
+2007-12-30  Werner Lemberg  <wl@gnu.org>
+
+	* src/smooth/ftgrays.c (gray_raster_render): Check `outline'
+	correctly.
+
 2007-12-21  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
 
 	Improvement of POSIX resource-fork accessor to load unsorted
-	references in a resource. In HelveLTMM (resource-fork
-	PostScript Type1 font bundled to Mac OS X since 10.3.x),
-	the appearance order of PFB chunks is not sorted.
-	Sorting the chunks by reference IDs is required.
+	references in a resource.  In HelveLTMM (resource-fork PostScript
+	Type1 font bundled with Mac OS X since 10.3.x), the appearance order
+	of PFB chunks is not sorted; sorting the chunks by reference IDs is
+	required.
 
-	* include/freetype/internal/ftrfork.h (FT_RFork_Ref):
-	New structure type to store a pair of reference ID and offset
-	to the chunk.
+	* include/freetype/internal/ftrfork.h (FT_RFork_Ref): New structure
+	type to store a pair of reference ID and offset to the chunk.
 
-	* src/base/ftrfork.c (ft_raccess_sort_ref_by_id):
-	New function to sort FT_RFork_Ref by their reference ID.
+	* src/base/ftrfork.c (ft_raccess_sort_ref_by_id): New function to
+	sort FT_RFork_Ref by their reference IDs.
 
-	(FT_Raccess_Get_DataOffsets): Returns an array of offsets
-	that is sorted by reference ID.
+	(FT_Raccess_Get_DataOffsets): Returns an array of offsets that is
+	sorted by reference ID.
 
 2007-12-14  Werner Lemberg  <wl@gnu.org>
 
diff --git a/include/freetype/ftimage.h b/include/freetype/ftimage.h
index 1c428f1..4f3a6d2 100644
--- a/include/freetype/ftimage.h
+++ b/include/freetype/ftimage.h
@@ -28,7 +28,7 @@
 #define __FTIMAGE_H__
 
 
-/* _STANDALONE_ is from ftgrays.c */
+  /* _STANDALONE_ is from ftgrays.c */
 #ifndef _STANDALONE_
 #include <ft2build.h>
 #endif
@@ -1075,6 +1075,7 @@ FT_BEGIN_HEADER
 
 #define  FT_Raster_New_Func    FT_Raster_NewFunc
 
+
   /*************************************************************************/
   /*                                                                       */
   /* <FuncType>                                                            */
@@ -1091,6 +1092,7 @@ FT_BEGIN_HEADER
 
 #define  FT_Raster_Done_Func   FT_Raster_DoneFunc
 
+
   /*************************************************************************/
   /*                                                                       */
   /* <FuncType>                                                            */
@@ -1125,6 +1127,7 @@ FT_BEGIN_HEADER
 
 #define  FT_Raster_Reset_Func   FT_Raster_ResetFunc
 
+
   /*************************************************************************/
   /*                                                                       */
   /* <FuncType>                                                            */
@@ -1150,6 +1153,7 @@ FT_BEGIN_HEADER
 
 #define  FT_Raster_Set_Mode_Func  FT_Raster_SetModeFunc
 
+
   /*************************************************************************/
   /*                                                                       */
   /* <FuncType>                                                            */
@@ -1190,6 +1194,7 @@ FT_BEGIN_HEADER
 
 #define  FT_Raster_Render_Func    FT_Raster_RenderFunc
 
+
   /*************************************************************************/
   /*                                                                       */
   /* <Struct>                                                              */
@@ -1211,12 +1216,12 @@ FT_BEGIN_HEADER
   /*                                                                       */
   typedef struct  FT_Raster_Funcs_
   {
-    FT_Glyph_Format         glyph_format;
-    FT_Raster_NewFunc       raster_new;
-    FT_Raster_ResetFunc     raster_reset;
-    FT_Raster_SetModeFunc   raster_set_mode;
-    FT_Raster_RenderFunc    raster_render;
-    FT_Raster_DoneFunc      raster_done;
+    FT_Glyph_Format        glyph_format;
+    FT_Raster_NewFunc      raster_new;
+    FT_Raster_ResetFunc    raster_reset;
+    FT_Raster_SetModeFunc  raster_set_mode;
+    FT_Raster_RenderFunc   raster_render;
+    FT_Raster_DoneFunc     raster_done;
 
   } FT_Raster_Funcs;
 
diff --git a/include/freetype/internal/ftrfork.h b/include/freetype/internal/ftrfork.h
index 7f1a3f4..aa573c8 100644
--- a/include/freetype/internal/ftrfork.h
+++ b/include/freetype/internal/ftrfork.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Embedded resource forks accessor (specification).                    */
 /*                                                                         */
-/*  Copyright 2004, 2006 by                                                */
+/*  Copyright 2004, 2006, 2007 by                                          */
 /*  Masatake YAMATO and Redhat K.K.                                        */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -36,14 +36,19 @@ FT_BEGIN_HEADER
   /* Don't forget to increment the number if you add a new guessing rule. */
 #define FT_RACCESS_N_RULES  9
 
-  /* Structure to describe a reference in resource, by its resource id    */
-  /* and internal offset. `POST' resource expects to be concatenated by   */
-  /* the order of resource id, instead of its appearance in the file.     */
-  typedef struct FT_RFork_Ref_ {
-      FT_UShort  res_id;
-      FT_ULong   offset;
+
+  /* A structure to describe a reference in a resource by its resource ID */
+  /* and internal offset.  The `POST' resource expects to be concatenated */
+  /* by the order of resource IDs instead of its appearance in the file.  */
+
+  typedef struct  FT_RFork_Ref_
+  {
+    FT_UShort  res_id;
+    FT_ULong   offset;
+
   } FT_RFork_Ref;
 
+
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
diff --git a/src/base/ftrfork.c b/src/base/ftrfork.c
index ac6602f..5a835ee 100644
--- a/src/base/ftrfork.c
+++ b/src/base/ftrfork.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Embedded resource forks accessor (body).                             */
 /*                                                                         */
-/*  Copyright 2004, 2005, 2006 by                                          */
+/*  Copyright 2004, 2005, 2006, 2007 by                                    */
 /*  Masatake YAMATO and Redhat K.K.                                        */
 /*                                                                         */
 /*  FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are     */
@@ -137,11 +137,11 @@
                              FT_RFork_Ref*  b )
   {
     if ( a->res_id < b->res_id )
-      return ( -1 );
+      return -1;
     else if ( a->res_id > b->res_id )
-      return ( 1 );
+      return 1;
     else
-      return ( 0 );
+      return 0;
   }
 
 
@@ -154,12 +154,12 @@
                               FT_Long   **offsets,
                               FT_Long    *count )
   {
-    FT_Error   error;
-    int        i, j, cnt, subcnt;
-    FT_Long    tag_internal, rpos;
-    FT_Memory  memory = library->memory;
-    FT_Long    temp;
-    FT_Long    *offsets_internal;
+    FT_Error      error;
+    int           i, j, cnt, subcnt;
+    FT_Long       tag_internal, rpos;
+    FT_Memory     memory = library->memory;
+    FT_Long       temp;
+    FT_Long       *offsets_internal;
     FT_RFork_Ref  *ref;
 
 
@@ -210,7 +210,7 @@
           ref[j].offset = temp & 0xFFFFFFL;
         }
 
-	ft_qsort( ref, *count, sizeof( FT_RFork_Ref ),
+        ft_qsort( ref, *count, sizeof ( FT_RFork_Ref ),
                   ( int(*)(const void*, const void*) )
                   ft_raccess_sort_ref_by_id );
 
@@ -225,8 +225,9 @@
           offsets_internal[j] = rdata_pos + ref[j].offset;
 
         *offsets = offsets_internal;
-        error = FT_Err_Ok;
-Exit:
+        error    = FT_Err_Ok;
+
+      Exit:
         FT_FREE( ref );
         return error;
       }
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 5a4a544..add1dd2 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -144,10 +144,10 @@
 
 #include "ftsmerrs.h"
 
-#define ErrRaster_Invalid_Mode     Smooth_Err_Cannot_Render_Glyph
-#define ErrRaster_Invalid_Outline  Smooth_Err_Invalid_Outline
-#define ErrRaster_Memory_Overflow  Smooth_Err_Out_Of_Memory
-#define ErrRaster_Invalid_Argument Smooth_Err_Bad_Argument
+#define ErrRaster_Invalid_Mode      Smooth_Err_Cannot_Render_Glyph
+#define ErrRaster_Invalid_Outline   Smooth_Err_Invalid_Outline
+#define ErrRaster_Memory_Overflow   Smooth_Err_Out_Of_Memory
+#define ErrRaster_Invalid_Argument  Smooth_Err_Bad_Argument
 
 #endif /* !_STANDALONE_ */
 
@@ -1659,7 +1659,7 @@
     ras.count_ex = ras.max_ex - ras.min_ex;
     ras.count_ey = ras.max_ey - ras.min_ey;
 
-    /* simple heuristic used to speed-up the bezier decomposition -- see */
+    /* simple heuristic used to speed up the bezier decomposition -- see */
     /* the code in gray_render_conic() and gray_render_cubic() for more  */
     /* details                                                           */
     ras.conic_level = 32;
@@ -1796,11 +1796,14 @@
     if ( !raster || !raster->buffer || !raster->buffer_size )
       return ErrRaster_Invalid_Argument;
 
+    if ( !outline )
+      return ErrRaster_Invalid_Outline;
+
     /* return immediately if the outline is empty */
     if ( outline->n_points == 0 || outline->n_contours <= 0 )
       return 0;
 
-    if ( !outline || !outline->contours || !outline->points )
+    if ( !outline->contours || !outline->points )
       return ErrRaster_Invalid_Outline;
 
     if ( outline->n_points !=
@@ -1850,10 +1853,10 @@
 
     gray_init_cells( worker, raster->buffer, raster->buffer_size );
 
-    ras.outline   = *outline;
-    ras.num_cells = 0;
-    ras.invalid   = 1;
-    ras.band_size = raster->band_size;
+    ras.outline        = *outline;
+    ras.num_cells      = 0;
+    ras.invalid        = 1;
+    ras.band_size      = raster->band_size;
     ras.num_gray_spans = 0;
 
     if ( target_map )