shithub: freetype+ttf2subf

Download patch

ref: f13516c8321b386227414be01e707563e852fc0d
parent: 1339b974f13e9ff5bc1f2497870f5305a32fee02
author: Werner Lemberg <[email protected]>
date: Thu Mar 3 12:09:08 EST 2005

Various fixes for C and C++ compiling.

* src/autofit/*: Add copyright messages.
  Formatting.

* src/autofit/afhints.c (af_glyph_hints_done): Don't use
`AF_Dimension' but `int' for loop counter.

* src/autofit/aflatin.c (af_latin_metrics_init_widths): Don't use
`AF_Dimension' but `int' for loop counter.
Use proper enumeration value for `render_mode'.
(af_latin_metrics_scale_dim): Don't shadow variables.
(af_latin_hints_compute_segments): Use proper cast for `major_dir'
and `segment_dir'.
(af_latin_align_linked_edge, af_latin_hint_edges): Fix arguments of call to
`af_latin_compute_stem_width'.
(af_latin_hints_apply): Don't use `AF_Dimension' but `int' for loop
counter.

* src/base/ftdbgmem.c (ft_mem_table_get_source, FT_DumpMemory): Use
proper cast for memory allocation.

* src/cff/cffdrivr.c (cff_get_kerning): Use proper cast for
initialization of `sfnt'.

* src/sfnt/sfdriver.c: Include `ttkern.h'.

* src/sfnt/ttkern.c (tt_face_get_kerning): Don't shadow variables.

* src/truetype/ttgload.c: Include `ttpload.h'.

* src/truetype/ttpload.c (tt_face_load_loca) [FT_OPTIMIZE_MEMORY]:
Remove redundant variable.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,19 +1,55 @@
 2005-03-04  David Turner  <[email protected]>
 
-    * include/freetype/internal/{ftmemory.h,ftserv.h}: removing
-    compiler warnings with GCC 3.3 and above...
+	* include/freetype/internal/{ftmemory.h,ftserv.h}: removing
+	compiler warnings with GCC 3.3 and above...
 
-    * include/freetype/internal/ftobjs.h, src/base/ftutil.c (ft_highpow2),
-    src/pfr/pfrload.c, src/pfr/pfrobjs.c, src/pfr/pfrtypes.h: implement
-    FT_OPTIMIZE_MEMORY, the kerning table is not loaded into the heap
-    anymore.
+	* include/freetype/internal/ftobjs.h, src/base/ftutil.c (ft_highpow2),
+	src/pfr/pfrload.c, src/pfr/pfrobjs.c, src/pfr/pfrtypes.h: implement
+	FT_OPTIMIZE_MEMORY, the kerning table is not loaded into the heap
+	anymore.
 
-    * src/sfnt/ttsbit0.c, src/truetype/ttpload.c: removing compiler
-    warnings
+	* src/sfnt/ttsbit0.c (tt_sbit_decoder_load_image): Introduce
+	temporary variable to avoid gcc warning.
+	(tt_face_load_sbit_image): Mark unused variables with FT_UNUSED.
 
-    * include/freetype/config/ftmodule.h: moving the order of drivers to
-    speed up font loading. the pcf and bdf loaders are still slow and
-    eat memory like crazy.
+	* include/freetype/config/ftmodule.h: moving the order of drivers to
+	speed up font loading. the pcf and bdf loaders are still slow and
+	eat memory like crazy.
+
+2005-03-03  Werner Lemberg  <[email protected]>
+
+	Various fixes for C and C++ compiling.
+
+	* src/autofit/*: Add copyright messages.
+
+	* src/autofit/afhints.c (af_glyph_hints_done): Don't use
+	`AF_Dimension' but `int' for loop counter.
+
+	* src/autofit/aflatin.c (af_latin_metrics_init_widths): Don't use
+	`AF_Dimension' but `int' for loop counter.
+	Use proper enumeration value for `render_mode'.
+	(af_latin_metrics_scale_dim): Don't shadow variables.
+	(af_latin_hints_compute_segments): Use proper cast for `major_dir'
+	and `segment_dir'.
+	(af_latin_align_linked_edge, af_latin_hint_edges): Fix arguments of call to
+	`af_latin_compute_stem_width'.
+	(af_latin_hints_apply): Don't use `AF_Dimension' but `int' for loop
+	counter.
+
+	* src/base/ftdbgmem.c (ft_mem_table_get_source, FT_DumpMemory): Use
+	proper cast for memory allocation.
+
+	* src/cff/cffdrivr.c (cff_get_kerning): Use proper cast for
+	initialization of `sfnt'.
+
+	* src/sfnt/sfdriver.c: Include `ttkern.h'.
+
+	* src/sfnt/ttkern.c (tt_face_get_kerning): Don't shadow variables.
+
+	* src/truetype/ttgload.c: Include `ttpload.h'.
+
+	* src/truetype/ttpload.c (tt_face_load_loca) [FT_OPTIMIZE_MEMORY]:
+	Remove redundant variable.
 
 2005-03-03  Werner Lemberg  <[email protected]>
 
--- a/src/autofit/Jamfile
+++ b/src/autofit/Jamfile
@@ -1,3 +1,6 @@
+# FreeType 2 src/autofit Jamfile (c) 2003, 2004, 2005 David Turner
+#
+
 SubDir FT2_TOP src autofit ;
 
 {
@@ -15,4 +18,4 @@
   Library  $(FT2_LIB) : $(_sources).c ;
 }
 
-# end of src/autofir Jamfile
+# end of src/autofit Jamfile
--- a/src/autofit/afangles.c
+++ b/src/autofit/afangles.c
@@ -1,5 +1,25 @@
+/***************************************************************************/
+/*                                                                         */
+/*  afangles.c                                                             */
+/*                                                                         */
+/*    Routines used to compute vector angles with limited accuracy         */
+/*    and very high speed.  It also contains sorting routines (body).      */
+/*                                                                         */
+/*  Copyright 2003, 2004, 2005 by                                          */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #include "aftypes.h"
 
+
 /*
  * a python script used to generate the following table
  *
@@ -6,30 +26,29 @@
 
 import sys, math
 
-units  = 256
-scale  = units/math.pi
-comma  = ""
+units = 256
+scale = units/math.pi
+comma = ""
 
 print ""
-print "table of arctan( 1/2^n ) for PI = " + repr(units/65536.0) + " units"
+print "table of arctan( 1/2^n ) for PI = " + repr( units / 65536.0 ) + " units"
 
-r = [-1] + range(32)
+r = [-1] + range( 32 )
 
 for n in r:
-
     if n >= 0:
-        x = 1.0/(2.0**n)    # tangent value
+        x = 1.0 / ( 2.0 ** n )   # tangent value
     else:
-        x = 2.0**(-n)
+        x = 2.0 ** ( -n )
 
-    angle  = math.atan(x)    # arctangent
-    angle2 = angle*scale     # arctangent in FT_Angle units
+    angle  = math.atan( x )      # arctangent
+    angle2 = angle * scale       # arctangent in FT_Angle units
 
     # determine which integer value for angle gives the best tangent
-    lo  = int(angle2)
+    lo  = int( angle2 )
     hi  = lo + 1
-    tlo = math.tan(lo/scale)
-    thi = math.tan(hi/scale)
+    tlo = math.tan( lo / scale )
+    thi = math.tan( hi / scale )
 
     errlo = abs( tlo - x )
     errhi = abs( thi - x )
@@ -41,7 +60,7 @@
     if angle2 <= 0:
         break
 
-    sys.stdout.write( comma + repr( int(angle2) ) )
+    sys.stdout.write( comma + repr( int( angle2 ) ) )
     comma = ", "
 
 *
@@ -122,7 +141,7 @@
     }
 
     if ( y > 0 )
-      theta = - theta;
+      theta = -theta;
 
     arctanptr = af_angle_arctan_table;
 
@@ -167,9 +186,9 @@
 #if 0
     /* round theta */
     if ( theta >= 0 )
-      theta =   FT_PAD_ROUND( theta, 2 );
+      theta =  FT_PAD_ROUND( theta, 2 );
     else
-      theta = - FT_PAD_ROUND( -theta, 2 );
+      theta = -FT_PAD_ROUND( -theta, 2 );
 #endif
 
     vec->x = x;
@@ -177,7 +196,7 @@
   }
 
 
-  /* documentation is in fttrigon.h */
+  /* cf. documentation in fttrigon.h */
 
   FT_LOCAL_DEF( AF_Angle )
   af_angle_atan( FT_Fixed  dx,
@@ -198,7 +217,6 @@
   }
 
 
-
   FT_LOCAL_DEF( AF_Angle )
   af_angle_diff( AF_Angle  angle1,
                  AF_Angle  angle2 )
@@ -205,6 +223,7 @@
   {
     AF_Angle  delta = angle2 - angle1;
 
+
     delta %= AF_ANGLE_2PI;
     if ( delta < 0 )
       delta += AF_ANGLE_2PI;
@@ -216,12 +235,9 @@
   }
 
 
- /* well, this needs to be somewhere, right :-)
-  */
-
   FT_LOCAL_DEF( void )
-  af_sort_pos( FT_UInt   count,
-               FT_Pos*   table )
+  af_sort_pos( FT_UInt  count,
+               FT_Pos*  table )
   {
     FT_UInt  i, j;
     FT_Pos   swap;
@@ -266,6 +282,7 @@
 
 
 #ifdef TEST
+
 #include <stdio.h>
 #include <math.h>
 
@@ -274,19 +291,21 @@
   int  angle;
   int  dist;
 
+
   for ( dist = 100; dist < 1000; dist++ )
   {
-    for ( angle = AF_ANGLE_PI; angle < AF_ANGLE_2PI*4; angle++ )
+    for ( angle = AF_ANGLE_PI; angle < AF_ANGLE_2PI * 4; angle++ )
     {
-      double a = (angle*3.1415926535)/(1.0*AF_ANGLE_PI);
-      int    dx, dy, angle1, angle2, delta;
+      double  a = ( angle * 3.1415926535 ) / ( 1.0 * AF_ANGLE_PI );
+      int     dx, dy, angle1, angle2, delta;
 
-      dx = dist * cos(a);
-      dy = dist * sin(a);
 
-      angle1  = ((atan2(dy,dx)*AF_ANGLE_PI)/3.1415926535);
-      angle2  = af_angle_atan( dx, dy );
-      delta   = (angle2 - angle1) % AF_ANGLE_2PI;
+      dx = dist * cos( a );
+      dy = dist * sin( a );
+
+      angle1 = ( ( atan2( dy, dx ) * AF_ANGLE_PI ) / 3.1415926535 );
+      angle2 = af_angle_atan( dx, dy );
+      delta  = ( angle2 - angle1 ) % AF_ANGLE_2PI;
       if ( delta < 0 )
         delta = -delta;
 
@@ -299,4 +318,8 @@
   }
   return 0;
 }
-#endif
+
+#endif /* TEST */
+
+
+/* END */
--- a/src/autofit/afdummy.c
+++ b/src/autofit/afdummy.c
@@ -1,3 +1,22 @@
+/***************************************************************************/
+/*                                                                         */
+/*  afdummy.c                                                              */
+/*                                                                         */
+/*    Auto-fitter dummy routines to be used if no hinting should be        */
+/*    performed (body).                                                    */
+/*                                                                         */
+/*  Copyright 2003, 2004, 2005 by                                          */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #include "afdummy.h"
 #include "afhints.h"
 
@@ -11,6 +30,7 @@
     return 0;
   }
 
+
   static FT_Error
   af_dummy_hints_apply( AF_GlyphHints  hints,
                         FT_Outline*    outline )
@@ -29,12 +49,13 @@
     NULL,
 
     sizeof( AF_ScriptMetricsRec ),
-    (AF_Script_InitMetricsFunc)  NULL,
-    (AF_Script_ScaleMetricsFunc) NULL,
-    (AF_Script_DoneMetricsFunc)  NULL,
 
-    (AF_Script_InitHintsFunc)    af_dummy_hints_init,
-    (AF_Script_ApplyHintsFunc)   af_dummy_hints_apply
+    (AF_Script_InitMetricsFunc) NULL,
+    (AF_Script_ScaleMetricsFunc)NULL,
+    (AF_Script_DoneMetricsFunc) NULL,
+
+    (AF_Script_InitHintsFunc)   af_dummy_hints_init,
+    (AF_Script_ApplyHintsFunc)  af_dummy_hints_apply
   };
 
 
--- a/src/autofit/afdummy.h
+++ b/src/autofit/afdummy.h
@@ -1,12 +1,32 @@
+/***************************************************************************/
+/*                                                                         */
+/*  afdummy.h                                                              */
+/*                                                                         */
+/*    Auto-fitter dummy routines to be used if no hinting should be        */
+/*    performed (specification).                                           */
+/*                                                                         */
+/*  Copyright 2003, 2004, 2005 by                                          */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #ifndef __AFDUMMY_H__
 #define __AFDUMMY_H__
 
 #include "aftypes.h"
 
+
 FT_BEGIN_HEADER
 
- /* A dummy script metrics class used when no hinting should
-  * be performed.  This is the default for non-latin glyphs!
+ /*  A dummy script metrics class used when no hinting should
+  *  be performed.  This is the default for non-latin glyphs!
   */
 
   FT_CALLBACK_TABLE const AF_ScriptClassRec
@@ -15,6 +35,7 @@
 /* */
 
 FT_END_HEADER
+
 
 #endif /* __AFDUMMY_H__ */
 
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -1,52 +1,70 @@
+/***************************************************************************/
+/*                                                                         */
+/*  afglobal.c                                                             */
+/*                                                                         */
+/*    Auto-fitter routines to compute global hinting values (body).        */
+/*                                                                         */
+/*  Copyright 2003, 2004, 2005 by                                          */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #include "afglobal.h"
 #include "afdummy.h"
 #include "aflatin.h"
 
- /* populate this list when you add new scripts
-  */
-  static AF_ScriptClass const   af_script_classes[] =
+
+  /* populate this list when you add new scripts */
+  static AF_ScriptClass const  af_script_classes[] =
   {
-    & af_dummy_script_class,
-    & af_latin_script_class,
+    &af_dummy_script_class,
+    &af_latin_script_class,
 
     NULL  /* do not remove */
   };
 
-#define AF_SCRIPT_LIST_DEFAULT   1    /* index of default script in 'af_script_classes' */
-#define AF_SCRIPT_LIST_NONE      255  /* indicates an uncovered glyph                      */
+  /* index of default script in `af_script_classes' */
+#define AF_SCRIPT_LIST_DEFAULT  1
+  /* indicates an uncovered glyph                   */
+#define AF_SCRIPT_LIST_NONE   255
 
- /*
-  *  note that glyph_scripts[] is used to map each glyph into
-  *  an index into the 'af_script_classes' array.
-  *
-  */
-  typedef struct AF_FaceGlobalsRec_
+
+  /*
+   *  Note that glyph_scripts[] is used to map each glyph into
+   *  an index into the `af_script_classes' array.
+   *
+   */
+  typedef struct  AF_FaceGlobalsRec_
   {
-    FT_Face            face;
-    FT_UInt            glyph_count;    /* same as face->num_glyphs     */
-    FT_Byte*           glyph_scripts;
+    FT_Face           face;
+    FT_UInt           glyph_count;    /* same as face->num_glyphs */
+    FT_Byte*          glyph_scripts;
 
-    AF_ScriptMetrics   metrics[ AF_SCRIPT_MAX ];
+    AF_ScriptMetrics  metrics[AF_SCRIPT_MAX];
 
   } AF_FaceGlobalsRec;
 
 
+  /* Compute the script index of each glyph within a given face. */
 
-
- /* this function is used to compute the script index of each glyph
-  * within a given face
-  */
   static FT_Error
   af_face_globals_compute_script_coverage( AF_FaceGlobals  globals )
   {
-    FT_Error    error       = 0;
+    FT_Error    error       = FT_Err_Ok;
     FT_Face     face        = globals->face;
     FT_CharMap  old_charmap = face->charmap;
     FT_Byte*    gscripts    = globals->glyph_scripts;
     FT_UInt     ss;
 
-   /* the value 255 means "uncovered glyph"
-    */
+
+    /* the value 255 means `uncovered glyph' */
     FT_MEM_SET( globals->glyph_scripts,
                 AF_SCRIPT_LIST_NONE,
                 globals->glyph_count );
@@ -54,39 +72,43 @@
     error = FT_Select_Charmap( face, FT_ENCODING_UNICODE );
     if ( error )
     {
-     /* ignore this error, we'll simply use Latin as the standard
-      * script. XXX: Shouldn't we rather disable hinting ??
+     /*
+      *  Ignore this error; we simply use Latin as the standard
+      *  script.  XXX: Shouldn't we rather disable hinting?
       */
-      error = 0;
+      error = FT_Err_Ok;
       goto Exit;
     }
 
-   /* scan each script in a Unicode charmap
-    */
+    /* scan each script in a Unicode charmap */
     for ( ss = 0; af_script_classes[ss]; ss++ )
     {
       AF_ScriptClass      clazz = af_script_classes[ss];
       AF_Script_UniRange  range;
 
+
       if ( clazz->script_uni_ranges == NULL )
         continue;
 
-     /* scan all unicode points in the range, and set the corresponding
-      * glyph script index
-      */
+      /*
+       *  Scan all unicode points in the range and set the corresponding
+       *  glyph script index.
+       */
       for ( range = clazz->script_uni_ranges; range->first != 0; range++ )
       {
         FT_ULong  charcode = range->first;
         FT_UInt   gindex;
 
+
         gindex = FT_Get_Char_Index( face, charcode );
 
-        if ( gindex != 0                               &&
-             gindex < globals->glyph_count             &&
-             gscripts[ gindex ] == AF_SCRIPT_LIST_NONE )
+        if ( gindex != 0                             &&
+             gindex < globals->glyph_count           &&
+             gscripts[gindex] == AF_SCRIPT_LIST_NONE )
         {
-          gscripts[ gindex ] = (FT_Byte) ss;
+          gscripts[gindex] = (FT_Byte)ss;
         }
+
         for (;;)
         {
           charcode = FT_Get_Next_Char( face, charcode, &gindex );
@@ -94,10 +116,10 @@
           if ( gindex == 0 || charcode > range->last )
             break;
 
-          if ( gindex < globals->glyph_count       &&
-               gscripts[ gindex ] == AF_SCRIPT_LIST_NONE )
+          if ( gindex < globals->glyph_count           &&
+               gscripts[gindex] == AF_SCRIPT_LIST_NONE )
           {
-            gscripts[ gindex ] = (FT_Byte) ss;
+            gscripts[gindex] = (FT_Byte)ss;
           }
         }
       }
@@ -104,16 +126,18 @@
     }
 
   Exit:
-   /* by default, all uncovered glyphs are set to the latin script
-    * XXX: shouldnt' we disable hinting or do something similar ?
-    */
+    /*
+     *  By default, all uncovered glyphs are set to the latin script.
+     *  XXX: Shouldnt' we disable hinting or do something similar?
+     */
     {
       FT_UInt  nn;
 
+
       for ( nn = 0; nn < globals->glyph_count; nn++ )
       {
-        if ( gscripts[ nn ] == AF_SCRIPT_LIST_NONE )
-          gscripts[ nn ] = AF_SCRIPT_LIST_DEFAULT;
+        if ( gscripts[nn] == AF_SCRIPT_LIST_NONE )
+          gscripts[nn] = AF_SCRIPT_LIST_DEFAULT;
       }
     }
 
@@ -122,7 +146,6 @@
   }
 
 
-
   FT_LOCAL_DEF( FT_Error )
   af_face_globals_new( FT_Face          face,
                        AF_FaceGlobals  *aglobals )
@@ -131,14 +154,15 @@
     FT_Memory       memory;
     AF_FaceGlobals  globals;
 
+
     memory = face->memory;
 
-    if ( !FT_ALLOC( globals, sizeof(*globals) +
-                             face->num_glyphs*sizeof(FT_Byte) ) )
+    if ( !FT_ALLOC( globals, sizeof ( *globals ) +
+                             face->num_glyphs * sizeof ( FT_Byte ) ) )
     {
       globals->face          = face;
       globals->glyph_count   = face->num_glyphs;
-      globals->glyph_scripts = (FT_Byte*)( globals+1 );
+      globals->glyph_scripts = (FT_Byte*)( globals + 1 );
 
       error = af_face_globals_compute_script_coverage( globals );
       if ( error )
@@ -161,6 +185,7 @@
       FT_Memory  memory = globals->face->memory;
       FT_UInt    nn;
 
+
       for ( nn = 0; nn < AF_SCRIPT_MAX; nn++ )
       {
         if ( globals->metrics[nn] )
@@ -167,6 +192,7 @@
         {
           AF_ScriptClass  clazz = af_script_classes[nn];
 
+
           FT_ASSERT( globals->metrics[nn]->clazz == clazz );
 
           if ( clazz->script_metrics_done )
@@ -177,8 +203,9 @@
       }
 
       globals->glyph_count   = 0;
-      globals->glyph_scripts = NULL;  /* no need to free this one !! */
+      globals->glyph_scripts = NULL;  /* no need to free this one! */
       globals->face          = NULL;
+
       FT_FREE( globals );
     }
   }
@@ -194,6 +221,7 @@
     AF_ScriptClass    clazz;
     FT_Error          error = 0;
 
+
     if ( gindex >= globals->glyph_count )
     {
       error = FT_Err_Invalid_Argument;
@@ -200,15 +228,15 @@
       goto Exit;
     }
 
-    index   = globals->glyph_scripts[ gindex ];
-    clazz   = af_script_classes[ index ];
-    metrics = globals->metrics[ clazz->script ];
+    index   = globals->glyph_scripts[gindex];
+    clazz   = af_script_classes[index];
+    metrics = globals->metrics[clazz->script];
     if ( metrics == NULL )
     {
-     /* create the global metrics object when needed
-      */
+      /* create the global metrics object when needed */
       FT_Memory  memory = globals->face->memory;
 
+
       if ( FT_ALLOC( metrics, clazz->script_metrics_size ) )
         goto Exit;
 
@@ -227,10 +255,14 @@
         }
       }
 
-      globals->metrics[ clazz->script ] = metrics;
+      globals->metrics[clazz->script] = metrics;
     }
 
   Exit:
     *ametrics = metrics;
+
     return error;
   }
+
+
+/* END */
--- a/src/autofit/afglobal.h
+++ b/src/autofit/afglobal.h
@@ -1,24 +1,45 @@
+/***************************************************************************/
+/*                                                                         */
+/*  afglobal.h                                                             */
+/*                                                                         */
+/*    Auto-fitter routines to compute global hinting values                */
+/*    (specification).                                                     */
+/*                                                                         */
+/*  Copyright 2003, 2004, 2005 by                                          */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #ifndef __AF_GLOBAL_H__
 #define __AF_GLOBAL_H__
 
+
 #include "aftypes.h"
 
+
 FT_BEGIN_HEADER
 
- /**************************************************************************/
- /**************************************************************************/
- /*****                                                                *****/
- /*****                F A C E   G L O B A L S                         *****/
- /*****                                                                *****/
- /**************************************************************************/
- /**************************************************************************/
 
+  /************************************************************************/
+  /************************************************************************/
+  /*****                                                              *****/
+  /*****                  F A C E   G L O B A L S                     *****/
+  /*****                                                              *****/
+  /************************************************************************/
+  /************************************************************************/
 
- /*
-  *  models the global hints data for a given face, decomposed into
-  *  script-specific items..
-  *
-  */
+
+  /*
+   *  model the global hints data for a given face, decomposed into
+   *  script-specific items
+   */
   typedef struct AF_FaceGlobalsRec_*   AF_FaceGlobals;
 
 
@@ -36,6 +57,10 @@
 
  /* */
 
+
 FT_END_HEADER
 
 #endif /* __AF_GLOBALS_H__ */
+
+
+/* END */
--- a/src/autofit/afhints.c
+++ b/src/autofit/afhints.c
@@ -1,3 +1,21 @@
+/***************************************************************************/
+/*                                                                         */
+/*  afhints.c                                                              */
+/*                                                                         */
+/*    Auto-fitter hinting routines (body).                                 */
+/*                                                                         */
+/*  Copyright 2003, 2004, 2005 by                                          */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #include "afhints.h"
 
 
@@ -6,7 +24,7 @@
                              FT_Memory     memory,
                              AF_Segment   *asegment )
   {
-    FT_Error    error   = 0;
+    FT_Error    error   = FT_Err_Ok;
     AF_Segment  segment = NULL;
 
 
@@ -42,13 +60,13 @@
   }
 
 
-  FT_LOCAL( FT_Error)
+  FT_LOCAL( FT_Error )
   af_axis_hints_new_edge( AF_AxisHints  axis,
                           FT_Int        fpos,
                           FT_Memory     memory,
                           AF_Edge      *aedge )
   {
-    FT_Error  error = 0;
+    FT_Error  error = FT_Err_Ok;
     AF_Edge   edge  = NULL;
     AF_Edge   edges;
 
@@ -286,15 +304,15 @@
     /* do each contour separately */
     for ( ; contour < contour_limit; contour++ )
     {
-      AF_Point   point = contour[0];
-      AF_Point   first = point;
-      AF_Point   start = point;
-      AF_Point   end   = point;
-      AF_Point   before;
-      AF_Point   after;
-      AF_Angle   angle_in, angle_seg, angle_out;
-      AF_Angle   diff_in, diff_out;
-      FT_Int     finished = 0;
+      AF_Point  point = contour[0];
+      AF_Point  first = point;
+      AF_Point  start = point;
+      AF_Point  end   = point;
+      AF_Point  before;
+      AF_Point  after;
+      AF_Angle  angle_in, angle_seg, angle_out;
+      AF_Angle  diff_in, diff_out;
+      FT_Int    finished = 0;
 
 
       /* compute first segment in contour */
@@ -397,8 +415,8 @@
   {
     if ( hints && hints->memory )
     {
-      FT_Memory     memory = hints->memory;
-      AF_Dimension  dim;
+      FT_Memory  memory = hints->memory;
+      int        dim;
 
 
       /*
@@ -405,7 +423,7 @@
        *  note that we don't need to free the segment and edge
        *  buffers, since they are really within the hints->points array
        */
-      for ( dim = 0; dim < 2; dim++ )
+      for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
       {
         AF_AxisHints  axis = &hints->axis[dim];
 
@@ -455,9 +473,9 @@
     FT_Memory  memory  = hints->memory;
 
 
-    hints->scaler_flags  = scaler->flags;
-    hints->num_points    = 0;
-    hints->num_contours  = 0;
+    hints->scaler_flags = scaler->flags;
+    hints->num_points   = 0;
+    hints->num_contours = 0;
 
     hints->axis[0].num_segments = 0;
     hints->axis[0].num_edges    = 0;
@@ -478,7 +496,7 @@
     }
 
     /*
-     *  then, reallocate the points arrays if needed --
+     *  then reallocate the points arrays if necessary --
      *  note that we reserve two additional point positions, used to
      *  hint metrics appropriately
      */
@@ -547,7 +565,6 @@
             break;
           default:
             point->flags = 0;
-            ;
           }
         }
       }
@@ -861,7 +878,6 @@
         }
 
       Store_Point:
-
         /* save the point position */
         if ( dim == AF_DIMENSION_HORZ )
           point->x = u;
@@ -970,14 +986,14 @@
   af_glyph_hints_align_weak_points( AF_GlyphHints  hints,
                                     AF_Dimension   dim )
   {
-    AF_Point    points        = hints->points;
-    AF_Point    point_limit   = points + hints->num_points;
-    AF_Point*   contour       = hints->contours;
-    AF_Point*   contour_limit = contour + hints->num_contours;
-    AF_Flags    touch_flag;
-    AF_Point    point;
-    AF_Point    end_point;
-    AF_Point    first_point;
+    AF_Point   points        = hints->points;
+    AF_Point   point_limit   = points + hints->num_points;
+    AF_Point*  contour       = hints->contours;
+    AF_Point*  contour_limit = contour + hints->num_contours;
+    AF_Flags   touch_flag;
+    AF_Point   point;
+    AF_Point   end_point;
+    AF_Point   first_point;
 
 
     /* PASS 1: Move segment points to edge positions */
--- a/src/autofit/afhints.h
+++ b/src/autofit/afhints.h
@@ -1,20 +1,40 @@
+/***************************************************************************/
+/*                                                                         */
+/*  afhints.h                                                              */
+/*                                                                         */
+/*    Auto-fitter hinting routines (specification).                        */
+/*                                                                         */
+/*  Copyright 2003, 2004, 2005 by                                          */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #ifndef __AFHINTS_H__
 #define __AFHINTS_H__
 
 #include "aftypes.h"
 
+
 FT_BEGIN_HEADER
 
  /*
-  *  The definition of outline glyph hints. These are shared by all
-  *  script analysis routines (until now)
-  *
+  *  The definition of outline glyph hints.  These are shared by all
+  *  script analysis routines (until now).
   */
 
   typedef enum
   {
-    AF_DIMENSION_HORZ = 0,  /* x coordinates, i.e. vertical segments & edges   */
-    AF_DIMENSION_VERT = 1,  /* y coordinates, i.e. horizontal segments & edges */
+    AF_DIMENSION_HORZ = 0,  /* x coordinates,                    */
+                            /* i.e., vertical segments & edges   */
+    AF_DIMENSION_VERT = 1,  /* y coordinates,                    */
+                            /* i.e., horizontal segments & edges */
 
     AF_DIMENSION_MAX  /* do not remove */
 
@@ -22,7 +42,7 @@
 
 
   /* hint directions -- the values are computed so that two vectors are */
-  /* in opposite directions iff `dir1+dir2 == 0'                        */
+  /* in opposite directions iff `dir1 + dir2 == 0'                      */
   typedef enum
   {
     AF_DIR_NONE  =  4,
@@ -37,30 +57,30 @@
   /* point hint flags */
   typedef enum
   {
-    AF_FLAG_NONE    = 0,
+    AF_FLAG_NONE = 0,
 
-   /* point type flags */
-    AF_FLAG_CONIC   = (1 << 0),
-    AF_FLAG_CUBIC   = (1 << 1),
+    /* point type flags */
+    AF_FLAG_CONIC   = 1 << 0,
+    AF_FLAG_CUBIC   = 1 << 1,
     AF_FLAG_CONTROL = AF_FLAG_CONIC | AF_FLAG_CUBIC,
 
-   /* point extremum flags */
-    AF_FLAG_EXTREMA_X = (1 << 2),
-    AF_FLAG_EXTREMA_Y = (1 << 3),
+    /* point extremum flags */
+    AF_FLAG_EXTREMA_X = 1 << 2,
+    AF_FLAG_EXTREMA_Y = 1 << 3,
 
-   /* point roundness flags */
-    AF_FLAG_ROUND_X = (1 << 4),
-    AF_FLAG_ROUND_Y = (1 << 5),
+    /* point roundness flags */
+    AF_FLAG_ROUND_X = 1 << 4,
+    AF_FLAG_ROUND_Y = 1 << 5,
 
-   /* point touch flags */
-    AF_FLAG_TOUCH_X = (1 << 6),
-    AF_FLAG_TOUCH_Y = (1 << 7),
+    /* point touch flags */
+    AF_FLAG_TOUCH_X = 1 << 6,
+    AF_FLAG_TOUCH_Y = 1 << 7,
 
-   /* candidates for weak interpolation have this flag set */
-    AF_FLAG_WEAK_INTERPOLATION = (1 << 8),
+    /* candidates for weak interpolation have this flag set */
+    AF_FLAG_WEAK_INTERPOLATION = 1 << 8,
 
-   /* all inflection points in the outline have this flag set */
-    AF_FLAG_INFLECTION         = (1 << 9)
+    /* all inflection points in the outline have this flag set */
+    AF_FLAG_INFLECTION = 1 << 9
 
   } AF_Flags;
 
@@ -69,14 +89,13 @@
   typedef enum
   {
     AF_EDGE_NORMAL = 0,
-    AF_EDGE_ROUND  = (1 << 0),
-    AF_EDGE_SERIF  = (1 << 1),
-    AF_EDGE_DONE   = (1 << 2)
+    AF_EDGE_ROUND  = 1 << 0,
+    AF_EDGE_SERIF  = 1 << 1,
+    AF_EDGE_DONE   = 1 << 2
 
   } AF_Edge_Flags;
 
 
-
   typedef struct AF_PointRec_*    AF_Point;
   typedef struct AF_SegmentRec_*  AF_Segment;
   typedef struct AF_EdgeRec_*     AF_Edge;
@@ -84,17 +103,17 @@
 
   typedef struct  AF_PointRec_
   {
-    FT_UShort     flags;    /* point flags used by hinter */
-    FT_Char       in_dir;   /* direction of inwards vector  */
-    FT_Char       out_dir;  /* direction of outwards vector */
+    FT_UShort  flags;    /* point flags used by hinter   */
+    FT_Char    in_dir;   /* direction of inwards vector  */
+    FT_Char    out_dir;  /* direction of outwards vector */
 
-    FT_Pos        ox, oy;   /* original, scaled position  */
-    FT_Short      fx, fy;   /* original, unscaled position (font units) */
-    FT_Pos        x,  y;    /* current position */
-    FT_Pos        u,  v;    /* current (x,y) or (y,x) depending on context */
+    FT_Pos     ox, oy;   /* original, scaled position                   */
+    FT_Short   fx, fy;   /* original, unscaled position (font units)    */
+    FT_Pos     x, y;     /* current position                            */
+    FT_Pos     u, v;     /* current (x,y) or (y,x) depending on context */
 
-    AF_Point      next;     /* next point in contour     */
-    AF_Point      prev;     /* previous point in contour */
+    AF_Point   next;     /* next point in contour     */
+    AF_Point   prev;     /* previous point in contour */
 
   } AF_PointRec;
 
@@ -101,23 +120,23 @@
 
   typedef struct  AF_SegmentRec_
   {
-    FT_Byte        flags;       /* edge/segment flags for this segment */
-    FT_Char        dir;         /* segment direction                   */
-    FT_Short       pos;         /* position of segment                 */
-    FT_Short       min_coord;   /* minimum coordinate of segment       */
-    FT_Short       max_coord;   /* maximum coordinate of segment       */
+    FT_Byte     flags;       /* edge/segment flags for this segment */
+    FT_Char     dir;         /* segment direction                   */
+    FT_Short    pos;         /* position of segment                 */
+    FT_Short    min_coord;   /* minimum coordinate of segment       */
+    FT_Short    max_coord;   /* maximum coordinate of segment       */
 
-    AF_Edge        edge;        /* the segment's parent edge */
-    AF_Segment     edge_next;   /* link to next segment in parent edge */
+    AF_Edge     edge;        /* the segment's parent edge           */
+    AF_Segment  edge_next;   /* link to next segment in parent edge */
 
-    AF_Segment     link;        /* (stem) link segment        */
-    AF_Segment     serif;       /* primary segment for serifs */
-    FT_Pos         num_linked;  /* number of linked segments  */
-    FT_Pos         score;       /* used during stem matching  */
+    AF_Segment  link;        /* (stem) link segment        */
+    AF_Segment  serif;       /* primary segment for serifs */
+    FT_Pos      num_linked;  /* number of linked segments  */
+    FT_Pos      score;       /* used during stem matching  */
 
-    AF_Point       first;       /* first point in edge segment             */
-    AF_Point       last;        /* last point in edge segment              */
-    AF_Point*      contour;     /* ptr to first point of segment's contour */
+    AF_Point    first;       /* first point in edge segment             */
+    AF_Point    last;        /* last point in edge segment              */
+    AF_Point*   contour;     /* ptr to first point of segment's contour */
 
   } AF_SegmentRec;
 
@@ -124,28 +143,28 @@
 
   typedef struct  AF_EdgeRec_
   {
-    FT_Short       fpos;       /* original, unscaled position (font units) */
-    FT_Pos         opos;       /* original, scaled position                */
-    FT_Pos         pos;        /* current position                         */
+    FT_Short    fpos;       /* original, unscaled position (font units) */
+    FT_Pos      opos;       /* original, scaled position                */
+    FT_Pos      pos;        /* current position                         */
 
-    FT_Byte        flags;      /* edge flags */
-    FT_Char        dir;        /* edge direction */
-    FT_Fixed       scale;      /* used to speed up interpolation between edges */
-    AF_Width       blue_edge;  /* non-NULL if this is a blue edge              */
+    FT_Byte     flags;      /* edge flags                                   */
+    FT_Char     dir;        /* edge direction                               */
+    FT_Fixed    scale;      /* used to speed up interpolation between edges */
+    AF_Width    blue_edge;  /* non-NULL if this is a blue edge              */
 
-    AF_Edge        link;
-    AF_Edge        serif;
-    FT_Short       num_linked;
+    AF_Edge     link;
+    AF_Edge     serif;
+    FT_Short    num_linked;
 
-    FT_Int         score;
+    FT_Int      score;
 
-    AF_Segment     first;
-    AF_Segment     last;
+    AF_Segment  first;
+    AF_Segment  last;
 
   } AF_EdgeRec;
 
 
-  typedef struct AF_AxisHintsRec_
+  typedef struct  AF_AxisHintsRec_
   {
     FT_Int        num_segments;
     FT_Int        max_segments;
@@ -160,46 +179,47 @@
   } AF_AxisHintsRec, *AF_AxisHints;
 
 
-  typedef struct AF_GlyphHintsRec_
+  typedef struct  AF_GlyphHintsRec_
   {
-    FT_Memory     memory;
+    FT_Memory         memory;
 
-    FT_Fixed      x_scale;
-    FT_Pos        x_delta;
+    FT_Fixed          x_scale;
+    FT_Pos            x_delta;
 
-    FT_Fixed      y_scale;
-    FT_Pos        y_delta;
+    FT_Fixed          y_scale;
+    FT_Pos            y_delta;
 
-    FT_Pos        edge_distance_threshold;
+    FT_Pos            edge_distance_threshold;
 
-    FT_Int        max_points;
-    FT_Int        num_points;
-    AF_Point      points;
+    FT_Int            max_points;
+    FT_Int            num_points;
+    AF_Point          points;
 
-    FT_Int        max_contours;
-    FT_Int        num_contours;
-    AF_Point*     contours;
+    FT_Int            max_contours;
+    FT_Int            num_contours;
+    AF_Point*         contours;
 
-    AF_AxisHintsRec  axis[ AF_DIMENSION_MAX ];
+    AF_AxisHintsRec   axis[AF_DIMENSION_MAX];
 
-    FT_UInt32         scaler_flags;  /* copy of scaler flags */
-    FT_UInt32         other_flags;   /* free for script-specific implementations */
+    FT_UInt32         scaler_flags;  /* copy of scaler flags     */
+    FT_UInt32         other_flags;   /* free for script-specific */
+                                     /* implementations          */
     AF_ScriptMetrics  metrics;
 
   } AF_GlyphHintsRec;
 
 
-#define  AF_HINTS_TEST_SCALER(h,f)  ( (h)->scaler_flags & (f) )
-#define  AF_HINTS_TEST_OTHER(h,f)   ( (h)->other_flags  & (f) )
+#define AF_HINTS_TEST_SCALER( h, f )  ( (h)->scaler_flags & (f) )
+#define AF_HINTS_TEST_OTHER( h, f )   ( (h)->other_flags  & (f) )
 
-#define  AF_HINTS_DO_HORIZONTAL(h)  \
-            !AF_HINTS_TEST_SCALER(h,AF_SCALER_FLAG_NO_HORIZONTAL)
+#define AF_HINTS_DO_HORIZONTAL( h )                                \
+          !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_HORIZONTAL )
 
-#define  AF_HINTS_DO_VERTICAL(h)    \
-            !AF_HINTS_TEST_SCALER(h,AF_SCALER_FLAG_NO_VERTICAL)
+#define AF_HINTS_DO_VERTICAL( h )                                \
+          !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_VERTICAL )
 
-#define  AF_HINTS_DO_ADVANCE(h)     \
-            !AF_HINTS_TEST_SCALER(h,AF_SCALER_FLAG_NO_ADVANCE)
+#define AF_HINTS_DO_ADVANCE( h )                                \
+          !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_ADVANCE )
 
 
   FT_LOCAL( AF_Direction )
@@ -224,20 +244,21 @@
 
 
 
- /*  recomputes all AF_Point in a AF_GlyphHints from the definitions
-  *  in a source outline
-  */
+  /*
+   *  recompute all AF_Point in a AF_GlyphHints from the definitions
+   *  in a source outline
+   */
   FT_LOCAL( void )
   af_glyph_hints_rescale( AF_GlyphHints     hints,
                           AF_ScriptMetrics  metrics );
 
   FT_LOCAL( FT_Error )
-  af_glyph_hints_reload( AF_GlyphHints     hints,
-                         FT_Outline*       outline );
+  af_glyph_hints_reload( AF_GlyphHints  hints,
+                         FT_Outline*    outline );
 
   FT_LOCAL( void )
-  af_glyph_hints_save( AF_GlyphHints   hints,
-                       FT_Outline*     outline );
+  af_glyph_hints_save( AF_GlyphHints  hints,
+                       FT_Outline*    outline );
 
   FT_LOCAL( void )
   af_glyph_hints_align_edge_points( AF_GlyphHints  hints,
@@ -256,6 +277,10 @@
 
 /* */
 
+
 FT_END_HEADER
 
 #endif /* __AFHINTS_H__ */
+
+
+/* END */
\ No newline at end of file
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -1,3 +1,21 @@
+/***************************************************************************/
+/*                                                                         */
+/*  aflatin.c                                                              */
+/*                                                                         */
+/*    Auto-fitter hinting routines for latin script (body).                */
+/*                                                                         */
+/*  Copyright 2003, 2004, 2005 by                                          */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #include "aflatin.h"
 
 
@@ -26,7 +44,7 @@
     {
       FT_Error             error;
       FT_UInt              glyph_index;
-      AF_Dimension         dim;
+      int                  dim;
       AF_ScriptMetricsRec  dummy[1];
       AF_Scaler            scaler = &dummy->scaler;
 
@@ -44,7 +62,7 @@
       scaler->x_scale     = scaler->y_scale = 0x10000L;
       scaler->x_delta     = scaler->y_delta = 0;
       scaler->face        = face;
-      scaler->render_mode = 0;
+      scaler->render_mode = FT_RENDER_MODE_NORMAL;
       scaler->flags       = 0;
 
       af_glyph_hints_rescale( hints, dummy );
@@ -63,11 +81,13 @@
         FT_Pos        edge_distance_threshold = 32000;
 
 
-        error = af_latin_hints_compute_segments( hints, dim );
+        error = af_latin_hints_compute_segments( hints,
+                                                 (AF_Dimension)dim );
         if ( error )
           goto Exit;
 
-        af_latin_hints_link_segments( hints, dim );
+        af_latin_hints_link_segments( hints,
+                                      (AF_Dimension)dim );
 
         seg   = axhints->segments;
         limit = seg + axhints->num_segments;
@@ -399,7 +419,7 @@
       delta = scaler->y_delta;
     }
 
-    axis = & metrics->axis[dim];
+    axis = &metrics->axis[dim];
 
     if ( axis->org_scale == scale && axis->org_delta == delta )
       return;
@@ -412,16 +432,15 @@
      * letters to the pixel grid
      */
     {
-      AF_LatinAxis  axis = &metrics->axis[AF_DIMENSION_VERT];
+      AF_LatinAxis  Axis = &metrics->axis[AF_DIMENSION_VERT];
       AF_LatinBlue  blue = NULL;
-      FT_UInt       nn;
 
 
-      for ( nn = 0; nn < axis->blue_count; nn++ )
+      for ( nn = 0; nn < Axis->blue_count; nn++ )
       {
-        if ( axis->blues[nn].flags & AF_LATIN_BLUE_ADJUSTMENT )
+        if ( Axis->blues[nn].flags & AF_LATIN_BLUE_ADJUSTMENT )
         {
-          blue = &axis->blues[nn];
+          blue = &Axis->blues[nn];
           break;
         }
       }
@@ -490,12 +509,12 @@
         dist = FT_MulFix( blue->ref.org - blue->shoot.org, scale );
         if ( dist <= 48 && dist >= -48 )
         {
-          FT_Pos  delta, delta2;
+          FT_Pos  delta1, delta2;
 
 
-          delta  = blue->shoot.org - blue->ref.org;
-          delta2 = delta;
-          if ( delta < 0 )
+          delta1 = blue->shoot.org - blue->ref.org;
+          delta2 = delta1;
+          if ( delta1 < 0 )
             delta2 = -delta2;
 
           delta2 = FT_MulFix( delta2, scale );
@@ -507,7 +526,7 @@
           else
             delta2 = FT_PIX_ROUND( delta2 );
 
-          if ( delta < 0 )
+          if ( delta1 < 0 )
             delta2 = -delta2;
 
           blue->ref.fit   = FT_PIX_ROUND( blue->ref.cur );
@@ -556,7 +575,7 @@
     FT_Pos    max_coord = -32000;
 #endif
 
-    major_dir   = FT_ABS( axis->major_dir );
+    major_dir   = (AF_Direction)FT_ABS( axis->major_dir );
     segment_dir = major_dir;
 
     axis->num_segments = 0;
@@ -690,7 +709,7 @@
         if ( !on_edge && FT_ABS( point->out_dir ) == major_dir )
         {
           /* this is the start of a new segment! */
-          segment_dir = point->out_dir;
+          segment_dir = (AF_Direction)point->out_dir;
 
           /* clear all segment fields */
           error = af_axis_hints_new_segment( axis, memory, &segment );
@@ -1508,11 +1527,10 @@
   {
     FT_Pos  dist = stem_edge->opos - base_edge->opos;
 
-    FT_Pos  fitted_width = af_latin_compute_stem_width( hints,
-                                                        dim,
-                                                        dist,
-                                                        base_edge->flags,
-                                                        stem_edge->flags );
+    FT_Pos  fitted_width = af_latin_compute_stem_width(
+                             hints, dim, dist,
+                             (AF_Edge_Flags)base_edge->flags,
+                             (AF_Edge_Flags)stem_edge->flags );
 
 
     stem_edge->pos = base_edge->pos + fitted_width;
@@ -1635,8 +1653,10 @@
 
 
         org_len = edge2->opos - edge->opos;
-        cur_len = af_latin_compute_stem_width( hints, dim, org_len,
-                                               edge->flags, edge2->flags );
+        cur_len = af_latin_compute_stem_width(
+                    hints, dim, org_len,
+                    (AF_Edge_Flags)edge->flags,
+                    (AF_Edge_Flags)edge2->flags );
         if ( cur_len <= 64 )
           u_off = d_off = 32;
         else
@@ -1687,8 +1707,10 @@
         org_len    = edge2->opos - edge->opos;
         org_center = org_pos + ( org_len >> 1 );
 
-        cur_len = af_latin_compute_stem_width( hints, dim, org_len,
-                                               edge->flags, edge2->flags  );
+        cur_len = af_latin_compute_stem_width(
+                   hints, dim, org_len,
+                   (AF_Edge_Flags)edge->flags,
+                   (AF_Edge_Flags)edge2->flags );
 
         if ( cur_len < 96 )
         {
@@ -1728,7 +1750,9 @@
           org_center = org_pos + ( org_len >> 1 );
 
           cur_len    = af_latin_compute_stem_width(
-                         hints, dim, org_len, edge->flags, edge2->flags );
+                         hints, dim, org_len,
+                         (AF_Edge_Flags)edge->flags,
+                         (AF_Edge_Flags)edge2->flags );
 
           cur_pos1   = FT_PIX_ROUND( org_pos );
           delta1     = cur_pos1 + ( cur_len >> 1 ) - org_center;
@@ -1855,8 +1879,8 @@
                         FT_Outline*      outline,
                         AF_LatinMetrics  metrics )
   {
-    FT_Error      error;
-    AF_Dimension  dim;
+    FT_Error  error;
+    int       dim;
 
 
     error = af_glyph_hints_reload( hints, outline );
@@ -1886,10 +1910,10 @@
       if ( ( dim == AF_DIMENSION_HORZ && AF_HINTS_DO_HORIZONTAL( hints ) ) ||
            ( dim == AF_DIMENSION_VERT && AF_HINTS_DO_VERTICAL( hints ) )   )
       {
-        af_latin_hint_edges( hints, dim );
-        af_glyph_hints_align_edge_points( hints, dim );
-        af_glyph_hints_align_strong_points( hints, dim );
-        af_glyph_hints_align_weak_points( hints, dim );
+        af_latin_hint_edges( hints, (AF_Dimension)dim );
+        af_glyph_hints_align_edge_points( hints, (AF_Dimension)dim );
+        af_glyph_hints_align_strong_points( hints, (AF_Dimension)dim );
+        af_glyph_hints_align_weak_points( hints, (AF_Dimension)dim );
       }
     }
     af_glyph_hints_save( hints, outline );
--- a/src/autofit/aflatin.h
+++ b/src/autofit/aflatin.h
@@ -1,3 +1,21 @@
+/***************************************************************************/
+/*                                                                         */
+/*  aflatin.h                                                              */
+/*                                                                         */
+/*    Auto-fitter hinting routines for latin script (specification).       */
+/*                                                                         */
+/*  Copyright 2003, 2004, 2005 by                                          */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #ifndef __AFLATIN_H__
 #define __AFLATIN_H__
 
@@ -54,10 +72,10 @@
 
   enum
   {
-    AF_LATIN_BLUE_ACTIVE     = ( 1 << 0 ),
-    AF_LATIN_BLUE_TOP        = ( 1 << 1 ),
-    AF_LATIN_BLUE_ADJUSTMENT = ( 1 << 2 ),  /* used for scale adjustment */
-                                            /* optimization              */
+    AF_LATIN_BLUE_ACTIVE     = 1 << 0,
+    AF_LATIN_BLUE_TOP        = 1 << 1,
+    AF_LATIN_BLUE_ADJUSTMENT = 1 << 2,  /* used for scale adjustment */
+                                        /* optimization              */
     AF_LATIN_BLUE_FLAG_MAX
   };
 
@@ -120,12 +138,12 @@
 
   enum
   {
-    AF_LATIN_HINTS_HORZ_SNAP   = ( 1 << 0 ), /* enable stem width snapping  */
-    AF_LATIN_HINTS_VERT_SNAP   = ( 1 << 1 ), /* enable stem height snapping */
-    AF_LATIN_HINTS_STEM_ADJUST = ( 1 << 2 ), /* enable stem width/height
-                                                adjustment                  */
-    AF_LATIN_HINTS_MONO        = ( 1 << 3 )  /* indicate monochrome
-                                                rendering                   */
+    AF_LATIN_HINTS_HORZ_SNAP   = 1 << 0, /* enable stem width snapping  */
+    AF_LATIN_HINTS_VERT_SNAP   = 1 << 1, /* enable stem height snapping */
+    AF_LATIN_HINTS_STEM_ADJUST = 1 << 2, /* enable stem width/height    */
+                                         /* adjustment                  */
+    AF_LATIN_HINTS_MONO        = 1 << 3  /* indicate monochrome         */
+                                         /* rendering                   */
   };
 
 
--- a/src/autofit/afloader.c
+++ b/src/autofit/afloader.c
@@ -1,3 +1,21 @@
+/***************************************************************************/
+/*                                                                         */
+/*  afloader.c                                                             */
+/*                                                                         */
+/*    Auto-fitter glyph loading routines (body).                           */
+/*                                                                         */
+/*  Copyright 2003, 2004, 2005 by                                          */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #include "afloader.h"
 #include "afhints.h"
 #include "afglobal.h"
@@ -167,7 +185,7 @@
       {
         FT_Pos        old_advance, old_rsb, old_lsb, new_lsb;
         FT_Pos        pp1x_uh, pp2x_uh;
-        AF_AxisHints  axis  = &hints->axis[ AF_DIMENSION_HORZ ];
+        AF_AxisHints  axis  = &hints->axis[AF_DIMENSION_HORZ];
         AF_Edge       edge1 = axis->edges;         /* leftmost edge  */
         AF_Edge       edge2 = edge1 +
                               axis->num_edges - 1; /* rightmost edge */
--- a/src/autofit/afloader.h
+++ b/src/autofit/afloader.h
@@ -1,3 +1,21 @@
+/***************************************************************************/
+/*                                                                         */
+/*  afloader.h                                                             */
+/*                                                                         */
+/*    Auto-fitter glyph loading routines (specification).                  */
+/*                                                                         */
+/*  Copyright 2003, 2004, 2005 by                                          */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #ifndef __AF_LOADER_H__
 #define __AF_LOADER_H__
 
@@ -4,6 +22,7 @@
 #include "afhints.h"
 #include "afglobal.h"
 
+
 FT_BEGIN_HEADER
 
   typedef struct AF_LoaderRec_
@@ -45,6 +64,10 @@
 
 /* */
 
+
 FT_END_HEADER
 
 #endif /* __AF_LOADER_H__ */
+
+
+/* END */
--- a/src/autofit/afmodule.c
+++ b/src/autofit/afmodule.c
@@ -1,7 +1,27 @@
+/***************************************************************************/
+/*                                                                         */
+/*  afmodule.c                                                             */
+/*                                                                         */
+/*    Auto-fitter module implementation (body).                            */
+/*                                                                         */
+/*  Copyright 2003, 2004, 2005 by                                          */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #include "afmodule.h"
 #include "afloader.h"
+
 #include FT_INTERNAL_OBJECTS_H
 
+
   typedef struct  FT_AutofitterRec_
   {
     FT_ModuleRec  root;
@@ -38,7 +58,6 @@
   }
 
 
-
   FT_CALLBACK_TABLE_DEF
   const FT_AutoHinter_ServiceRec  af_autofitter_service =
   {
@@ -45,7 +64,7 @@
     NULL,
     NULL,
     NULL,
-    (FT_AutoHinter_GlyphLoadFunc) af_autofitter_load_glyph
+    (FT_AutoHinter_GlyphLoadFunc)af_autofitter_load_glyph
   };
 
 
@@ -59,11 +78,11 @@
     0x10000L,   /* version 1.0 of the autofitter  */
     0x20000L,   /* requires FreeType 2.0 or above */
 
-    (const void*) &af_autofitter_service,
+    (const void*)&af_autofitter_service,
 
-    (FT_Module_Constructor) af_autofitter_init,
-    (FT_Module_Destructor)  af_autofitter_done,
-    (FT_Module_Requester)   0
+    (FT_Module_Constructor)af_autofitter_init,
+    (FT_Module_Destructor) af_autofitter_done,
+    (FT_Module_Requester)  NULL
   };
 
 
--- a/src/autofit/afmodule.h
+++ b/src/autofit/afmodule.h
@@ -1,3 +1,21 @@
+/***************************************************************************/
+/*                                                                         */
+/*  afmodule.h                                                             */
+/*                                                                         */
+/*    Auto-fitter module implementation (specification).                   */
+/*                                                                         */
+/*  Copyright 2003, 2004, 2005 by                                          */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #ifndef __AFMODULE_H__
 #define __AFMODULE_H__
 
@@ -14,3 +32,6 @@
 FT_END_HEADER
 
 #endif /* __AFMODULE_H__ */
+
+
+/* END */
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -1,61 +1,82 @@
+/***************************************************************************/
+/*                                                                         */
+/*  aftypes.h                                                              */
+/*                                                                         */
+/*    Auto-fitter types (specification only).                              */
+/*                                                                         */
+/*  Copyright 2003, 2004, 2005 by                                          */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 /***************************************************************************
  *
- *  FreeType auto-fitter
- *
- *  (c) 2004 David Turner
- *
  *  The auto-fitter is a complete rewrite of the old auto-hinter.
- *  its main feature is the ability to differentiate between different
+ *  Its main feature is the ability to differentiate between different
  *  scripts in order to apply language-specific rules.
  *
- *  the code has also been compartimentized into several entities that
+ *  The code has also been compartimentized into several entities that
  *  should make algorithmic experimentation easier than with the old
  *  code.
  *
- *  finally, we get rid of the Catharon license, since this code is
+ *  Finally, we get rid of the Catharon license, since this code is
  *  released under the FreeType one.
- */
+ *
+ ***************************************************************************/
+
+
 #ifndef __AFTYPES_H__
 #define __AFTYPES_H__
 
 #include <ft2build.h>
+
 #include FT_FREETYPE_H
 #include FT_OUTLINE_H
 #include FT_INTERNAL_OBJECTS_H
 #include FT_INTERNAL_DEBUG_H
 
+
 FT_BEGIN_HEADER
 
- /**************************************************************************/
- /**************************************************************************/
- /*****                                                                *****/
- /*****                D E B U G G I N G                               *****/
- /*****                                                                *****/
- /**************************************************************************/
- /**************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                    D E B U G G I N G                          *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
 
 #define xxAF_DEBUG
 
 #ifdef AF_DEBUG
 
-#  include <stdio.h>
-#  define AF_LOG( x )  printf x
+#include <stdio.h>
 
+#define AF_LOG( x )  printf x
+
 #else
 
-#  define AF_LOG( x )  do ; while ( 0 ) /* nothing */
+#define AF_LOG( x )  do ; while ( 0 )        /* nothing */
 
 #endif /* AF_DEBUG */
 
- /**************************************************************************/
- /**************************************************************************/
- /*****                                                                *****/
- /*****                U T I L I T Y                                   *****/
- /*****                                                                *****/
- /**************************************************************************/
- /**************************************************************************/
 
-  typedef struct AF_WidthRec_
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                 U T I L I T Y   S T U F F                     *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
+
+  typedef struct  AF_WidthRec_
   {
     FT_Pos  org;  /* original position/width in font units              */
     FT_Pos  cur;  /* current/scaled position/width in device sub-pixels */
@@ -65,8 +86,8 @@
 
 
   FT_LOCAL( void )
-  af_sort_pos( FT_UInt   count,
-               FT_Pos*   table );
+  af_sort_pos( FT_UInt  count,
+               FT_Pos*  table );
 
   FT_LOCAL( void )
   af_sort_widths( FT_UInt   count,
@@ -73,91 +94,89 @@
                   AF_Width  widths );
 
 
- /**************************************************************************/
- /**************************************************************************/
- /*****                                                                *****/
- /*****                A N G L E   T Y P E S                           *****/
- /*****                                                                *****/
- /**************************************************************************/
- /**************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                   A N G L E   T Y P E S                       *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
 
- /*
-  *  Angle type. The auto-fitter doesn't need a very high angular accuracy,
-  *  and this allows us to speed up some computations considerably with a
-  *  light Cordic algorithm (see afangles.c)
-  *
-  */
+  /*
+   *  The auto-fitter doesn't need a very high angular accuracy;
+   *  this allows us to speed up some computations considerably with a
+   *  light Cordic algorithm (see afangles.c).
+   */
 
-  typedef FT_Int    AF_Angle;
+  typedef FT_Int  AF_Angle;
 
-#define  AF_ANGLE_PI     256
-#define  AF_ANGLE_2PI    (AF_ANGLE_PI*2)
-#define  AF_ANGLE_PI2    (AF_ANGLE_PI/2)
-#define  AF_ANGLE_PI4    (AF_ANGLE_PI/4)
 
- /*
-  *  compute the angle of a given 2-D vector
-  *
-  */
+#define AF_ANGLE_PI   256
+#define AF_ANGLE_2PI  ( AF_ANGLE_PI * 2 )
+#define AF_ANGLE_PI2  ( AF_ANGLE_PI / 2 )
+#define AF_ANGLE_PI4  ( AF_ANGLE_PI / 4 )
+
+
+  /*
+   *  compute the angle of a given 2-D vector
+   */
   FT_LOCAL( AF_Angle )
   af_angle_atan( FT_Pos  dx,
                  FT_Pos  dy );
 
 
- /*
-  *  computes "angle2 - angle1", the result is always within
-  *  the range [ -AF_ANGLE_PI .. AF_ANGLE_PI-1 ]
-  *
-  */
+  /*
+   *  compute `angle2 - angle1'; the result is always within
+   *  the range [-AF_ANGLE_PI .. AF_ANGLE_PI - 1]
+   */
   FT_LOCAL( AF_Angle )
   af_angle_diff( AF_Angle  angle1,
                  AF_Angle  angle2 );
 
 
- /**************************************************************************/
- /**************************************************************************/
- /*****                                                                *****/
- /*****                O U T L I N E S                                 *****/
- /*****                                                                *****/
- /**************************************************************************/
- /**************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                    O U T L I N E S                            *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
 
- /* opaque handle to glyph-specific hints. see "afhints.h" for more
-  * details
-  */
-  typedef struct AF_GlyphHintsRec_*     AF_GlyphHints;
+  /*  opaque handle to glyph-specific hints -- see `afhints.h' for more
+   *  details
+   */
+  typedef struct AF_GlyphHintsRec_*  AF_GlyphHints;
 
- /* this structure is used to model an input glyph outline to
-  * the auto-hinter. The latter will set the "hints" field
-  * depending on the glyph's script
-  */
-  typedef struct AF_OutlineRec_
+  /*  This structure is used to model an input glyph outline to
+   *  the auto-hinter.  The latter will set the `hints' field
+   *  depending on the glyph's script.
+   */
+  typedef struct  AF_OutlineRec_
   {
-    FT_Face          face;
-    FT_Outline       outline;
-    FT_UInt          outline_resolution;
+    FT_Face        face;
+    FT_Outline     outline;
+    FT_UInt        outline_resolution;
 
-    FT_Int           advance;
-    FT_UInt          metrics_resolution;
+    FT_Int         advance;
+    FT_UInt        metrics_resolution;
 
-    AF_GlyphHints    hints;
+    AF_GlyphHints  hints;
 
   } AF_OutlineRec;
 
 
- /**************************************************************************/
- /**************************************************************************/
- /*****                                                                *****/
- /*****                S C A L E R S                                   *****/
- /*****                                                                *****/
- /**************************************************************************/
- /**************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                       S C A L E R S                           *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
 
- /*
-  *  A scaler models the target pixel device that will receive the
-  *  auto-hinted glyph image
-  *
-  */
+  /*
+   *  A scaler models the target pixel device that will receive the
+   *  auto-hinted glyph image.
+   */
 
   typedef enum
   {
@@ -168,59 +187,61 @@
   } AF_ScalerFlags;
 
 
-  typedef struct AF_ScalerRec_
+  typedef struct  AF_ScalerRec_
   {
-    FT_Face         face;         /* source font face                        */
-    FT_Fixed        x_scale;      /* from font units to 1/64th device pixels */
-    FT_Fixed        y_scale;      /* from font units to 1/64th device pixels */
-    FT_Pos          x_delta;      /* in 1/64th device pixels                 */
-    FT_Pos          y_delta;      /* in 1/64th device pixels                 */
-    FT_Render_Mode  render_mode;  /* monochrome, anti-aliased, LCD, etc..    */
-    FT_UInt32       flags;        /* additionnal control flags, see above    */
+    FT_Face         face;        /* source font face                        */
+    FT_Fixed        x_scale;     /* from font units to 1/64th device pixels */
+    FT_Fixed        y_scale;     /* from font units to 1/64th device pixels */
+    FT_Pos          x_delta;     /* in 1/64th device pixels                 */
+    FT_Pos          y_delta;     /* in 1/64th device pixels                 */
+    FT_Render_Mode  render_mode; /* monochrome, anti-aliased, LCD, etc.     */
+    FT_UInt32       flags;       /* additional control flags, see above     */
 
   } AF_ScalerRec, *AF_Scaler;
 
 
-#define  AF_SCALER_EQUAL_SCALES(a,b)    \
-   ( (a)->x_scale == (b)->x_scale &&    \
-     (a)->y_scale == (b)->y_scale &&    \
-     (a)->x_delta == (b)->x_delta &&    \
-     (a)->y_delta == (b)->y_delta )
+#define AF_SCALER_EQUAL_SCALES( a, b )      \
+          ( (a)->x_scale == (b)->x_scale && \
+            (a)->y_scale == (b)->y_scale && \
+            (a)->x_delta == (b)->x_delta && \
+            (a)->y_delta == (b)->y_delta )
 
 
- /**************************************************************************/
- /**************************************************************************/
- /*****                                                                *****/
- /*****                S C R I P T S                                   *****/
- /*****                                                                *****/
- /**************************************************************************/
- /**************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                       S C R I P T S                           *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
 
- /*
-  *  the list of know scripts. Each different script correspond to the
-  *  following information:
-  *
-  *   - a set of Unicode ranges to test weither the face supports the
-  *     script
-  *
-  *   - a specific global analyzer that will compute global metrics
-  *     specific to the script.
-  *
-  *   - a specific glyph analyzer that will compute segments and
-  *     edges for each glyph covered by the script
-  *
-  *   - a specific grid-fitting algorithm that will distort the
-  *     scaled glyph outline according to the results of the glyph
-  *     analyzer
-  *
-  *  note that a given analyzer and/or grid-fitting algorithm can be
-  *  used by more than one script
-  */
+  /*
+   *  The list of know scripts.  Each different script corresponds to the
+   *  following information:
+   *
+   *   - A set of Unicode ranges to test whether the face supports the
+   *     script.
+   *
+   *   - A specific global analyzer that will compute global metrics
+   *     specific to the script.
+   *
+   *   - A specific glyph analyzer that will compute segments and
+   *     edges for each glyph covered by the script.
+   *
+   *   - A specific grid-fitting algorithm that will distort the
+   *     scaled glyph outline according to the results of the glyph
+   *     analyzer.
+   *
+   *  Note that a given analyzer and/or grid-fitting algorithm can be
+   *  used by more than one script.
+   */
+
   typedef enum
   {
     AF_SCRIPT_NONE  = 0,
     AF_SCRIPT_LATIN = 1,
-    /* add new scripts here. don't forget to update the list in "afglobal.c" */
+    /* add new scripts here.  Don't forget to update the list in */
+    /* `afglobal.c'.                                             */
 
     AF_SCRIPT_MAX   /* do not remove */
 
@@ -227,50 +248,55 @@
   } AF_Script;
 
 
-
   typedef struct AF_ScriptClassRec_ const*  AF_ScriptClass;
 
-  typedef struct AF_ScriptMetricsRec_
+  typedef struct  AF_ScriptMetricsRec_
   {
-    AF_ScriptClass    clazz;
-    AF_ScalerRec      scaler;
+    AF_ScriptClass  clazz;
+    AF_ScalerRec    scaler;
 
   } AF_ScriptMetricsRec, *AF_ScriptMetrics;
 
 
- /* this function parses a FT_Face to compute global metrics for
-  * a specific script
-  */
-  typedef FT_Error  (*AF_Script_InitMetricsFunc)( AF_ScriptMetrics   metrics,
-                                                  FT_Face            face );
+  /*  This function parses an FT_Face to compute global metrics for
+   *  a specific script.
+   */
+  typedef FT_Error
+  (*AF_Script_InitMetricsFunc)( AF_ScriptMetrics  metrics,
+                                FT_Face           face );
 
-  typedef void      (*AF_Script_ScaleMetricsFunc)( AF_ScriptMetrics  metrics,
-                                                   AF_Scaler         scaler );
+  typedef void
+  (*AF_Script_ScaleMetricsFunc)( AF_ScriptMetrics  metrics,
+                                 AF_Scaler         scaler );
 
-  typedef void      (*AF_Script_DoneMetricsFunc)( AF_ScriptMetrics   metrics );
+  typedef void
+  (*AF_Script_DoneMetricsFunc)( AF_ScriptMetrics  metrics );
 
 
-  typedef FT_Error  (*AF_Script_InitHintsFunc)( AF_GlyphHints     hints,
-                                                AF_ScriptMetrics  metrics );
+  typedef FT_Error
+  (*AF_Script_InitHintsFunc)( AF_GlyphHints     hints,
+                              AF_ScriptMetrics  metrics );
 
-  typedef void      (*AF_Script_ApplyHintsFunc)( AF_GlyphHints     hints,
-                                                 FT_Outline*       outline,
-                                                 AF_ScriptMetrics  metrics );
+  typedef void
+  (*AF_Script_ApplyHintsFunc)( AF_GlyphHints     hints,
+                               FT_Outline*       outline,
+                               AF_ScriptMetrics  metrics );
 
 
-  typedef struct AF_Script_UniRangeRec_
+  typedef struct  AF_Script_UniRangeRec_
   {
-    FT_UInt32    first;
-    FT_UInt32    last;
+    FT_UInt32  first;
+    FT_UInt32  last;
 
   } AF_Script_UniRangeRec;
 
-  typedef const AF_Script_UniRangeRec *  AF_Script_UniRange;
+  typedef const AF_Script_UniRangeRec  *AF_Script_UniRange;
 
-  typedef struct AF_ScriptClassRec_
+
+  typedef struct  AF_ScriptClassRec_
   {
     AF_Script                   script;
-    AF_Script_UniRange          script_uni_ranges;  /* last must be { 0, 0 } */
+    AF_Script_UniRange          script_uni_ranges; /* last must be { 0, 0 } */
 
     FT_UInt                     script_metrics_size;
     AF_Script_InitMetricsFunc   script_metrics_init;
@@ -288,3 +314,6 @@
 FT_END_HEADER
 
 #endif /* __AFTYPES_H__ */
+
+
+/* END */
--- a/src/autofit/autofit.c
+++ b/src/autofit/autofit.c
@@ -1,3 +1,21 @@
+/***************************************************************************/
+/*                                                                         */
+/*  autofit.c                                                              */
+/*                                                                         */
+/*    Auto-fitter module (body).                                           */
+/*                                                                         */
+/*  Copyright 2003, 2004, 2005 by                                          */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #define FT_MAKE_OPTION_SINGLE_OBJECT
 #include <ft2build.h>
 #include "afangles.c"
@@ -7,3 +25,6 @@
 #include "aflatin.c"
 #include "afloader.c"
 #include "afmodule.c"
+
+
+/* END */
--- a/src/autofit/module.mk
+++ b/src/autofit/module.mk
@@ -3,6 +3,16 @@
 #
 
 
+# Copyright 2003, 2004, 2005 by
+# David Turner, Robert Wilhelm, and Werner Lemberg.
+#
+# This file is part of the FreeType project, and may only be used, modified,
+# and distributed under the terms of the FreeType project license,
+# LICENSE.TXT.  By continuing to use, modify, or distribute this file you
+# indicate that you have read the license and understand and accept it
+# fully.
+
+
 make_module_list: add_autofit_module
 
 add_autofit_module:
--- a/src/autofit/rules.mk
+++ b/src/autofit/rules.mk
@@ -3,6 +3,16 @@
 #
 
 
+# Copyright 2003, 2004, 2005 by
+# David Turner, Robert Wilhelm, and Werner Lemberg.
+#
+# This file is part of the FreeType project, and may only be used, modified,
+# and distributed under the terms of the FreeType project license,
+# LICENSE.TXT.  By continuing to use, modify, or distribute this file you
+# indicate that you have read the license and understand and accept it
+# fully.
+
+
 # AUTOF driver directory
 #
 AUTOF_DIR := $(SRC_DIR)/autofit
--- a/src/autohint/ahangles.c
+++ b/src/autohint/ahangles.c
@@ -1,11 +1,11 @@
 /***************************************************************************/
 /*                                                                         */
-/*  ahangles.h                                                             */
+/*  ahangles.c                                                             */
 /*                                                                         */
-/*    A routine used to compute vector angles with limited accuracy        */
+/*    Routines used to compute vector angles with limited accuracy         */
 /*    and very high speed (body).                                          */
 /*                                                                         */
-/*  Copyright 2000-2001, 2002 Catharon Productions Inc.                    */
+/*  Copyright 2000-2001, 2002, 2005 Catharon Productions Inc.              */
 /*  Author: David Turner                                                   */
 /*                                                                         */
 /*  This file is part of the Catharon Typography Project and shall only    */
@@ -143,5 +143,6 @@
     
     return delta;
   }                 
+
 
 /* END */
--- a/src/base/ftdbgmem.c
+++ b/src/base/ftdbgmem.c
@@ -463,7 +463,7 @@
       pnode = &node->link;
     }
 
-    node = ft_mem_table_alloc( table, sizeof ( *node ) );
+    node = (FT_MemSource)ft_mem_table_alloc( table, sizeof ( *node ) );
     if ( node == NULL )
       ft_mem_debug_panic(
         "not enough memory to perform memory debugging\n" );
@@ -982,7 +982,8 @@
           count++;
       }
 
-      sources = ft_mem_table_alloc( table, sizeof ( *sources ) * count );
+      sources = (FT_MemSource*)ft_mem_table_alloc(
+                                 table, sizeof ( *sources ) * count );
 
       count = 0;
       for ( bucket = table->sources; bucket < limit; bucket++ )
--- a/src/base/fttrigon.c
+++ b/src/base/fttrigon.c
@@ -274,7 +274,7 @@
     if ( theta >= 0 )
       theta = FT_PAD_ROUND( theta, 32 );
     else
-      theta = - FT_PAD_ROUND( -theta, 32 );
+      theta = -FT_PAD_ROUND( -theta, 32 );
 
     vec->x = x;
     vec->y = theta;
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -103,7 +103,7 @@
                    FT_Vector*  kerning )
   {
     TT_Face       face = (TT_Face)ttface;
-    SFNT_Service  sfnt = face->sfnt;
+    SFNT_Service  sfnt = (SFNT_Service)face->sfnt;
 
 
     kerning->x = 0;
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -35,6 +35,7 @@
 #endif
 
 #include "ttcmap.h"
+#include "ttkern.h"
 
 #include FT_SERVICE_GLYPH_DICT_H
 #include FT_SERVICE_POSTSCRIPT_NAME_H
--- a/src/sfnt/ttkern.c
+++ b/src/sfnt/ttkern.c
@@ -246,10 +246,7 @@
           }
           else /* linear search */
           {
-            FT_UInt  count = num_pairs;
-
-
-            for ( ; count > 0; count-- )
+            for ( count = num_pairs; count > 0; count-- )
             {
               FT_ULong  key = FT_NEXT_ULONG( p );
 
--- a/src/sfnt/ttsbit0.c
+++ b/src/sfnt/ttsbit0.c
@@ -791,7 +791,7 @@
     goto NoBitmap;
 
   FoundRange:
-    image_offset = FT_NEXT_ULONG(p);
+    image_offset = FT_NEXT_ULONG( p );
     p = decoder->eblc_base + decoder->strike_index_array + image_offset;
     if ( p + 8 > p_limit )
       goto NoBitmap;
@@ -949,9 +949,10 @@
     TT_SBitDecoderRec  decoder[1];
     FT_Error           error;
 
-    FT_UNUSED(map);
-    FT_UNUSED(stream);
-    FT_UNUSED(load_flags);
+    FT_UNUSED( load_flags );
+    FT_UNUSED( stream );
+    FT_UNUSED( map );
+
 
     error = tt_sbit_decoder_init( decoder, face, strike_index, metrics );
     if ( !error )
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -25,6 +25,7 @@
 #include FT_OUTLINE_H
 
 #include "ttgload.h"
+#include "ttpload.h"
 
 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
 #include "ttgxvar.h"
--- a/src/truetype/ttpload.c
+++ b/src/truetype/ttpload.c
@@ -64,8 +64,8 @@
   tt_face_load_loca( TT_Face    face,
                      FT_Stream  stream )
   {
-    FT_Error   error;
-    FT_ULong   table_len;
+    FT_Error  error;
+    FT_ULong  table_len;
 
 
     FT_TRACE2(( "Locations " ));