shithub: freetype+ttf2subf

Download patch

ref: 1f7f0e87e58168b2e739e2622db0ee06e0c9accc
parent: b3d9f882d0a0fce056d238a507267327301ee456
author: Werner Lemberg <[email protected]>
date: Wed Jun 6 13:30:41 EDT 2001

Complete redesign of error codes.  Please check ftmoderr.h for more
details.

* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed.  Replaced with files
local to the module.  All extra error codes have been moved to
`fterrors.h'.

* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.

* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.

* include/freetype/ftmoderr.h: New file, defining the module error
offsets.  Its structure is similar to `fterrors.h'.

* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.

* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.

All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.

All make files have been updated to include the local error files.


* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.

* src/raster/ftraster.c: Use macros for header file names.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,49 @@
 2001-06-06  Werner Lemberg  <[email protected]>
 
+	Complete redesign of error codes.  Please check ftmoderr.h for more
+	details.
+
+	* include/freetype/internal/cfferrs.h,
+	include/freetype/internal/tterrors.h,
+	include/freetype/internal/t1errors.h: Removed.  Replaced with files
+	local to the module.  All extra error codes have been moved to
+	`fterrors.h'.
+
+	* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
+
+	* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
+	src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
+	src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
+	src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
+	src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
+	error names for the module it belongs to.
+
+	* include/freetype/ftmoderr.h: New file, defining the module error
+	offsets.  Its structure is similar to `fterrors.h'.
+
+	* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
+	(FT_ERRORDEF): Redefined to use module error offsets.
+	All internal error codes are now public; unused error codes have
+	been removed, some are new.
+
+	* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
+	macro.
+	* include/freetype/config/ftoption.h
+	(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
+
+	All other source files have been updated to use the new error codes;
+	some already existing (internal) error codes local to a module have
+	been renamed to give them the same name as in the base module.
+
+	All make files have been updated to include the local error files.
+
+2001-06-06  Werner Lemberg  <[email protected]>
+
+	* src/cid/cidtokens.h: Replaced with...
+	* src/cid/cidtoken.h: This file for 8+3 consistency.
+
+	* src/raster/ftraster.c: Use macros for header file names.
+
 	* src/include/freetype/tttables.h (TT_HoriHeader_, TT_VertHeader_):
 	Fix length of `Reserved' array.  Note that this isn't the real fix
 	since recent OpenType specs have introduced a `CaretOffset' field
--- a/include/freetype/config/ftheader.h
+++ b/include/freetype/config/ftheader.h
@@ -167,6 +167,18 @@
   /*************************************************************************/
   /*                                                                       */
   /* @macro:                                                               */
+  /*    FT_MODULE_ERRORS_H                                                 */
+  /*                                                                       */
+  /* @description:                                                         */
+  /*    A macro used in #include statements to name the file containing    */
+  /*    the list of FreeType 2 module error offsets (and messages).        */
+  /*                                                                       */
+#define FT_MODULE_ERRORS_H  <freetype/ftmoderr.h>
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* @macro:                                                               */
   /*    FT_SYSTEM_H                                                        */
   /*                                                                       */
   /* @description:                                                         */
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -75,6 +75,22 @@
 
   /*************************************************************************/
   /*                                                                       */
+  /* Module errors                                                         */
+  /*                                                                       */
+  /*   If this macro is set (which is the default), the higher byte of an  */
+  /*   error code gives the module in which the error has occurred, while  */
+  /*   the lower byte is the real error code.                              */
+  /*                                                                       */
+  /*   Unsetting this macro makes sense for backwards compatibility; only  */
+  /*   the real error code is emitted, and the higher byte is always zero. */
+  /*                                                                       */
+  /*   More details can be found in the files ftmoderr.h and fterrors.h.   */
+  /*                                                                       */
+#define FT_CONFIG_OPTION_USE_MODULE_ERRORS
+
+
+  /*************************************************************************/
+  /*                                                                       */
   /* Alternate Glyph Image Format support                                  */
   /*                                                                       */
   /*   By default, the glyph images returned by the FreeType glyph loader  */
--- a/include/freetype/fterrors.h
+++ b/include/freetype/fterrors.h
@@ -19,14 +19,25 @@
   /*************************************************************************/
   /*                                                                       */
   /* This file is used to define the FreeType error enumeration constants. */
+  /*                                                                       */
+  /* The lower byte gives the error code, the higher byte gives the        */
+  /* module.  The base module has error offset 0.  For example, the error  */
+  /* `FT_Err_Invalid_File_Format' has value 0x003, the error               */
+  /* `TT_Err_Invalid_File_Format' has value 0xB03, the error               */
+  /* `T1_Err_Invalid_File_Format' has value 0xC03, etc.                    */
+  /*                                                                       */
+  /* Undefine the macro FT_CONFIG_OPTION_USE_MODULE_ERRORS (in ftoption.h) */
+  /* to make the higher byte always zero.                                  */
+  /*                                                                       */
   /* It can also be used to create an error message table easily with      */
   /* something like                                                        */
   /*                                                                       */
   /*   {                                                                   */
   /*     #undef __FTERRORS_H__                                             */
-  /*     #define FT_ERRORDEF( e, v, s )  { e, s },                         */
-  /*     #define FT_ERROR_START_LIST  {                                    */
-  /*     #define FT_ERROR_END_LIST    { 0, 0 } };                          */
+  /*     #define FT_ERRORDEF( e, v, s )   { FT_Err_ ## e, s },             */
+  /*     #define FT_NOERRORDEF( e, v, s ) { FT_Err_ ## e, s },             */
+  /*     #define FT_ERROR_START_LIST      {                                */
+  /*     #define FT_ERROR_END_LIST        { 0, 0 } };                      */
   /*                                                                       */
   /*     const struct                                                      */
   /*     {                                                                 */
@@ -37,8 +48,8 @@
   /*     #include FT_ERRORS_H                                              */
   /*   }                                                                   */
   /*                                                                       */
-  /* For C++ it might be necessary to use `extern "C" {' and to define     */
-  /* FT_NEED_EXTERN_C also.                                                */
+  /* To use such a table, all errors must be ANDed with 0x00FF to remove   */
+  /* the module error offset.                                              */
   /*                                                                       */
   /*************************************************************************/
 
@@ -46,6 +57,7 @@
 #ifndef __FTERRORS_H__
 #define __FTERRORS_H__
 
+#include FT_MODULE_ERRORS_H
 
 #undef FT_NEED_EXTERN_C
 
@@ -52,10 +64,12 @@
 
 #ifndef FT_ERRORDEF
 
-#define FT_ERRORDEF( e, v, s )  e = v,
-#define FT_ERROR_START_LIST     enum {
-#define FT_ERROR_END_LIST       FT_Err_Max };
+#define FT_ERRORDEF( e, v, s )    FT_Err_ ## e = v + FT_Mod_Err_Base,
+#define FT_NOERRORDEF( e, v, s )  FT_Err_ ## e = v,
 
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         FT_Err_Max };
+
 #ifdef __cplusplus
 #define FT_NEED_EXTERN_C
   extern "C" {
@@ -68,120 +82,183 @@
   FT_ERROR_START_LIST
 #endif
 
+
   /* generic errors */
 
-  FT_ERRORDEF( FT_Err_Ok,                           0x0000, \
-               "no error" )
-  FT_ERRORDEF( FT_Err_Cannot_Open_Resource,         0x0001, \
+  FT_NOERRORDEF( Ok,                                        0x00, \
+                 "no error" )
+
+  FT_ERRORDEF( Cannot_Open_Resource,                        0x01, \
                "cannot open resource" )
-  FT_ERRORDEF( FT_Err_Unknown_File_Format,          0x0002, \
+  FT_ERRORDEF( Unknown_File_Format,                         0x02, \
                "unknown file format" )
-  FT_ERRORDEF( FT_Err_Invalid_File_Format,          0x0003, \
+  FT_ERRORDEF( Invalid_File_Format,                         0x03, \
                "broken file" )
-  FT_ERRORDEF( FT_Err_Invalid_Version,              0x0004, \
+  FT_ERRORDEF( Invalid_Version,                             0x04, \
                "invalid FreeType version" )
-  FT_ERRORDEF( FT_Err_Lower_Module_Version,         0x0005, \
+  FT_ERRORDEF( Lower_Module_Version,                        0x05, \
                "module version is too low" )
-  FT_ERRORDEF( FT_Err_Invalid_Argument,             0x0006, \
+  FT_ERRORDEF( Invalid_Argument,                            0x06, \
                "invalid argument" )
-  FT_ERRORDEF( FT_Err_Unimplemented_Feature,        0x0007, \
+  FT_ERRORDEF( Unimplemented_Feature,                       0x07, \
                "unimplemented feature" )
 
   /* glyph/character errors */
 
-  FT_ERRORDEF( FT_Err_Invalid_Glyph_Index,          0x0010, \
+  FT_ERRORDEF( Invalid_Glyph_Index,                         0x10, \
                "invalid glyph index" )
-  FT_ERRORDEF( FT_Err_Invalid_Character_Code,       0x0011, \
+  FT_ERRORDEF( Invalid_Character_Code,                      0x11, \
                "invalid character code" )
-  FT_ERRORDEF( FT_Err_Invalid_Glyph_Format,         0x0012, \
+  FT_ERRORDEF( Invalid_Glyph_Format,                        0x12, \
                "unsupported glyph image format" )
-  FT_ERRORDEF( FT_Err_Cannot_Render_Glyph,          0x0013, \
+  FT_ERRORDEF( Cannot_Render_Glyph,                         0x13, \
                "cannot render this glyph format" )
-  FT_ERRORDEF( FT_Err_Invalid_Outline,              0x0014, \
+  FT_ERRORDEF( Invalid_Outline,                             0x14, \
                "invalid outline" )
-  FT_ERRORDEF( FT_Err_Invalid_Composite,            0x0015, \
+  FT_ERRORDEF( Invalid_Composite,                           0x15, \
                "invalid composite glyph" )
-  FT_ERRORDEF( FT_Err_Too_Many_Hints,               0x0016, \
+  FT_ERRORDEF( Too_Many_Hints,                              0x16, \
                "too many hints" )
-  FT_ERRORDEF( FT_Err_Invalid_Pixel_Size,           0x0017, \
+  FT_ERRORDEF( Invalid_Pixel_Size,                          0x17, \
                "invalid pixel size" )
 
   /* handle errors */
 
-  FT_ERRORDEF( FT_Err_Invalid_Handle,               0x0020, \
+  FT_ERRORDEF( Invalid_Handle,                              0x20, \
                "invalid object handle" )
-  FT_ERRORDEF( FT_Err_Invalid_Library_Handle,       0x0021, \
+  FT_ERRORDEF( Invalid_Library_Handle,                      0x21, \
                "invalid library handle" )
-  FT_ERRORDEF( FT_Err_Invalid_Driver_Handle,        0x0022, \
+  FT_ERRORDEF( Invalid_Driver_Handle,                       0x22, \
                "invalid module handle" )
-  FT_ERRORDEF( FT_Err_Invalid_Face_Handle,          0x0023, \
+  FT_ERRORDEF( Invalid_Face_Handle,                         0x23, \
                "invalid face handle" )
-  FT_ERRORDEF( FT_Err_Invalid_Size_Handle,          0x0024, \
+  FT_ERRORDEF( Invalid_Size_Handle,                         0x24, \
                "invalid size handle" )
-  FT_ERRORDEF( FT_Err_Invalid_Slot_Handle,          0x0025, \
+  FT_ERRORDEF( Invalid_Slot_Handle,                         0x25, \
                "invalid glyph slot handle" )
-  FT_ERRORDEF( FT_Err_Invalid_CharMap_Handle,       0x0026, \
+  FT_ERRORDEF( Invalid_CharMap_Handle,                      0x26, \
                "invalid charmap handle" )
-  FT_ERRORDEF( FT_Err_Invalid_Cache_Handle,         0x0027, \
+  FT_ERRORDEF( Invalid_Cache_Handle,                        0x27, \
                "invalid cache manager handle" )
-  FT_ERRORDEF( FT_Err_Invalid_Stream_Handle,        0x0028, \
+  FT_ERRORDEF( Invalid_Stream_Handle,                       0x28, \
                "invalid stream handle" )
 
   /* driver errors */
 
-  FT_ERRORDEF( FT_Err_Too_Many_Drivers,             0x0030, \
+  FT_ERRORDEF( Too_Many_Drivers,                            0x30, \
                "too many modules" )
-  FT_ERRORDEF( FT_Err_Too_Many_Extensions,          0x0031, \
+  FT_ERRORDEF( Too_Many_Extensions,                         0x31, \
                "too many extensions" )
 
   /* memory errors */
 
-  FT_ERRORDEF( FT_Err_Out_Of_Memory,                0x0040, \
+  FT_ERRORDEF( Out_Of_Memory,                               0x40, \
                "out of memory" )
-  FT_ERRORDEF( FT_Err_Unlisted_Object,              0x0041, \
+  FT_ERRORDEF( Unlisted_Object,                             0x41, \
                "unlisted object" )
 
   /* stream errors */
 
-  FT_ERRORDEF( FT_Err_Cannot_Open_Stream,           0x0051, \
+  FT_ERRORDEF( Cannot_Open_Stream,                          0x51, \
                "cannot open stream" )
-  FT_ERRORDEF( FT_Err_Invalid_Stream_Seek,          0x0052, \
+  FT_ERRORDEF( Invalid_Stream_Seek,                         0x52, \
                "invalid stream seek" )
-  FT_ERRORDEF( FT_Err_Invalid_Stream_Skip,          0x0053, \
+  FT_ERRORDEF( Invalid_Stream_Skip,                         0x53, \
                "invalid stream skip" )
-  FT_ERRORDEF( FT_Err_Invalid_Stream_Read,          0x0054, \
+  FT_ERRORDEF( Invalid_Stream_Read,                         0x54, \
                "invalid stream read" )
-  FT_ERRORDEF( FT_Err_Invalid_Stream_Operation,     0x0055, \
+  FT_ERRORDEF( Invalid_Stream_Operation,                    0x55, \
                "invalid stream operation" )
-  FT_ERRORDEF( FT_Err_Invalid_Frame_Operation,      0x0056, \
+  FT_ERRORDEF( Invalid_Frame_Operation,                     0x56, \
                "invalid frame operation" )
-  FT_ERRORDEF( FT_Err_Nested_Frame_Access,          0x0057, \
+  FT_ERRORDEF( Nested_Frame_Access,                         0x57, \
                "nested frame access" )
-  FT_ERRORDEF( FT_Err_Invalid_Frame_Read,           0x0058, \
+  FT_ERRORDEF( Invalid_Frame_Read,                          0x58, \
                "invalid frame read" )
 
   /* raster errors */
 
-  FT_ERRORDEF( FT_Err_Raster_Uninitialized,         0x0060, \
+  FT_ERRORDEF( Raster_Uninitialized,                        0x60, \
                "raster uninitialized" )
-  FT_ERRORDEF( FT_Err_Raster_Corrupted,             0x0061, \
+  FT_ERRORDEF( Raster_Corrupted,                            0x61, \
                "raster corrupted" )
-  FT_ERRORDEF( FT_Err_Raster_Overflow,              0x0062, \
+  FT_ERRORDEF( Raster_Overflow,                             0x62, \
                "raster overflow" )
-  FT_ERRORDEF( FT_Err_Raster_Negative_Height,       0x0063, \
+  FT_ERRORDEF( Raster_Negative_Height,                      0x63, \
                "negative height while rastering" )
 
   /* cache errors */
 
-  FT_ERRORDEF( FT_Err_Too_Many_Caches,              0x0070, \
+  FT_ERRORDEF( Too_Many_Caches,                             0x70, \
                "too many registered caches" )
 
-  /* range 0x400 - 0x4FF is reserved for TrueType specific stuff */
+  /* TrueType and SFNT errors */
 
-  /* range 0x500 - 0x5FF is reserved for CFF specific stuff */
+  FT_ERRORDEF( Invalid_Opcode,                              0x80, \
+               "invalid opcode" )
+  FT_ERRORDEF( Too_Few_Arguments,                           0x81, \
+               "too few arguments" )
+  FT_ERRORDEF( Stack_Overflow,                              0x82, \
+               "stack overflow" )
+  FT_ERRORDEF( Code_Overflow,                               0x83, \
+               "code overflow" )
+  FT_ERRORDEF( Bad_Argument,                                0x84, \
+               "bad argument" )
+  FT_ERRORDEF( Divide_By_Zero,                              0x85, \
+               "division by zero" )
+  FT_ERRORDEF( Invalid_Reference,                           0x86, \
+               "invalid reference" )
+  FT_ERRORDEF( Debug_OpCode,                                0x87, \
+               "found debug opcode" )
+  FT_ERRORDEF( ENDF_In_Exec_Stream,                         0x88, \
+               "found ENDF opcode in execution stream" )
+  FT_ERRORDEF( Nested_DEFS,                                 0x89, \
+               "nested DEFS" )
+  FT_ERRORDEF( Invalid_CodeRange,                           0x8A, \
+               "invalid code range" )
+  FT_ERRORDEF( Execution_Too_Long,                          0x8B, \
+               "execution context too long" )
+  FT_ERRORDEF( Too_Many_Function_Defs,                      0x8C, \
+               "too many function definitions" )
+  FT_ERRORDEF( Too_Many_Instruction_Defs,                   0x8D, \
+               "too many instruction definitions" )
+  FT_ERRORDEF( Table_Missing,                               0x8E, \
+               "SFNT font table missing" )
+  FT_ERRORDEF( Horiz_Header_Missing,                        0x8F, \
+               "horizontal header (hhea) table missing" )
+  FT_ERRORDEF( Locations_Missing,                           0x90, \
+               "locations (loca) table missing" )
+  FT_ERRORDEF( Name_Table_Missing,                          0x91, \
+               "name table missing" )
+  FT_ERRORDEF( CMap_Table_Missing,                          0x92, \
+               "character map (cmap) table missing" )
+  FT_ERRORDEF( Hmtx_Table_Missing,                          0x93, \
+               "horizontal metrics (hmtx) table missing" )
+  FT_ERRORDEF( Post_Table_Missing,                          0x94, \
+               "PostScript (post) table missing" )
+  FT_ERRORDEF( Invalid_Horiz_Metrics,                       0x95, \
+               "invalid horizontal metrics" )
+  FT_ERRORDEF( Invalid_CharMap_Format,                      0x96, \
+               "invalid character map (cmap) format" )
+  FT_ERRORDEF( Invalid_PPem,                                0x97, \
+               "invalid ppem value" )
+  FT_ERRORDEF( Invalid_Vert_Metrics,                        0x98, \
+               "invalid vertical metrics" )
+  FT_ERRORDEF( Could_Not_Find_Context,                      0x99, \
+               "could not find context" )
+  FT_ERRORDEF( Invalid_Post_Table_Format,                   0x9A, \
+               "invalid PostScript (post) table format" )
+  FT_ERRORDEF( Invalid_Post_Table,                          0x9B, \
+               "invalid PostScript (post) table" )
 
-  /* range 0x600 - 0x6FF is reserved for Type1 specific stuff */
+  /* CFF, CID, and Type 1 errors */
 
+  FT_ERRORDEF( Syntax_Error,                                0xA0, \
+               "opcode syntax error" )
+  FT_ERRORDEF( Stack_Underflow,                             0xA1, \
+               "argument stack underflow" )
+
+
 #ifdef FT_ERROR_END_LIST
   FT_ERROR_END_LIST
 #endif
@@ -190,6 +267,7 @@
 #undef FT_ERROR_START_LIST
 #undef FT_ERROR_END_LIST
 #undef FT_ERRORDEF
+#undef FT_NOERRORDEF
 
 
 #ifdef FT_NEED_EXTERN_C
--- /dev/null
+++ b/include/freetype/ftmoderr.h
@@ -1,0 +1,123 @@
+/***************************************************************************/
+/*                                                                         */
+/*  ftmoderr.h                                                             */
+/*                                                                         */
+/*    FreeType module error offsets (specification).                       */
+/*                                                                         */
+/*  Copyright 2001 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.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the FreeType module error offsets.        */
+  /*                                                                       */
+  /* The lower byte gives the error code, the higher byte gives the        */
+  /* module.  The base module has error offset 0.  For example, the error  */
+  /* `FT_Err_Invalid_File_Format' has value 0x003, the error               */
+  /* `TT_Err_Invalid_File_Format' has value 0xB03, the error               */
+  /* `T1_Err_Invalid_File_Format' has value 0xC03, etc.                    */
+  /*                                                                       */
+  /* Undefine the macro FT_CONFIG_OPTION_USE_MODULE_ERRORS in ftoption.h   */
+  /* to make the higher byte always zero (disabling the module error       */
+  /* mechanism).                                                           */
+  /*                                                                       */
+  /* It can also be used to create a module error message table easily     */
+  /* with something like                                                   */
+  /*                                                                       */
+  /*   {                                                                   */
+  /*     #undef __FTMODERR_H__                                             */
+  /*     #define FT_MODERRDEF( e, v, s )  { FT_Mod_Err_ ## e, s },         */
+  /*     #define FT_MODERR_START_LIST     {                                */
+  /*     #define FT_MODERR_END_LIST       { 0, 0 } };                      */
+  /*                                                                       */
+  /*     const struct                                                      */
+  /*     {                                                                 */
+  /*       int          mod_err_offset;                                    */
+  /*       const char*  mod_err_msg                                        */
+  /*     } ft_mod_errors[] =                                               */
+  /*                                                                       */
+  /*     #include FT_MODULE_ERRORS_H                                       */
+  /*   }                                                                   */
+  /*                                                                       */
+  /* To use such a table, all errors must be ANDed with 0xFF00 to remove   */
+  /* the error code.                                                       */
+  /*                                                                       */
+  /*************************************************************************/
+
+
+#ifndef __FTMODERR_H__
+#define __FTMODERR_H__
+
+
+#undef FT_NEED_EXTERN_C
+
+
+
+
+#ifndef FT_MODERRDEF
+
+#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS
+#define FT_MODERRDEF( e, v, s )  FT_Mod_Err_ ## e = v,
+#else
+#define FT_MODERRDEF( e, v, s )  FT_Mod_Err_ ## e = 0,
+#endif
+
+#define FT_MODERR_START_LIST     enum {
+#define FT_MODERR_END_LIST       FT_Mod_Err_Max };
+
+#ifdef __cplusplus
+#define FT_NEED_EXTERN_C
+  extern "C" {
+#endif
+
+#endif /* !FT_MODERRDEF */
+
+
+#ifdef FT_MODERR_START_LIST
+  FT_MODERR_START_LIST
+#endif
+
+
+  FT_MODERRDEF( Base,     0x000, "base module" )
+  FT_MODERRDEF( Autohint, 0x100, "autohinter module" )
+  FT_MODERRDEF( Cache,    0x200, "cache module" )
+  FT_MODERRDEF( CFF,      0x300, "CFF module" )
+  FT_MODERRDEF( CID,      0x400, "CID module" )
+  FT_MODERRDEF( PCF,      0x500, "PCF module" )
+  FT_MODERRDEF( PSaux,    0x600, "PS auxiliary module" )
+  FT_MODERRDEF( PSnames,  0x700, "PS names module" )
+  FT_MODERRDEF( Raster,   0x800, "raster module" )
+  FT_MODERRDEF( SFNT,     0x900, "SFNT module" )
+  FT_MODERRDEF( Smooth,   0xA00, "smooth raster module" )
+  FT_MODERRDEF( TrueType, 0xB00, "TrueType module" )
+  FT_MODERRDEF( Type1,    0xC00, "Type 1 module" )
+  FT_MODERRDEF( Winfonts, 0xD00, "Windows FON/FNT module" )
+
+
+#ifdef FT_MODERR_END_LIST
+  FT_MODERR_END_LIST
+#endif
+
+
+#undef FT_MODERR_START_LIST
+#undef FT_MODERR_END_LIST
+#undef FT_MODERRDEF
+
+
+#ifdef FT_NEED_EXTERN_C
+  }
+#endif
+
+#endif /* __FTMODERR_H__ */
+
+
+/* END */
--- a/include/freetype/internal/cfferrs.h
+++ /dev/null
@@ -1,136 +1,0 @@
-/***************************************************************************/
-/*                                                                         */
-/*  cfferrs.h                                                              */
-/*                                                                         */
-/*    OpenType error ID definitions (specification only).                  */
-/*                                                                         */
-/*  Copyright 1996-2000 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 __CFFERRORS_H__
-#define __CFFERRORS_H__
-
-
-#include <ft2build.h>
-
-
-FT_BEGIN_HEADER
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* Error codes declaration                                               */
-  /*                                                                       */
-  /* The error codes are grouped in `classes' used to indicate the `level' */
-  /* at which the error happened.  The class is given by an error code's   */
-  /* high byte.                                                            */
-  /*                                                                       */
-  /*************************************************************************/
-
-
-  /* Success is always 0. */
-
-#define CFF_Err_Ok                         FT_Err_Ok
-
-  /* High level API errors. */
-
-#define CFF_Err_Unknown_File_Format        FT_Err_Unknown_File_Format
-#define CFF_Err_Invalid_File_Format        FT_Err_Invalid_File_Format
-#define CFF_Err_Invalid_Argument           FT_Err_Invalid_Argument
-#define CFF_Err_Invalid_Driver_Handle      FT_Err_Invalid_Driver_Handle
-#define CFF_Err_Invalid_Face_Handle        FT_Err_Invalid_Face_Handle
-#define CFF_Err_Invalid_Instance_Handle    FT_Err_Invalid_Size_Handle
-#define CFF_Err_Invalid_Glyph_Handle       FT_Err_Invalid_Slot_Handle
-#define CFF_Err_Invalid_CharMap_Handle     FT_Err_Invalid_CharMap_Handle
-#define CFF_Err_Invalid_Glyph_Index        FT_Err_Invalid_Glyph_Index
-
-#define CFF_Err_Unimplemented_Feature      FT_Err_Unimplemented_Feature
-
-#define CFF_Err_Invalid_Engine             FT_Err_Invalid_Driver_Handle
-
-  /* Internal errors. */
-
-#define CFF_Err_Out_Of_Memory              FT_Err_Out_Of_Memory
-#define CFF_Err_Unlisted_Object            FT_Err_Unlisted_Object
-
-  /* General glyph outline errors. */
-
-#define CFF_Err_Invalid_Composite          FT_Err_Invalid_Composite
-
-  /* CFF parser errors. */
-
-#define CFF_Err_Stack_Underflow            FT_Err_Invalid_Argument
-#define CFF_Err_Syntax_Error               FT_Err_Invalid_Argument
-
-  /* Bytecode interpreter error codes. */
-
-  /* These error codes are produced by the TrueType */
-  /* bytecode interpreter.  They usually indicate a */
-  /* broken font file, a broken glyph within a font */
-  /* file, or a bug in the interpreter!             */
-
-#define CFF_Err_Invalid_Opcode             0x500
-#define CFF_Err_Too_Few_Arguments          0x501
-#define CFF_Err_Stack_Overflow             0x502
-#define CFF_Err_Code_Overflow              0x503
-#define CFF_Err_Bad_Argument               0x504
-#define CFF_Err_Divide_By_Zero             0x505
-#define CFF_Err_Storage_Overflow           0x506
-#define CFF_Err_Cvt_Overflow               0x507
-#define CFF_Err_Invalid_Reference          0x508
-#define CFF_Err_Invalid_Distance           0x509
-#define CFF_Err_Interpolate_Twilight       0x50A
-#define CFF_Err_Debug_OpCode               0x50B
-#define CFF_Err_ENDF_In_Exec_Stream        0x50C
-#define CFF_Err_Out_Of_CodeRanges          0x50D
-#define CFF_Err_Nested_DEFS                0x50E
-#define CFF_Err_Invalid_CodeRange          0x50F
-#define CFF_Err_Invalid_Displacement       0x510
-#define CFF_Err_Execution_Too_Long         0x511
-
-#define CFF_Err_Too_Many_Instruction_Defs  0x512
-#define CFF_Err_Too_Many_Function_Defs     0x513
-
-  /* Other TrueType specific error codes. */
-
-#define CFF_Err_Table_Missing              0x520
-#define CFF_Err_Too_Many_Extensions        0x521
-#define CFF_Err_Extensions_Unsupported     0x522
-#define CFF_Err_Invalid_Extension_Id       0x523
-
-#define CFF_Err_No_Vertical_Data           0x524
-
-#define CFF_Err_Max_Profile_Missing        0x530
-#define CFF_Err_Header_Table_Missing       0x531
-#define CFF_Err_Horiz_Header_Missing       0x532
-#define CFF_Err_Locations_Missing          0x533
-#define CFF_Err_Name_Table_Missing         0x534
-#define CFF_Err_CMap_Table_Missing         0x535
-#define CFF_Err_Hmtx_Table_Missing         0x536
-#define CFF_Err_OS2_Table_Missing          0x537
-#define CFF_Err_Post_Table_Missing         0x538
-
-#define CFF_Err_Invalid_Horiz_Metrics      0x540
-#define CFF_Err_Invalid_CharMap_Format     0x541
-#define CFF_Err_Invalid_PPem               0x542
-#define CFF_Err_Invalid_Vert_Metrics       0x543
-
-#define CFF_Err_Could_Not_Find_Context     0x550
-
-
-FT_END_HEADER
-
-
-#endif /* __CFFERRORS_H__ */
-
-
-/* END */
--- a/include/freetype/internal/internal.h
+++ b/include/freetype/internal/internal.h
@@ -36,19 +36,14 @@
 #define FT_INTERNAL_SFNT_H              <freetype/internal/sfnt.h>
 
 #define FT_INTERNAL_TRUETYPE_TYPES_H    <freetype/internal/tttypes.h>
-#define FT_INTERNAL_TRUETYPE_ERRORS_H   <freetype/internal/tterrors.h>
-
-#define FT_INTERNAL_TYPE1_ERRORS_H      <freetype/internal/t1errors.h>
 #define FT_INTERNAL_TYPE1_TYPES_H       <freetype/internal/t1types.h>
-
-#define FT_INTERNAL_CFF_ERRORS_H        <freetype/internal/cfferrs.h>
 #define FT_INTERNAL_CFF_TYPES_H         <freetype/internal/cfftypes.h>
+#define FT_INTERNAL_FNT_TYPES_H         <freetype/internal/fnttypes.h>
 
 #define FT_INTERNAL_POSTSCRIPT_NAMES_H  <freetype/internal/psnames.h>
 #define FT_INTERNAL_POSTSCRIPT_AUX_H    <freetype/internal/psaux.h>
 
 #define FT_INTERNAL_AUTOHINT_H          <freetype/internal/autohint.h>
-#define FT_INTERNAL_FNT_TYPES_H         <freetype/internal/fnttypes.h>
 
 
 /* END */
--- a/include/freetype/internal/t1errors.h
+++ /dev/null
@@ -1,76 +1,0 @@
-/***************************************************************************/
-/*                                                                         */
-/*  t1errors.h                                                             */
-/*                                                                         */
-/*    Type 1 error ID definitions (specification only).                    */
-/*                                                                         */
-/*  Copyright 1996-2000 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 __T1ERRORS_H__
-#define __T1ERRORS_H__
-
-
-#include <ft2build.h>
-
-
-FT_BEGIN_HEADER
-
-
-  /************************ error codes declaration **************/
-
-  /* The error codes are grouped into `classes' used to indicate the */
-  /* `level' at which the error happened.                            */
-  /*                                                                 */
-  /* The class is given by an error code's high byte.                */
-
-
-  /* ------------- Success is always 0 -------- */
-
-#define T1_Err_Ok                      FT_Err_Ok
-
-  /* ----------- high level API errors -------- */
-
-#define T1_Err_Unknown_File_Format     FT_Err_Unknown_File_Format
-#define T1_Err_Invalid_File_Format     FT_Err_Invalid_File_Format
-#define T1_Err_Invalid_Argument        FT_Err_Invalid_Argument
-#define T1_Err_Invalid_Driver_Handle   FT_Err_Invalid_Driver_Handle
-#define T1_Err_Invalid_Face_Handle     FT_Err_Invalid_Face_Handle
-#define T1_Err_Invalid_Size_Handle     FT_Err_Invalid_Size_Handle
-#define T1_Err_Invalid_Glyph_Handle    FT_Err_Invalid_Slot_Handle
-#define T1_Err_Invalid_CharMap_Handle  FT_Err_Invalid_CharMap_Handle
-#define T1_Err_Invalid_Glyph_Index     FT_Err_Invalid_Glyph_Index
-
-#define T1_Err_Unimplemented_Feature   FT_Err_Unimplemented_Feature
-
-#define T1_Err_Invalid_Engine          FT_Err_Invalid_Driver_Handle
-
-  /* ------------- internal errors ------------ */
-
-#define T1_Err_Out_Of_Memory           FT_Err_Out_Of_Memory
-#define T1_Err_Unlisted_Object         FT_Err_Unlisted_Object
-
-  /* ------------ general glyph outline errors ------ */
-
-#define T1_Err_Invalid_Composite       FT_Err_Invalid_Composite
-
-#define T1_Err_Syntax_Error            FT_Err_Invalid_File_Format
-#define T1_Err_Stack_Underflow         FT_Err_Invalid_File_Format
-#define T1_Err_Stack_Overflow          FT_Err_Invalid_File_Format
-
-
-FT_END_HEADER
-
-#endif /* __T1ERRORS_H__ */
-
-
-/* END */
--- a/include/freetype/internal/tterrors.h
+++ /dev/null
@@ -1,131 +1,0 @@
-/***************************************************************************/
-/*                                                                         */
-/*  tterrors.h                                                             */
-/*                                                                         */
-/*    TrueType error ID definitions (specification only).                  */
-/*                                                                         */
-/*  Copyright 1996-2000 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 __TTERRORS_H__
-#define __TTERRORS_H__
-
-
-#include <ft2build.h>
-
-
-FT_BEGIN_HEADER
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* Error codes declaration                                               */
-  /*                                                                       */
-  /* The error codes are grouped in `classes' used to indicate the `level' */
-  /* at which the error happened.  The class is given by an error code's   */
-  /* high byte.                                                            */
-  /*                                                                       */
-  /*************************************************************************/
-
-
-  /* Success is always 0. */
-
-#define TT_Err_Ok                         FT_Err_Ok
-
-  /* High level API errors. */
-
-#define TT_Err_Unknown_File_Format        FT_Err_Unknown_File_Format
-#define TT_Err_Invalid_File_Format        FT_Err_Invalid_File_Format
-#define TT_Err_Invalid_Argument           FT_Err_Invalid_Argument
-#define TT_Err_Invalid_Driver_Handle      FT_Err_Invalid_Driver_Handle
-#define TT_Err_Invalid_Face_Handle        FT_Err_Invalid_Face_Handle
-#define TT_Err_Invalid_Instance_Handle    FT_Err_Invalid_Size_Handle
-#define TT_Err_Invalid_Glyph_Handle       FT_Err_Invalid_Slot_Handle
-#define TT_Err_Invalid_CharMap_Handle     FT_Err_Invalid_CharMap_Handle
-#define TT_Err_Invalid_Glyph_Index        FT_Err_Invalid_Glyph_Index
-
-#define TT_Err_Unimplemented_Feature      FT_Err_Unimplemented_Feature
-
-#define TT_Err_Invalid_Engine             FT_Err_Invalid_Driver_Handle
-
-  /* Internal errors. */
-
-#define TT_Err_Out_Of_Memory              FT_Err_Out_Of_Memory
-#define TT_Err_Unlisted_Object            FT_Err_Unlisted_Object
-
-  /* General glyph outline errors. */
-
-#define TT_Err_Too_Many_Ins               FT_Err_Too_Many_Hints
-#define TT_Err_Invalid_Composite          FT_Err_Invalid_Composite
-
-  /* Bytecode interpreter error codes. */
-
-  /* These error codes are produced by the TrueType */
-  /* bytecode interpreter.  They usually indicate a */
-  /* broken font file, a broken glyph within a font */
-  /* file, or a bug in the interpreter!             */
-
-#define TT_Err_Invalid_Opcode             0x400
-#define TT_Err_Too_Few_Arguments          0x401
-#define TT_Err_Stack_Overflow             0x402
-#define TT_Err_Code_Overflow              0x403
-#define TT_Err_Bad_Argument               0x404
-#define TT_Err_Divide_By_Zero             0x405
-#define TT_Err_Storage_Overflow           0x406
-#define TT_Err_Cvt_Overflow               0x407
-#define TT_Err_Invalid_Reference          0x408
-#define TT_Err_Invalid_Distance           0x409
-#define TT_Err_Interpolate_Twilight       0x40A
-#define TT_Err_Debug_OpCode               0x40B
-#define TT_Err_ENDF_In_Exec_Stream        0x40C
-#define TT_Err_Out_Of_CodeRanges          0x40D
-#define TT_Err_Nested_DEFS                0x40E
-#define TT_Err_Invalid_CodeRange          0x40F
-#define TT_Err_Invalid_Displacement       0x410
-#define TT_Err_Execution_Too_Long         0x411
-#define TT_Err_Too_Many_Function_Defs     0x412
-#define TT_Err_Too_Many_Instruction_Defs  0x413
-
-  /* Other TrueType specific error codes. */
-
-#define TT_Err_Table_Missing              0x420
-#define TT_Err_Too_Many_Extensions        0x421
-#define TT_Err_Extensions_Unsupported     0x422
-#define TT_Err_Invalid_Extension_Id       0x423
-
-#define TT_Err_No_Vertical_Data           0x424
-
-#define TT_Err_Max_Profile_Missing        0x430
-#define TT_Err_Header_Table_Missing       0x431
-#define TT_Err_Horiz_Header_Missing       0x432
-#define TT_Err_Locations_Missing          0x433
-#define TT_Err_Name_Table_Missing         0x434
-#define TT_Err_CMap_Table_Missing         0x435
-#define TT_Err_Hmtx_Table_Missing         0x436
-#define TT_Err_OS2_Table_Missing          0x437
-#define TT_Err_Post_Table_Missing         0x438
-
-#define TT_Err_Invalid_Horiz_Metrics      0x440
-#define TT_Err_Invalid_CharMap_Format     0x441
-#define TT_Err_Invalid_PPem               0x442
-#define TT_Err_Invalid_Vert_Metrics       0x443
-
-#define TT_Err_Could_Not_Find_Context     0x450
-
-
-FT_END_HEADER
-
-
-#endif /* __TTERRORS_H__ */
-
-
-/* END */
--- /dev/null
+++ b/src/autohint/aherrors.h
@@ -1,0 +1,43 @@
+/***************************************************************************/
+/*                                                                         */
+/*  aherrors.h                                                             */
+/*                                                                         */
+/*    Autohinter error codes (specification only).                         */
+/*                                                                         */
+/*  Copyright 2001 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.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the Autohinter error enumeration          */
+  /* constants.                                                            */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __AHERRORS_H__
+#define __AHERRORS_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    AH_Err_ ## e = v + FT_Mod_Err_Autohint,
+#define FT_NOERRORDEF( e, v, s )  AH_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         AH_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __AHERRORS_H__ */
+
+/* END */
--- a/src/autohint/ahglyph.c
+++ b/src/autohint/ahglyph.c
@@ -24,6 +24,7 @@
 #include "ahglyph.h"
 #include "ahangles.h"
 #include "ahglobal.h"
+#include "aherrors.h"
 
 #include <stdio.h>
 
@@ -388,7 +389,7 @@
                              FT_Face      face )
   {
     FT_Memory   memory       = outline->memory;
-    FT_Error    error        = FT_Err_Ok;
+    FT_Error    error        = AH_Err_Ok;
     FT_Outline* source       = &face->glyph->outline;
     FT_Int      num_points   = source->n_points;
     FT_Int      num_contours = source->n_contours;
@@ -399,7 +400,7 @@
     if ( !face                                          ||
          !face->size                                    ||
          face->glyph->format != ft_glyph_format_outline )
-      return FT_Err_Invalid_Argument;
+      return AH_Err_Invalid_Argument;
 
     /* first of all, reallocate the contours array if necessary */
     if ( num_contours > outline->max_contours )
@@ -1316,7 +1317,7 @@
     AH_Globals*  globals    = &face_globals->design;
     FT_Fixed     y_scale    = outline->y_scale;
 
-    FT_Bool      blue_active[ ah_blue_max ];
+    FT_Bool      blue_active[ah_blue_max];
 
 
     /* compute which blue zones are active, i.e. have their scaled */
@@ -1325,14 +1326,16 @@
       AH_Blue  blue;
       FT_Bool  check = 0;
 
+
       for ( blue = ah_blue_capital_top; blue < ah_blue_max; blue++ )
       {
         FT_Pos  ref, shoot, dist;
 
+
         ref   = globals->blue_refs[blue];
         shoot = globals->blue_shoots[blue];
         dist  = ref-shoot;
-        if (dist < 0)
+        if ( dist < 0 )
           dist = -dist;
 
         blue_active[blue] = 0;
@@ -1345,7 +1348,7 @@
       }
 
       /* return immediately if no blue zone is active */
-      if (!check)
+      if ( !check )
         return;
     }
 
--- a/src/autohint/ahhint.c
+++ b/src/autohint/ahhint.c
@@ -23,6 +23,7 @@
 #include "ahhint.h"
 #include "ahglyph.h"
 #include "ahangles.h"
+#include "aherrors.h"
 #include FT_OUTLINE_H
 
 
@@ -1241,7 +1242,7 @@
             if ( start_point + k >= num_base_points          ||
                                l >= (FT_UInt)num_new_points  )
             {
-              error = FT_Err_Invalid_Composite;
+              error = AH_Err_Invalid_Composite;
               goto Exit;
             }
 
@@ -1279,7 +1280,7 @@
 
     default:
       /* we don't support other formats (yet?) */
-      error = FT_Err_Unimplemented_Feature;
+      error = AH_Err_Unimplemented_Feature;
     }
 
   Hint_Metrics:
--- a/src/autohint/rules.mk
+++ b/src/autohint/rules.mk
@@ -39,7 +39,8 @@
 #
 AUTO_DRV_H := $(AUTO_DRV_SRC:%c=%h)  \
               $(AUTO_DIR_)ahloader.h \
-              $(AUTO_DIR_)ahtypes.h
+              $(AUTO_DIR_)ahtypes.h \
+              $(AUTO_DIR_)aherrors.h
 
 
 # AUTO driver object(s)
--- a/src/cache/ftcchunk.c
+++ b/src/cache/ftcchunk.c
@@ -23,7 +23,9 @@
 #include FT_ERRORS_H
 #include FT_INTERNAL_OBJECTS_H
 
+#include "ftcerror.h"
 
+
   /*************************************************************************/
   /*************************************************************************/
   /*****                                                               *****/
@@ -223,7 +225,7 @@
     *anode = 0;
 
     if ( glyph_index >= cset->element_max )
-      error = FT_Err_Invalid_Argument;
+      error = FTC_Err_Invalid_Argument;
     else
     {
       FT_UInt         chunk_size  = cset->element_count;
@@ -401,7 +403,7 @@
     /* check for valid `desc' delayed to FT_Lru_Lookup() */
 
     if ( !cache || !anode || !aindex )
-      return FT_Err_Invalid_Argument;
+      return FTC_Err_Invalid_Argument;
 
     *anode  = 0;
     *aindex = 0;
--- /dev/null
+++ b/src/cache/ftcerror.h
@@ -1,0 +1,43 @@
+/***************************************************************************/
+/*                                                                         */
+/*  ftcerror.h                                                             */
+/*                                                                         */
+/*    Caching sub-system error codes (specification only).                 */
+/*                                                                         */
+/*  Copyright 2001 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.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the caching sub-system error enumeration  */
+  /* constants.                                                            */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __FTCERROR_H__
+#define __FTCERROR_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    FTC_Err_ ## e = v + FT_Mod_Err_Cache,
+#define FT_NOERRORDEF( e, v, s )  FTC_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         FTC_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __FTCERROR_H__ */
+
+/* END */
--- a/src/cache/ftcglyph.c
+++ b/src/cache/ftcglyph.c
@@ -24,7 +24,9 @@
 #include FT_INTERNAL_OBJECTS_H
 #include FT_INTERNAL_DEBUG_H
 
+#include "ftcerror.h"
 
+
   /*************************************************************************/
   /*************************************************************************/
   /*****                                                               *****/
@@ -433,7 +435,7 @@
     /* check for valid `desc' delayed to FT_Lru_Lookup() */
 
     if ( !cache || !anode )
-      return FT_Err_Invalid_Argument;
+      return FTC_Err_Invalid_Argument;
 
     *anode = 0;
     gset   = cache->last_gset;
--- a/src/cache/ftcimage.c
+++ b/src/cache/ftcimage.c
@@ -21,6 +21,8 @@
 #include FT_CACHE_IMAGE_H
 #include FT_INTERNAL_MEMORY_H
 
+#include "ftcerror.h"
+
 #include <string.h>     /* memcmp() */
 #include <stdlib.h>     /* labs()   */
 
@@ -143,7 +145,7 @@
             node->ft_glyph = glyph;
         }
         else
-          error = FT_Err_Invalid_Argument;
+          error = FTC_Err_Invalid_Argument;
       }
     }
 
@@ -284,7 +286,7 @@
     /* some argument checks are delayed to FTC_Glyph_Cache_Lookup */
 
     if (!aglyph)
-      return FT_Err_Invalid_Argument;
+      return FTC_Err_Invalid_Argument;
 
     error = FTC_Glyph_Cache_Lookup( (FTC_Glyph_Cache)cache,
                                     desc, gindex, &node );
--- a/src/cache/ftcmanag.c
+++ b/src/cache/ftcmanag.c
@@ -23,7 +23,9 @@
 #include FT_INTERNAL_DEBUG_H
 #include FT_LIST_H
 
+#include "ftcerror.h"
 
+
 #undef  FT_COMPONENT
 #define FT_COMPONENT  trace_cache
 
@@ -224,7 +226,7 @@
 
 
     if ( !library )
-      return FT_Err_Invalid_Library_Handle;
+      return FTC_Err_Invalid_Library_Handle;
 
     memory = library->memory;
 
@@ -328,7 +330,7 @@
                                                       FT_Face     *aface )
   {
     if ( !manager )
-      return FT_Err_Invalid_Cache_Handle;
+      return FTC_Err_Invalid_Cache_Handle;
 
     return  FT_Lru_Lookup( manager->faces_lru,
                            (FT_LruKey)face_id,
@@ -436,7 +438,7 @@
                                FTC_Cache_Class*  clazz,
                                FTC_Cache        *acache )
   {
-    FT_Error  error = FT_Err_Invalid_Argument;
+    FT_Error  error = FTC_Err_Invalid_Argument;
 
 
     if ( manager && clazz && acache )
@@ -459,7 +461,7 @@
       /* return an error if there are too many registered caches */
       if ( index >= FTC_MAX_CACHES )
       {
-        error = FT_Err_Too_Many_Caches;
+        error = FTC_Err_Too_Many_Caches;
         FT_ERROR(( "FTC_Manager_Register_Cache:" ));
         FT_ERROR(( " too many registered caches\n" ));
         goto Exit;
--- a/src/cache/ftcsbits.c
+++ b/src/cache/ftcsbits.c
@@ -23,6 +23,8 @@
 #include FT_INTERNAL_DEBUG_H
 #include FT_ERRORS_H
 
+#include "ftcerror.h"
+
 #include <string.h>         /* memcmp() */
 
 
@@ -144,7 +146,7 @@
       {
         FT_ERROR(( "FTC_SBit_Cache: cannot load scalable glyphs in an"
                    " sbit cache, please check your arguments!\n" ));
-        error = FT_Err_Invalid_Argument;
+        error = FTC_Err_Invalid_Argument;
         goto Exit;
       }
 
@@ -378,7 +380,7 @@
 
     /* argument checks delayed to FTC_Chunk_Cache_Lookup */
     if ( !ansbit )
-      return FT_Err_Invalid_Argument;
+      return FTC_Err_Invalid_Argument;
       
     *ansbit = 0;
     error   = FTC_Chunk_Cache_Lookup( &cache->root, desc, gindex,
--- a/src/cache/ftlru.c
+++ b/src/cache/ftlru.c
@@ -22,7 +22,9 @@
 #include FT_LIST_H
 #include FT_INTERNAL_OBJECTS_H
 
+#include "ftcerror.h"
 
+
   static
   void  lru_build_free_list( FT_LruNode  nodes,
                              FT_UInt     count,
@@ -50,7 +52,7 @@
 
 
     if ( !anlru )
-      return FT_Err_Invalid_Argument;
+      return FTC_Err_Invalid_Argument;
 
     *anlru = 0;
     if ( !ALLOC( lru, sizeof ( *lru ) ) )
@@ -146,7 +148,7 @@
 
 
     if ( !lru || !key || !anode )
-      return FT_Err_Invalid_Argument;
+      return FTC_Err_Invalid_Argument;
 
     node   = lru->elements.head;
     clazz  = lru->clazz;
@@ -271,7 +273,7 @@
     /* check for valid `lru' and `key' delayed to FT_Lru_Lookup_Node() */
 
     if ( !anobject )
-      return FT_Err_Invalid_Argument;
+      return FTC_Err_Invalid_Argument;
 
     *anobject = 0;
     error = FT_Lru_Lookup_Node( lru, key, &node );
--- a/src/cache/rules.mk
+++ b/src/cache/rules.mk
@@ -40,7 +40,8 @@
 Cache_DRV_H := $(CACHE_H_DIR_)ftlru.h    \
                $(CACHE_H_DIR_)ftcmanag.h \
                $(CACHE_H_DIR_)ftcglyph.h \
-               $(CACHE_H_DIR_)ftcimage.h
+               $(CACHE_H_DIR_)ftcimage.h \
+               $(CACHE_DIR_)ftcerror.h
 
 
 # Cache driver object(s)
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -22,12 +22,14 @@
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_SFNT_H
 #include FT_TRUETYPE_IDS_H
-#include FT_INTERNAL_CFF_ERRORS_H
 
 #include "cffdrivr.h"
 #include "cffgload.h"
 #include "cffload.h"
 
+#include "cfferrs.h"
+
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -180,7 +182,7 @@
 
 
     if ( !slot )
-      return CFF_Err_Invalid_Glyph_Handle;
+      return CFF_Err_Invalid_Slot_Handle;
 
     /* check whether we want a scaled outline or bitmap */
     if ( !size )
--- /dev/null
+++ b/src/cff/cfferrs.h
@@ -1,0 +1,43 @@
+/***************************************************************************/
+/*                                                                         */
+/*  cfferrs.h                                                              */
+/*                                                                         */
+/*    CFF error codes (specification only).                                */
+/*                                                                         */
+/*  Copyright 2001 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.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the CFF error enumeration constants.      */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __CFFERRS_H__
+#define __CFFERRS_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    CFF_Err_ ## e = v + FT_Mod_Err_CFF,
+#define FT_NOERRORDEF( e, v, s )  CFF_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         CFF_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __CFFERRS_H__ */
+
+
+/* END */
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -27,7 +27,7 @@
 #include "cffload.h"
 #include "cffgload.h"
 
-#include FT_INTERNAL_CFF_ERRORS_H
+#include "cfferrs.h"
 
 
   /*************************************************************************/
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -21,11 +21,12 @@
 #include FT_INTERNAL_OBJECTS_H
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
-#include FT_INTERNAL_CFF_ERRORS_H
 #include FT_TRUETYPE_TAGS_H
 
 #include "cffload.h"
 #include "cffparse.h"
+
+#include "cfferrs.h"
 
 
   /*************************************************************************/
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -27,7 +27,8 @@
 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
 #include "cffobjs.h"
 #include "cffload.h"
-#include FT_INTERNAL_CFF_ERRORS_H
+
+#include "cfferrs.h"
 
 #include <string.h>         /* for strlen() */
 
--- a/src/cff/cffobjs.h
+++ b/src/cff/cffobjs.h
@@ -23,7 +23,6 @@
 #include <ft2build.h>
 #include FT_INTERNAL_OBJECTS_H
 #include FT_INTERNAL_CFF_TYPES_H
-#include FT_INTERNAL_CFF_ERRORS_H
 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
 
 
--- a/src/cff/cffparse.c
+++ b/src/cff/cffparse.c
@@ -18,8 +18,9 @@
 
 #include <ft2build.h>
 #include "cffparse.h"
-#include FT_INTERNAL_CFF_ERRORS_H
 #include FT_INTERNAL_STREAM_H
+
+#include "cfferrs.h"
 
 
   /*************************************************************************/
--- a/src/cff/rules.mk
+++ b/src/cff/rules.mk
@@ -33,7 +33,8 @@
 # CFF driver headers
 #
 CFF_DRV_H := $(CFF_DRV_SRC:%.c=%.h) \
-            $(CFF_DIR_)cfftoken.h
+             $(CFF_DIR_)cfftoken.h \
+             $(CFF_DIR_)cfferrs.h
 
 
 # CFF driver object(s)
--- /dev/null
+++ b/src/cid/ciderrs.h
@@ -1,0 +1,43 @@
+/***************************************************************************/
+/*                                                                         */
+/*  ciderrs.h                                                              */
+/*                                                                         */
+/*    CID error codes (specification only).                                */
+/*                                                                         */
+/*  Copyright 2001 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.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the CID error enumeration constants.      */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __CIDERRS_H__
+#define __CIDERRS_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    CID_Err_ ## e = v + FT_Mod_Err_CID,
+#define FT_NOERRORDEF( e, v, s )  CID_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         CID_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __CIDERRS_H__ */
+
+
+/* END */
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -23,7 +23,9 @@
 #include FT_INTERNAL_STREAM_H
 #include FT_OUTLINE_H
 
+#include "ciderrs.h"
 
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -175,7 +177,7 @@
 
     *max_advance = decoder.builder.advance.x;
 
-    return T1_Err_Ok;
+    return CID_Err_Ok;
   }
 
 
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -21,9 +21,11 @@
 #include FT_CONFIG_CONFIG_H
 #include FT_MULTIPLE_MASTERS_H
 #include FT_INTERNAL_TYPE1_TYPES_H
-#include FT_INTERNAL_TYPE1_ERRORS_H
+
 #include "cidload.h"
 
+#include "ciderrs.h"
+
 #include <stdio.h>
 #include <ctype.h>  /* for isspace(), isalnum() */
 
@@ -125,7 +127,7 @@
         {
           FT_ERROR(( "cid_load_keyword: invalid use of `%s'!\n",
                      keyword->ident ));
-          error = T1_Err_Syntax_Error;
+          error = CID_Err_Syntax_Error;
           goto Exit;
         }
 
@@ -170,7 +172,7 @@
     bbox->xMax = FT_RoundFix( temp[2] );
     bbox->yMax = FT_RoundFix( temp[3] );
 
-    return T1_Err_Ok;       /* this is a callback function; */
+    return CID_Err_Ok;       /* this is a callback function; */
                             /* we must return an error code */
   }
 
@@ -224,7 +226,7 @@
       offset->y  = temp[5] >> 16;
     }
 
-    return T1_Err_Ok;       /* this is a callback function; */
+    return CID_Err_Ok;       /* this is a callback function; */
                             /* we must return an error code */
   }
 
@@ -235,7 +237,7 @@
   {
     CID_Info*  cid    = &face->cid;
     FT_Memory  memory = face->root.memory;
-    FT_Error   error  = T1_Err_Ok;
+    FT_Error   error  = CID_Err_Ok;
     FT_Long    num_dicts;
 
 
@@ -271,7 +273,7 @@
   const T1_Field  cid_field_records[] =
   {
 
-#include "cidtokens.h"
+#include "cidtoken.h"
 
     T1_FIELD_CALLBACK( "FontBBox", parse_font_bbox )
     T1_FIELD_CALLBACK( "FDArray", parse_fd_array )
--- a/src/cid/cidobjs.c
+++ b/src/cid/cidobjs.c
@@ -24,7 +24,9 @@
 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
 #include FT_INTERNAL_POSTSCRIPT_AUX_H
 
+#include "ciderrs.h"
 
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -165,7 +167,7 @@
     if ( face_index != 0 )
     {
       FT_ERROR(( "CID_Init_Face: invalid face index\n" ));
-      error = T1_Err_Invalid_Argument;
+      error = CID_Err_Invalid_Argument;
       goto Exit;
     }
 
@@ -356,7 +358,7 @@
   {
     FT_UNUSED( driver );
 
-    return T1_Err_Ok;
+    return CID_Err_Ok;
   }
 
 
--- a/src/cid/cidobjs.h
+++ b/src/cid/cidobjs.h
@@ -23,7 +23,6 @@
 #include <ft2build.h>
 #include FT_INTERNAL_OBJECTS_H
 #include FT_CONFIG_CONFIG_H
-#include FT_INTERNAL_TYPE1_ERRORS_H
 #include FT_INTERNAL_TYPE1_TYPES_H
 
 
--- a/src/cid/cidparse.c
+++ b/src/cid/cidparse.c
@@ -21,9 +21,11 @@
 #include FT_INTERNAL_CALC_H
 #include FT_INTERNAL_OBJECTS_H
 #include FT_INTERNAL_STREAM_H
-#include FT_INTERNAL_TYPE1_ERRORS_H
+
 #include "cidparse.h"
 
+#include "ciderrs.h"
+
 #include <string.h>     /* for strncmp() */
 
 
@@ -75,7 +77,7 @@
                   "%!PS-Adobe-3.0 Resource-CIDFont", 31 ) )
     {
       FT_TRACE2(( "[not a valid CID-keyed font]\n" ));
-      error = T1_Err_Unknown_File_Format;
+      error = CID_Err_Unknown_File_Format;
     }
 
     FORGET_Frame();
--- a/src/cid/cidriver.c
+++ b/src/cid/cidriver.c
@@ -23,6 +23,8 @@
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
 
+#include "ciderrs.h"
+
 #include <string.h>         /* for strcmp() */
 
 
@@ -65,7 +67,7 @@
     if ( afm )
       CID_Get_Kerning( afm, left_glyph, right_glyph, kerning );
 
-    return T1_Err_Ok;
+    return CID_Err_Ok;
   }
 
 
--- /dev/null
+++ b/src/cid/cidtoken.h
@@ -1,0 +1,96 @@
+/***************************************************************************/
+/*                                                                         */
+/*  cidtoken.h                                                             */
+/*                                                                         */
+/*    CID token definitions (specification only).                          */
+/*                                                                         */
+/*  Copyright 1996-2000 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.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+#undef  FT_STRUCTURE
+#define FT_STRUCTURE  CID_Info
+#undef  T1CODE
+#define T1CODE        t1_field_cid_info
+
+  T1_FIELD_STRING( "CIDFontName", cid_font_name )
+  T1_FIELD_NUM   ( "CIDFontVersion", cid_version )
+  T1_FIELD_NUM   ( "CIDFontType", cid_font_type )
+  T1_FIELD_STRING( "Registry", registry )
+  T1_FIELD_STRING( "Ordering", ordering )
+  T1_FIELD_NUM   ( "Supplement", supplement )
+  T1_FIELD_NUM   ( "UIDBase", uid_base )
+  T1_FIELD_NUM   ( "CIDMapOffset", cidmap_offset )
+  T1_FIELD_NUM   ( "FDBytes", fd_bytes )
+  T1_FIELD_NUM   ( "GDBytes", gd_bytes )
+  T1_FIELD_NUM   ( "CIDCount", cid_count )
+
+
+#undef  FT_STRUCTURE
+#define FT_STRUCTURE  T1_FontInfo
+#undef  T1CODE
+#define T1CODE        t1_field_font_info
+
+  T1_FIELD_STRING( "version", version )
+  T1_FIELD_STRING( "Notice", notice )
+  T1_FIELD_STRING( "FullName", full_name )
+  T1_FIELD_STRING( "FamilyName", family_name )
+  T1_FIELD_STRING( "Weight", weight )
+  T1_FIELD_FIXED ( "ItalicAngle", italic_angle )
+  T1_FIELD_BOOL  ( "isFixedPitch", is_fixed_pitch )
+  T1_FIELD_NUM   ( "UnderlinePosition", underline_position )
+  T1_FIELD_NUM   ( "UnderlineThickness", underline_thickness )
+
+
+#undef  FT_STRUCTURE
+#define FT_STRUCTURE  CID_FontDict
+#undef  T1CODE
+#define T1CODE        t1_field_font_dict
+
+  T1_FIELD_NUM  ( "PaintType", paint_type )
+  T1_FIELD_NUM  ( "FontType", font_type )
+  T1_FIELD_NUM  ( "SubrMapOffset", subrmap_offset )
+  T1_FIELD_NUM  ( "SDBytes", sd_bytes )
+  T1_FIELD_NUM  ( "SubrCount", num_subrs )
+  T1_FIELD_NUM  ( "lenBuildCharArray", len_buildchar )
+  T1_FIELD_FIXED( "ForceBoldThreshold", forcebold_threshold )
+  T1_FIELD_FIXED( "ExpansionFactor", expansion_factor )
+  T1_FIELD_NUM  ( "StrokeWidth", stroke_width )
+
+
+#undef  FT_STRUCTURE
+#define FT_STRUCTURE  T1_Private
+#undef  T1CODE
+#define T1CODE        t1_field_private
+
+  T1_FIELD_NUM       ( "UniqueID", unique_id )
+  T1_FIELD_NUM       ( "lenIV", lenIV )
+  T1_FIELD_NUM       ( "LanguageGroup", language_group )
+  T1_FIELD_NUM       ( "password", password )
+
+  T1_FIELD_FIXED     ( "BlueScale", blue_scale )
+  T1_FIELD_NUM       ( "BlueShift", blue_shift )
+  T1_FIELD_NUM       ( "BlueFuzz",  blue_fuzz )
+
+  T1_FIELD_NUM_TABLE ( "BlueValues", blue_values, 14 )
+  T1_FIELD_NUM_TABLE ( "OtherBlues", other_blues, 10 )
+  T1_FIELD_NUM_TABLE ( "FamilyBlues", family_blues, 14 )
+  T1_FIELD_NUM_TABLE ( "FamilyOtherBlues", family_other_blues, 10 )
+
+  T1_FIELD_NUM_TABLE2( "StdHW", standard_width,  1 )
+  T1_FIELD_NUM_TABLE2( "StdVW", standard_height, 1 )
+  T1_FIELD_NUM_TABLE2( "MinFeature", min_feature, 2 )
+
+  T1_FIELD_NUM_TABLE ( "StemSnapH", snap_widths, 12 )
+  T1_FIELD_NUM_TABLE ( "StemSnapV", snap_heights, 12 )
+
+
+/* END */
--- a/src/cid/cidtokens.h
+++ /dev/null
@@ -1,96 +1,0 @@
-/***************************************************************************/
-/*                                                                         */
-/*  cidtokens.h                                                            */
-/*                                                                         */
-/*    CID token definitions (specification only).                          */
-/*                                                                         */
-/*  Copyright 1996-2000 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.                                        */
-/*                                                                         */
-/***************************************************************************/
-
-
-#undef  FT_STRUCTURE
-#define FT_STRUCTURE  CID_Info
-#undef  T1CODE
-#define T1CODE        t1_field_cid_info
-
-  T1_FIELD_STRING( "CIDFontName", cid_font_name )
-  T1_FIELD_NUM   ( "CIDFontVersion", cid_version )
-  T1_FIELD_NUM   ( "CIDFontType", cid_font_type )
-  T1_FIELD_STRING( "Registry", registry )
-  T1_FIELD_STRING( "Ordering", ordering )
-  T1_FIELD_NUM   ( "Supplement", supplement )
-  T1_FIELD_NUM   ( "UIDBase", uid_base )
-  T1_FIELD_NUM   ( "CIDMapOffset", cidmap_offset )
-  T1_FIELD_NUM   ( "FDBytes", fd_bytes )
-  T1_FIELD_NUM   ( "GDBytes", gd_bytes )
-  T1_FIELD_NUM   ( "CIDCount", cid_count )
-
-
-#undef  FT_STRUCTURE
-#define FT_STRUCTURE  T1_FontInfo
-#undef  T1CODE
-#define T1CODE        t1_field_font_info
-
-  T1_FIELD_STRING( "version", version )
-  T1_FIELD_STRING( "Notice", notice )
-  T1_FIELD_STRING( "FullName", full_name )
-  T1_FIELD_STRING( "FamilyName", family_name )
-  T1_FIELD_STRING( "Weight", weight )
-  T1_FIELD_FIXED ( "ItalicAngle", italic_angle )
-  T1_FIELD_BOOL  ( "isFixedPitch", is_fixed_pitch )
-  T1_FIELD_NUM   ( "UnderlinePosition", underline_position )
-  T1_FIELD_NUM   ( "UnderlineThickness", underline_thickness )
-
-
-#undef  FT_STRUCTURE
-#define FT_STRUCTURE  CID_FontDict
-#undef  T1CODE
-#define T1CODE        t1_field_font_dict
-
-  T1_FIELD_NUM  ( "PaintType", paint_type )
-  T1_FIELD_NUM  ( "FontType", font_type )
-  T1_FIELD_NUM  ( "SubrMapOffset", subrmap_offset )
-  T1_FIELD_NUM  ( "SDBytes", sd_bytes )
-  T1_FIELD_NUM  ( "SubrCount", num_subrs )
-  T1_FIELD_NUM  ( "lenBuildCharArray", len_buildchar )
-  T1_FIELD_FIXED( "ForceBoldThreshold", forcebold_threshold )
-  T1_FIELD_FIXED( "ExpansionFactor", expansion_factor )
-  T1_FIELD_NUM  ( "StrokeWidth", stroke_width )
-
-
-#undef  FT_STRUCTURE
-#define FT_STRUCTURE  T1_Private
-#undef  T1CODE
-#define T1CODE        t1_field_private
-
-  T1_FIELD_NUM       ( "UniqueID", unique_id )
-  T1_FIELD_NUM       ( "lenIV", lenIV )
-  T1_FIELD_NUM       ( "LanguageGroup", language_group )
-  T1_FIELD_NUM       ( "password", password )
-
-  T1_FIELD_FIXED     ( "BlueScale", blue_scale )
-  T1_FIELD_NUM       ( "BlueShift", blue_shift )
-  T1_FIELD_NUM       ( "BlueFuzz",  blue_fuzz )
-
-  T1_FIELD_NUM_TABLE ( "BlueValues", blue_values, 14 )
-  T1_FIELD_NUM_TABLE ( "OtherBlues", other_blues, 10 )
-  T1_FIELD_NUM_TABLE ( "FamilyBlues", family_blues, 14 )
-  T1_FIELD_NUM_TABLE ( "FamilyOtherBlues", family_other_blues, 10 )
-
-  T1_FIELD_NUM_TABLE2( "StdHW", standard_width,  1 )
-  T1_FIELD_NUM_TABLE2( "StdVW", standard_height, 1 )
-  T1_FIELD_NUM_TABLE2( "MinFeature", min_feature, 2 )
-
-  T1_FIELD_NUM_TABLE ( "StemSnapH", snap_widths, 12 )
-  T1_FIELD_NUM_TABLE ( "StemSnapV", snap_heights, 12 )
-
-
-/* END */
--- a/src/cid/rules.mk
+++ b/src/cid/rules.mk
@@ -33,7 +33,8 @@
 # CID driver headers
 #
 CID_DRV_H := $(CID_DRV_SRC:%.c=%.h) \
-             $(CID_DIR_)cidtokens.h
+             $(CID_DIR_)cidtoken.h  \
+             $(CID_DIR_)ciderrs.h
 
 
 # CID driver object(s)
--- a/src/pcf/pcfdriver.c
+++ b/src/pcf/pcfdriver.c
@@ -27,7 +27,6 @@
 
 #include <ft2build.h>
 
-#include FT_ERRORS_H
 #include FT_INTERNAL_DEBUG_H
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_OBJECTS_H
@@ -36,7 +35,9 @@
 #include "pcfdriver.h"
 #include "pcfutil.h"
 
+#include "pcferror.h"
 
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -68,7 +69,7 @@
 
     FT_TRACE4(( "DONE_FACE!!!\n" ));
 
-    return FT_Err_Ok;
+    return PCF_Err_Ok;
   }
 
 
@@ -79,7 +80,7 @@
                            FT_Int         num_params,
                            FT_Parameter*  params )
   {
-    FT_Error  error = FT_Err_Ok;
+    FT_Error  error = PCF_Err_Ok;
   
     FT_UNUSED( num_params );
     FT_UNUSED( params );
@@ -90,13 +91,13 @@
     if ( error )
       goto Fail;
 
-    return FT_Err_Ok;
+    return PCF_Err_Ok;
 
   Fail: 
     FT_TRACE2(( "[not a valid PCF file]\n" ));
     PCF_Done_Face( face );
 
-    return FT_Err_Unknown_File_Format; /* error */
+    return PCF_Err_Unknown_File_Format; /* error */
   }
 
 
@@ -119,12 +120,12 @@
       size->metrics.height    = size->metrics.ascender -
                                 size->metrics.descender;
       
-      return FT_Err_Ok;
+      return PCF_Err_Ok;
     }
     else
     {
       FT_TRACE4(( "size WRONG\n" ));
-      return FT_Err_Invalid_Pixel_Size;
+      return PCF_Err_Invalid_Pixel_Size;
     }
   }
 
@@ -136,7 +137,7 @@
                             FT_Int        load_flags )
   { 
     PCF_Face    face   = (PCF_Face)FT_SIZE_FACE( size );
-    FT_Error    error  = FT_Err_Ok;
+    FT_Error    error  = PCF_Err_Ok;
     FT_Memory   memory = FT_FACE(face)->memory;
     FT_Bitmap*  bitmap = &slot->bitmap;
     PCF_Metric  metric;
@@ -151,7 +152,7 @@
 
     if ( !face )
     {
-      error = FT_Err_Invalid_Argument;
+      error = PCF_Err_Invalid_Argument;
       goto Exit;
     }
 
@@ -186,7 +187,7 @@
       break;
 
     default:
-      return FT_Err_Invalid_File_Format;
+      return PCF_Err_Invalid_File_Format;
     }
 
     /* XXX: to do: are there cases that need repadding the bitmap? */
--- /dev/null
+++ b/src/pcf/pcferror.h
@@ -1,0 +1,43 @@
+/***************************************************************************/
+/*                                                                         */
+/*  pcferror.h                                                             */
+/*                                                                         */
+/*    PCF error codes (specification only).                                */
+/*                                                                         */
+/*  Copyright 2001 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.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the PCF error enumeration constants.      */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __PCFERROR_H__
+#define __PCFERROR_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    PCF_Err_ ## e = v + FT_Mod_Err_PCF,
+#define FT_NOERRORDEF( e, v, s )  PCF_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         PCF_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __PCFERROR_H__ */
+
+
+/* END */
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -27,7 +27,6 @@
 
 #include <ft2build.h>
 
-#include FT_ERRORS_H
 #include FT_INTERNAL_DEBUG_H
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_OBJECTS_H
@@ -35,6 +34,8 @@
 #include "pcf.h"
 #include "pcfdriver.h"
 
+#include "pcferror.h"
+
 #include <string.h>     /* strlen(), strcpy() */
 
   /*************************************************************************/
@@ -98,13 +99,13 @@
 
     if ( FILE_Seek ( 0 )                   ||
          READ_Fields ( pcf_toc_header, toc ) )
-      return FT_Err_Cannot_Open_Resource;
+      return PCF_Err_Cannot_Open_Resource;
   
     if ( toc->version != PCF_FILE_VERSION )
-      return FT_Err_Invalid_File_Format;
+      return PCF_Err_Invalid_File_Format;
 
     if ( ALLOC( face->toc.tables, toc->count * sizeof ( PCF_TableRec ) ) )
-      return FT_Err_Out_Of_Memory;
+      return PCF_Err_Out_Of_Memory;
 
     tables = face->toc.tables;
     for ( i = 0; i < toc->count; i++ )
@@ -139,7 +140,7 @@
 
 #endif
 
-    return FT_Err_Ok;
+    return PCF_Err_Ok;
 
   Exit:
     FREE( face->toc.tables );
@@ -202,13 +203,13 @@
                               const FT_Frame_Field*  header, 
                               PCF_Metric             metric )
   {
-    FT_Error  error = FT_Err_Ok;
+    FT_Error  error = PCF_Err_Ok;
   
 
     if ( READ_Fields( header, metric ) )
       return error;
   
-    return FT_Err_Ok;
+    return PCF_Err_Ok;
   }
 
 
@@ -217,7 +218,7 @@
                                          PCF_Metric  metric )
   {
     PCF_Compressed_MetricRec  compr_metric;
-    FT_Error                  error = FT_Err_Ok;
+    FT_Error                  error = PCF_Err_Ok;
   
 
     if ( READ_Fields( pcf_compressed_metric_header, &compr_metric ) )
@@ -230,7 +231,7 @@
     metric->descent          = (FT_Short)compr_metric.descent - 0x80;
     metric->attributes       = 0;
   
-    return FT_Err_Ok;
+    return PCF_Err_Ok;
   }
 
 
@@ -239,7 +240,7 @@
                             FT_ULong    format,
                             PCF_Metric  metric )
   {
-    FT_Error error = FT_Err_Ok;
+    FT_Error error = PCF_Err_Ok;
 
 
     if ( PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
@@ -272,15 +273,15 @@
       if ( tables[i].type == type )
       {
         if ( stream->pos > tables[i].offset )
-          return FT_Err_Invalid_Stream_Skip;
+          return PCF_Err_Invalid_Stream_Skip;
         if ( FILE_Skip( tables[i].offset - stream->pos ) )
-          return FT_Err_Invalid_Stream_Skip;
+          return PCF_Err_Invalid_Stream_Skip;
         *sizep   = tables[i].size;  /* unused - to be removed */
         *formatp = tables[i].format;
-        return FT_Err_Ok;
+        return PCF_Err_Ok;
       }
 
-    return FT_Err_Invalid_File_Format;
+    return PCF_Err_Invalid_File_Format;
   }
 
 
@@ -466,7 +467,7 @@
     FREE( props );
     FREE( strings );
   
-    return FT_Err_Ok;
+    return PCF_Err_Ok;
  
   Bail:
     FREE( props );
@@ -480,7 +481,7 @@
   FT_Error  pcf_get_metrics( FT_Stream  stream,
                              PCF_Face   face )
   { 
-    FT_Error    error    = FT_Err_Ok;
+    FT_Error    error    = PCF_Err_Ok;
     FT_Memory   memory   = FT_FACE(face)->memory;
     FT_ULong    format   = 0;
     FT_ULong    size     = 0;
@@ -502,7 +503,7 @@
 
     if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT )   &&
          !PCF_FORMAT_MATCH( format, PCF_COMPRESSED_METRICS ) )
-      return FT_Err_Invalid_File_Format;
+      return PCF_Err_Invalid_File_Format;
 
     if ( PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
     {
@@ -519,12 +520,12 @@
         (void)READ_UShortLE( nmetrics );
     }
     if ( error || nmetrics == -1 )
-      return FT_Err_Invalid_File_Format;
+      return PCF_Err_Invalid_File_Format;
   
     face->nmetrics = nmetrics;
 
     if ( ALLOC( face->metrics, nmetrics * sizeof ( PCF_MetricRec ) ) )
-      return FT_Err_Out_Of_Memory;
+      return PCF_Err_Out_Of_Memory;
 
     metrics = face->metrics;
     for ( i = 0; i < nmetrics; i++ )
@@ -557,7 +558,7 @@
   FT_Error  pcf_get_bitmaps( FT_Stream  stream,
                              PCF_Face   face )
   {
-    FT_Error   error  = FT_Err_Ok;
+    FT_Error   error  = PCF_Err_Ok;
     FT_Memory  memory = FT_FACE(face)->memory;
     FT_Long*   offsets;
     FT_Long    bitmapSizes[GLYPHPADOPTIONS];
@@ -580,7 +581,7 @@
       return error;
     format = GET_ULongLE();
     if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
-      return FT_Err_Invalid_File_Format;
+      return PCF_Err_Invalid_File_Format;
   
     if ( PCF_BYTE_ORDER( format ) == MSBFirst )
       nbitmaps  = GET_ULong();
@@ -588,7 +589,7 @@
       nbitmaps  = GET_ULongLE();
     FT_Forget_Frame( stream );
     if ( nbitmaps != face->nmetrics )
-      return FT_Err_Invalid_File_Format;
+      return PCF_Err_Invalid_File_Format;
 
     if ( ALLOC( offsets, nbitmaps * sizeof ( FT_ULong ) ) )
       return error;
@@ -647,7 +648,7 @@
   FT_Error  pcf_get_encodings( FT_Stream  stream,
                                PCF_Face   face )
   {
-    FT_Error      error   = FT_Err_Ok;
+    FT_Error      error   = PCF_Err_Ok;
     FT_Memory     memory  = FT_FACE(face)->memory;
     FT_ULong      format, size;
     int           firstCol, lastCol;
@@ -671,7 +672,7 @@
       return error;
     format = GET_ULongLE();
     if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
-      return FT_Err_Invalid_File_Format;
+      return PCF_Err_Invalid_File_Format;
   
     if ( PCF_BYTE_ORDER( format ) == MSBFirst )
     {
@@ -698,7 +699,7 @@
     nencoding = ( lastCol - firstCol + 1 ) * ( lastRow - firstRow + 1 );
 
     if ( ALLOC( tmpEncoding, nencoding * sizeof ( PCF_EncodingRec ) ) )
-      return FT_Err_Out_Of_Memory;
+      return PCF_Err_Out_Of_Memory;
   
     error = FT_Access_Frame( stream, 2 * nencoding );
     if ( error )
@@ -799,7 +800,7 @@
                            FT_ULong   type )
   {
     FT_ULong   format, size;
-    FT_Error   error = FT_Err_Ok;
+    FT_Error   error = PCF_Err_Ok;
     PCF_Accel  accel = &face->accel;
 
 
@@ -860,7 +861,7 @@
   FT_Error  pcf_load_font( FT_Stream  stream,
                            PCF_Face   face )
   {
-    FT_Error   error  = FT_Err_Ok;
+    FT_Error   error  = PCF_Err_Ok;
     FT_Memory  memory = FT_FACE(face)->memory;
     FT_Bool    hasBDFAccelerators;
 
@@ -1033,7 +1034,7 @@
               face->charmap.face        = root;
               face->charmap_handle
 
-              return FT_Err_Ok;
+              return PCF_Err_Ok;
             }
 #endif
           }
@@ -1047,11 +1048,11 @@
       face->charmap_handle      = &face->charmap;
       root->charmap             = face->charmap_handle;
     }  
-    return FT_Err_Ok;
+    return PCF_Err_Ok;
 
   Bail:
     PCF_Done_Face( face );
-    return FT_Err_Invalid_File_Format;
+    return PCF_Err_Invalid_File_Format;
   }
 
 
--- a/src/pcf/rules.mk
+++ b/src/pcf/rules.mk
@@ -44,7 +44,8 @@
 #
 PCF_DRV_H := $(PCF_DIR_)pcf.h       \
              $(PCF_DIR_)pcfdriver.h \
-             $(PCF_DIR_)pcfutil.h
+             $(PCF_DIR_)pcfutil.h   \
+             $(PCF_DIR_)pcferror.h
 
 # pcf driver object(s)
 #
--- /dev/null
+++ b/src/psaux/psauxerr.h
@@ -1,0 +1,44 @@
+/***************************************************************************/
+/*                                                                         */
+/*  psauxerr.h                                                             */
+/*                                                                         */
+/*    PS auxiliary module error codes (specification only).                */
+/*                                                                         */
+/*  Copyright 2001 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.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the PS auxiliary module error enumeration */
+  /* constants.                                                            */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __PSAUXERR_H__
+#define __PSAUXERR_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    PSaux_Err_ ## e = v + FT_Mod_Err_PSaux,
+#define FT_NOERRORDEF( e, v, s )  PSaux_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         PSaux_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __PSAUXERR_H__ */
+
+
+/* END */
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -18,12 +18,13 @@
 
 #include <ft2build.h>
 #include FT_INTERNAL_POSTSCRIPT_AUX_H
-#include FT_INTERNAL_TYPE1_ERRORS_H
 #include FT_INTERNAL_DEBUG_H
-#include FT_ERRORS_H
+
 #include "psobjs.h"
 
+#include "psauxerr.h"
 
+
   /*************************************************************************/
   /*************************************************************************/
   /*****                                                               *****/
@@ -121,7 +122,7 @@
 
     table->capacity = new_size;
 
-    return T1_Err_Ok;
+    return PSaux_Err_Ok;
   }
 
 
@@ -156,7 +157,7 @@
     if ( index < 0 || index > table->max_elems )
     {
       FT_ERROR(( "PS_Table_Add: invalid index\n" ));
-      return T1_Err_Invalid_Argument;
+      return PSaux_Err_Invalid_Argument;
     }
 
     /* grow the base block if needed */
@@ -180,7 +181,7 @@
     MEM_Copy( table->block + table->cursor, object, length );
 
     table->cursor += length;
-    return T1_Err_Ok;
+    return PSaux_Err_Ok;
   }
 
 
@@ -878,13 +879,13 @@
     FT_UNUSED( pflags );
 #endif
 
-    error = T1_Err_Ok;
+    error = PSaux_Err_Ok;
 
   Exit:
     return error;
 
   Fail:
-    error = T1_Err_Invalid_File_Format;
+    error = PSaux_Err_Invalid_File_Format;
     goto Exit;
   }
 
@@ -950,7 +951,7 @@
     return error;
 
   Fail:
-    error = T1_Err_Invalid_File_Format;
+    error = PSaux_Err_Invalid_File_Format;
     goto Exit;
   }
 
@@ -1191,7 +1192,7 @@
     if ( !builder->load_points )
     {
       outline->n_contours++;
-      return T1_Err_Ok;
+      return PSaux_Err_Ok;
     }
 
     error = FT_GlyphLoader_Check_Points( builder->loader, 0, 1 );
--- a/src/psaux/rules.mk
+++ b/src/psaux/rules.mk
@@ -32,7 +32,8 @@
 
 # PSAUX driver headers
 #
-PSAUX_DRV_H := $(PSAUX_DRV_SRC:%c=%h)
+PSAUX_DRV_H := $(PSAUX_DRV_SRC:%c=%h)  \
+               $(PSAUX_DIR_)psauxerr.h
 
 
 # PSAUX driver object(s)
--- a/src/psaux/t1decode.c
+++ b/src/psaux/t1decode.c
@@ -18,12 +18,14 @@
 
 #include <ft2build.h>
 #include FT_INTERNAL_DEBUG_H
-#include FT_INTERNAL_TYPE1_ERRORS_H
 #include FT_OUTLINE_H
+
 #include "t1decode.h"
 #include "psobjs.h"
 
+#include "psauxerr.h"
 
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -193,7 +195,7 @@
     {
       FT_ERROR(( "t1operator_seac:" ));
       FT_ERROR(( " glyph names table not available in this font!\n" ));
-      return T1_Err_Syntax_Error;
+      return PSaux_Err_Syntax_Error;
     }
 
     bchar_index = t1_lookup_glyph_by_stdcharcode( decoder, bchar );
@@ -203,7 +205,7 @@
     {
       FT_ERROR(( "t1operator_seac:" ));
       FT_ERROR(( " invalid seac character code arguments\n" ));
-      return T1_Err_Syntax_Error;
+      return PSaux_Err_Syntax_Error;
     }
 
     /* if we are trying to load a composite glyph, do not load the */
@@ -344,7 +346,7 @@
     limit = zone->limit  = charstring_base + charstring_len;
     ip    = zone->cursor = zone->base;
 
-    error   = T1_Err_Ok;
+    error   = PSaux_Err_Ok;
     outline = builder->current;
 
     x = builder->pos_x;
@@ -713,7 +715,7 @@
 
           /* return now! */
           FT_TRACE4(( "\n\n" ));
-          return T1_Err_Ok;
+          return PSaux_Err_Ok;
 
         case op_hsbw:
           FT_TRACE4(( " hsbw" ));
@@ -729,7 +731,7 @@
           /* the glyph's metrics (lsb + advance width), not load the   */
           /* rest of it; so exit immediately                           */
           if ( builder->metrics_only )
-            return T1_Err_Ok;
+            return PSaux_Err_Ok;
 
           break;
 
@@ -753,7 +755,7 @@
           /* the glyph's metrics (lsb + advance width), not load the   */
           /* rest of it; so exit immediately                           */
           if ( builder->metrics_only )
-            return T1_Err_Ok;
+            return PSaux_Err_Ok;
 
           break;
 
@@ -1014,10 +1016,10 @@
     return error;
 
   Syntax_Error:
-    return T1_Err_Syntax_Error;
+    return PSaux_Err_Syntax_Error;
 
   Stack_Underflow:
-    return T1_Err_Stack_Underflow;
+    return PSaux_Err_Stack_Underflow;
 
   Memory_Error:
     return builder->error;
@@ -1054,7 +1056,7 @@
       {
         FT_ERROR(( "T1_Decoder_Init: " ));
         FT_ERROR(( "the `psnames' module is not available\n" ));
-        return T1_Err_Unimplemented_Feature;
+        return PSaux_Err_Unimplemented_Feature;
       }
 
       decoder->psnames = psnames;
--- a/src/psnames/psmodule.c
+++ b/src/psnames/psmodule.c
@@ -19,9 +19,12 @@
 #include <ft2build.h>
 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
 #include FT_INTERNAL_OBJECTS_H
+
 #include "psmodule.h"
 #include "pstables.h"
 
+#include "psnamerr.h"
+
 #include <stdlib.h>     /* for qsort()             */
 #include <string.h>     /* for strcmp(), strncpy() */
 
@@ -192,7 +195,7 @@
       {
         FREE( table->maps );
         if ( !error )
-          error = FT_Err_Invalid_Argument;  /* no unicode chars here! */
+          error = PSnames_Err_Invalid_Argument;  /* no unicode chars here! */
       }
       else
         /* sort the table in increasing order of unicode values */
--- /dev/null
+++ b/src/psnames/psnamerr.h
@@ -1,0 +1,44 @@
+/***************************************************************************/
+/*                                                                         */
+/*  psnamerr.h                                                             */
+/*                                                                         */
+/*    PS names module error codes (specification only).                    */
+/*                                                                         */
+/*  Copyright 2001 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.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the PS names module error enumeration     */
+  /* constants.                                                            */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __PSNAMERR_H__
+#define __PSNAMERR_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    PSnames_Err_ ## e = v + FT_Mod_Err_PSnames,
+#define FT_NOERRORDEF( e, v, s )  PSnames_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         PSnames_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __PSNAMERR_H__ */
+
+
+/* END */
--- a/src/psnames/rules.mk
+++ b/src/psnames/rules.mk
@@ -32,7 +32,8 @@
 # PSNames driver headers
 #
 PSNAMES_DRV_H := $(PSNAMES_DRV_SRC:%.c=%.h) \
-                 $(PSNAMES_DIR_)pstables.h
+                 $(PSNAMES_DIR_)pstables.h  \
+                 $(PSNAMES_DIR_)psnamerr.h
 
 
 # PSNames driver object(s)
--- a/src/raster/ftraster.c
+++ b/src/raster/ftraster.c
@@ -170,17 +170,19 @@
 #else /* _STANDALONE_ */
 
 
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdebug.h> /* for FT_TRACE() and FT_ERROR() */
+#include FT_INTERNAL_OBJECTS_H
+#include FT_INTERNAL_DEBUG_H        /* for FT_TRACE() and FT_ERROR() */
 
-#define Raster_Err_None         FT_Err_Ok
-#define Raster_Err_Not_Ini      FT_Err_Raster_Uninitialized
-#define Raster_Err_Overflow     FT_Err_Raster_Overflow
-#define Raster_Err_Neg_Height   FT_Err_Raster_Negative_Height
-#define Raster_Err_Invalid      FT_Err_Invalid_Outline
-#define Raster_Err_Unsupported  FT_Err_Cannot_Render_Glyph
+#include "rasterrs.h"
 
+#define Raster_Err_None         Raster_Err_Ok
+#define Raster_Err_Not_Ini      Raster_Err_Raster_Uninitialized
+#define Raster_Err_Overflow     Raster_Err_Raster_Overflow
+#define Raster_Err_Neg_Height   Raster_Err_Raster_Negative_Height
+#define Raster_Err_Invalid      Raster_Err_Invalid_Outline
+#define Raster_Err_Unsupported  Raster_Err_Cannot_Render_Glyph
 
+
 #endif /* _STANDALONE_ */
 
 
@@ -3012,7 +3014,7 @@
         return error;
     }
 
-    return FT_Err_Ok;
+    return Raster_Err_Ok;
   }
 
 
@@ -3085,7 +3087,7 @@
         return error;
     }
 
-    return FT_Err_Ok;
+    return Raster_Err_Ok;
   }
 
 #else /* FT_RASTER_OPTION_ANTI_ALIASING */
@@ -3095,7 +3097,7 @@
   {
     FT_UNUSED_RASTER;
 
-    return FT_Err_Cannot_Render_Glyph;
+    return Raster_Err_Cannot_Render_Glyph;
   }
 
 #endif /* FT_RASTER_OPTION_ANTI_ALIASING */
--- a/src/raster/ftrend1.c
+++ b/src/raster/ftrend1.c
@@ -22,7 +22,9 @@
 #include "ftrend1.h"
 #include "ftraster.h"
 
+#include "rasterrs.h"
 
+
   /* initialize renderer -- init its raster */
   static
   FT_Error  ft_raster1_init( FT_Renderer  render )
@@ -34,7 +36,7 @@
                                                library->raster_pool,
                                                library->raster_pool_size );
 
-    return FT_Err_Ok;
+    return Raster_Err_Ok;
   }
 
 
@@ -58,12 +60,12 @@
                                   FT_Matrix*    matrix,
                                   FT_Vector*    delta )
   {
-    FT_Error error = FT_Err_Ok;
+    FT_Error error = Raster_Err_Ok;
 
 
     if ( slot->format != render->glyph_format )
     {
-      error = FT_Err_Invalid_Argument;
+      error = Raster_Err_Invalid_Argument;
       goto Exit;
     }
 
@@ -111,7 +113,7 @@
     /* check glyph image format */
     if ( slot->format != render->glyph_format )
     {
-      error = FT_Err_Invalid_Argument;
+      error = Raster_Err_Invalid_Argument;
       goto Exit;
     }
 
@@ -120,13 +122,13 @@
     {
       /* raster1 is only capable of producing monochrome bitmaps */
       if ( render->clazz == &ft_raster1_renderer_class )
-        return FT_Err_Cannot_Render_Glyph;
+        return Raster_Err_Cannot_Render_Glyph;
     }
     else
     {
       /* raster5 is only capable of producing 5-gray-levels bitmaps */
       if ( render->clazz == &ft_raster5_renderer_class )
-        return FT_Err_Cannot_Render_Glyph;
+        return Raster_Err_Cannot_Render_Glyph;
     }
 
     outline = &slot->outline;
--- /dev/null
+++ b/src/raster/rasterrs.h
@@ -1,0 +1,44 @@
+/***************************************************************************/
+/*                                                                         */
+/*  rasterrs.h                                                             */
+/*                                                                         */
+/*    monochrome renderer error codes (specification only).                */
+/*                                                                         */
+/*  Copyright 2001 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.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the monochrome renderer error enumeration */
+  /* constants.                                                            */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __RASTERRS_H__
+#define __RASTERRS_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    Raster_Err_ ## e = v + FT_Mod_Err_Raster,
+#define FT_NOERRORDEF( e, v, s )  Raster_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         Raster_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __RASTERRS_H__ */
+
+
+/* END */
--- a/src/raster/rules.mk
+++ b/src/raster/rules.mk
@@ -31,7 +31,8 @@
 
 # raster1 driver headers
 #
-RAS1_DRV_H := $(RAS1_DRV_SRC:%.c=%.h)
+RAS1_DRV_H := $(RAS1_DRV_SRC:%.c=%.h) \
+              $(RAS1_DIR_)rasterrs.h
 
 
 # raster1 driver object(s)
--- a/src/sfnt/rules.mk
+++ b/src/sfnt/rules.mk
@@ -35,7 +35,8 @@
 
 # SFNT driver headers
 #
-SFNT_DRV_H := $(SFNT_DRV_SRC:%c=%h)
+SFNT_DRV_H := $(SFNT_DRV_SRC:%c=%h) \
+              $(SFNT_DIR_)sferrors.h
 
 
 # SFNT driver object(s)
--- /dev/null
+++ b/src/sfnt/sferrors.h
@@ -1,0 +1,42 @@
+/***************************************************************************/
+/*                                                                         */
+/*  sferrors.h                                                             */
+/*                                                                         */
+/*    SFNT error codes (specification only).                               */
+/*                                                                         */
+/*  Copyright 2001 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.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the SFNT error enumeration constants.     */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __SFERRORS_H__
+#define __SFERRORS_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    SFNT_Err_ ## e = v + FT_Mod_Err_SFNT,
+#define FT_NOERRORDEF( e, v, s )  SFNT_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         SFNT_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __SFERRORS_H__ */
+
+/* END */
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -23,9 +23,10 @@
 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
 #include FT_TRUETYPE_IDS_H
 #include FT_TRUETYPE_TAGS_H
-#include FT_INTERNAL_TRUETYPE_ERRORS_H
 
+#include "sferrors.h"
 
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -199,7 +200,7 @@
       sfnt = (SFNT_Interface*)FT_Get_Module_Interface( library, "sfnt" );
       if ( !sfnt )
       {
-        error = TT_Err_Invalid_File_Format;
+        error = SFNT_Err_Invalid_File_Format;
         goto Exit;
       }
 
@@ -237,7 +238,7 @@
 
 #undef  LOAD_
 #define LOAD_( x )  ( ( error = sfnt->load_##x( face, stream ) ) \
-                      != TT_Err_Ok )
+                      != SFNT_Err_Ok )
 
 
   FT_LOCAL_DEF
@@ -327,8 +328,8 @@
     if ( sfnt->load_sbits && LOAD_( sbits ) )
     {
       /* return an error if this font file has no outlines */
-      if ( error == TT_Err_Table_Missing && has_outline )
-        error = TT_Err_Ok;
+      if ( error == SFNT_Err_Table_Missing && has_outline )
+        error = SFNT_Err_Ok;
       else
         goto Exit;
     }
@@ -341,7 +342,7 @@
       goto Exit;
 
 #ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
-    if ( ( error = TT_Extension_Create( face ) ) != TT_Err_Ok )
+    if ( ( error = TT_Extension_Create( face ) ) != SFNT_Err_Ok )
       goto Exit;
 #endif
 
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -18,11 +18,12 @@
 
 #include <ft2build.h>
 #include FT_INTERNAL_DEBUG_H
-#include FT_INTERNAL_TRUETYPE_ERRORS_H
 #include "ttload.h"
 #include "ttcmap.h"
 
+#include "sferrors.h"
 
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -91,7 +92,7 @@
 
 
     if ( cmap->loaded )
-      return TT_Err_Ok;
+      return SFNT_Err_Ok;
 
     memory = stream->memory;
 
@@ -260,11 +261,11 @@
       break;
 
     default:   /* corrupt character mapping table */
-      return TT_Err_Invalid_CharMap_Format;
+      return SFNT_Err_Invalid_CharMap_Format;
 
     }
 
-    return TT_Err_Ok;
+    return SFNT_Err_Ok;
 
   Fail:
     TT_CharMap_Free( face, cmap );
@@ -295,7 +296,7 @@
 
 
     if ( !cmap )
-      return TT_Err_Ok;
+      return SFNT_Err_Ok;
 
     memory = face->root.driver->root.memory;
 
@@ -328,7 +329,7 @@
     }
 
     cmap->loaded = FALSE;
-    return TT_Err_Ok;
+    return SFNT_Err_Ok;
   }
 
 
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -19,13 +19,14 @@
 
 #include <ft2build.h>
 #include FT_INTERNAL_DEBUG_H
-#include FT_INTERNAL_TRUETYPE_ERRORS_H
 #include FT_INTERNAL_STREAM_H
 #include FT_TRUETYPE_TAGS_H
 #include "ttload.h"
 #include "ttcmap.h"
 
+#include "sferrors.h"
 
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -122,7 +123,7 @@
        goto Exit;
     }
     else
-      error = TT_Err_Table_Missing;
+      error = SFNT_Err_Table_Missing;
 
   Exit:
     return error;
@@ -233,7 +234,7 @@
       /* check face index */
       if ( face_index >= face->ttc_header.count )
       {
-        error = TT_Err_Bad_Argument;
+        error = SFNT_Err_Bad_Argument;
         goto Exit;
       }
 
@@ -262,7 +263,7 @@
            entry_selector * 2 <= num_tables )
       {
         FT_TRACE2(( "TT_Load_SFNT_Header: file is not SFNT!\n" ));
-        error = TT_Err_Unknown_File_Format;
+        error = SFNT_Err_Unknown_File_Format;
       }
     }
 
@@ -405,7 +406,7 @@
       table = TT_LookUp_Table( face, tag );
       if ( !table )
       {
-        error = TT_Err_Table_Missing;
+        error = SFNT_Err_Table_Missing;
         goto Exit;
       }
 
@@ -420,7 +421,7 @@
     {
       *length = size;
 
-      return TT_Err_Ok;
+      return SFNT_Err_Ok;
     }
 
     if ( length )
@@ -679,7 +680,7 @@
         /* Set number_Of_VMetrics to 0! */
         FT_TRACE2(( "  no vertical header in file.\n" ));
         face->vertical.number_Of_VMetrics = 0;
-        error = TT_Err_Ok;
+        error = SFNT_Err_Ok;
         goto Exit;
       }
 
@@ -693,7 +694,7 @@
       if ( error )
       {
         FT_ERROR(( " no horizontal metrics in file!\n" ));
-        error = TT_Err_Hmtx_Table_Missing;
+        error = SFNT_Err_Hmtx_Table_Missing;
         goto Exit;
       }
 
@@ -713,8 +714,8 @@
                  vertical ? "Vertical"
                           : "Horizontal" ));
 
-      error = vertical ? TT_Err_Invalid_Vert_Metrics
-                       : TT_Err_Invalid_Horiz_Metrics;
+      error = vertical ? SFNT_Err_Invalid_Vert_Metrics
+                       : SFNT_Err_Invalid_Horiz_Metrics;
       goto Exit;
     }
 
@@ -831,7 +832,7 @@
       error = face->goto_table( face, TTAG_vhea, stream, 0 );
       if ( error )
       {
-        error = TT_Err_Ok;
+        error = SFNT_Err_Ok;
         goto Exit;
       }
 
@@ -845,7 +846,7 @@
       error = face->goto_table( face, TTAG_hhea, stream, 0 );
       if ( error )
       {
-        error = TT_Err_Horiz_Header_Missing;
+        error = SFNT_Err_Horiz_Header_Missing;
         goto Exit;
       }
 
@@ -931,7 +932,7 @@
     {
       /* The name table is required so indicate failure. */
       FT_TRACE2(( "is missing!\n" ));
-      error = TT_Err_Name_Table_Missing;
+      error = SFNT_Err_Name_Table_Missing;
       goto Exit;
     }
 
@@ -1123,7 +1124,7 @@
     error = face->goto_table( face, TTAG_cmap, stream, 0 );
     if ( error )
     {
-      error = TT_Err_CMap_Table_Missing;
+      error = SFNT_Err_CMap_Table_Missing;
       goto Exit;
     }
 
@@ -1289,7 +1290,7 @@
     {
       FT_TRACE2(( "is missing!\n" ));
       face->os2.version = 0xFFFF;
-      error = TT_Err_Ok;
+      error = SFNT_Err_Ok;
       goto Exit;
     }
 
@@ -1367,7 +1368,7 @@
 
     error = face->goto_table( face, TTAG_post, stream, 0 );
     if ( error )
-      return TT_Err_Post_Table_Missing;
+      return SFNT_Err_Post_Table_Missing;
 
     if ( READ_Fields( post_fields, post ) )
       return error;
@@ -1376,7 +1377,7 @@
     /* module (ttpost).                                     */
     FT_TRACE2(( "loaded\n" ));
 
-    return TT_Err_Ok;
+    return SFNT_Err_Ok;
   }
 
 
@@ -1434,7 +1435,7 @@
     {
       FT_TRACE2(( "missing (optional)\n" ));
       pclt->Version = 0;
-      return TT_Err_Ok;
+      return SFNT_Err_Ok;
     }
 
     if ( READ_Fields( pclt_fields, pclt ) )
@@ -1478,7 +1479,7 @@
     /* the gasp table is optional */
     error = face->goto_table( face, TTAG_gasp, stream, 0 );
     if ( error )
-      return TT_Err_Ok;
+      return SFNT_Err_Ok;
 
     if ( ACCESS_Frame( 4L ) )
       goto Exit;
@@ -1547,7 +1548,7 @@
     /* the kern table is optional; exit silently if it is missing */
     error = face->goto_table( face, TTAG_kern, stream, 0 );
     if ( error )
-      return TT_Err_Ok;
+      return SFNT_Err_Ok;
 
     if ( ACCESS_Frame( 4L ) )
       goto Exit;
@@ -1658,7 +1659,7 @@
     /* this table is optional */
     error = face->goto_table( face, TTAG_hdmx, stream, 0 );
     if ( error )
-      return TT_Err_Ok;
+      return SFNT_Err_Ok;
 
     if ( ACCESS_Frame( 8L ) )
       goto Exit;
--- a/src/sfnt/ttpost.c
+++ b/src/sfnt/ttpost.c
@@ -27,11 +27,11 @@
 
 #include <ft2build.h>
 #include FT_INTERNAL_STREAM_H
-#include FT_INTERNAL_TRUETYPE_ERRORS_H
 #include FT_TRUETYPE_TAGS_H
 #include "ttpost.h"
 #include "ttload.h"
 
+#include "sferrors.h"
 
   /*************************************************************************/
   /*                                                                       */
@@ -176,7 +176,7 @@
 
     if ( num_glyphs > face->root.num_glyphs )
     {
-      error = TT_Err_Invalid_File_Format;
+      error = SFNT_Err_Invalid_File_Format;
       goto Exit;
     }
 
@@ -249,7 +249,7 @@
       table->glyph_indices = glyph_indices;
       table->glyph_names   = name_strings;
     }
-    return TT_Err_Ok;
+    return SFNT_Err_Ok;
 
 
   Fail1:
@@ -288,7 +288,7 @@
     /* check the number of glyphs */
     if ( num_glyphs > face->root.num_glyphs || num_glyphs > 258 )
     {
-      error = TT_Err_Invalid_File_Format;
+      error = SFNT_Err_Invalid_File_Format;
       goto Exit;
     }
 
@@ -308,7 +308,7 @@
 
         if ( index < 0 || index > num_glyphs )
         {
-          error = TT_Err_Invalid_File_Format;
+          error = SFNT_Err_Invalid_File_Format;
           goto Fail;
         }
       }
@@ -323,7 +323,7 @@
       table->offsets    = offset_table;
     }
 
-    return TT_Err_Ok;
+    return SFNT_Err_Ok;
 
   Fail:
     FREE( offset_table );
@@ -367,7 +367,7 @@
       break;
 
     default:
-      error = TT_Err_Invalid_File_Format;
+      error = SFNT_Err_Invalid_File_Format;
     }
 
     face->postscript_names.loaded = 1;
@@ -455,15 +455,15 @@
 
 
     if ( !face )
-      return TT_Err_Invalid_Face_Handle;
+      return SFNT_Err_Invalid_Face_Handle;
 
     if ( index >= (FT_UInt)face->root.num_glyphs )
-      return TT_Err_Invalid_Glyph_Index;
+      return SFNT_Err_Invalid_Glyph_Index;
 
 #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
     psnames = (PSNames_Interface*)face->psnames;
     if ( !psnames )
-      return TT_Err_Unimplemented_Feature;
+      return SFNT_Err_Unimplemented_Feature;
 #endif
 
     names = &face->postscript_names;
@@ -527,7 +527,7 @@
       break;                                /* nothing to do */
     }
 
-    return TT_Err_Ok;
+    return SFNT_Err_Ok;
   }
 
 
--- a/src/sfnt/ttpost.h
+++ b/src/sfnt/ttpost.h
@@ -29,10 +29,6 @@
 FT_BEGIN_HEADER
 
 
-#define TT_Err_Invalid_Post_Table_Format  0x0B00
-#define TT_Err_Invalid_Post_Table         0x0B01
-
-
   FT_LOCAL
   FT_Error TT_Get_PS_Name( TT_Face      face,
                            FT_UInt      index,
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -18,12 +18,13 @@
 
 #include <ft2build.h>
 #include FT_INTERNAL_DEBUG_H
-#include FT_INTERNAL_TRUETYPE_ERRORS_H
 #include FT_INTERNAL_STREAM_H
 #include FT_TRUETYPE_TAGS_H
 #include "ttsbit.h"
 
+#include "sferrors.h"
 
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -363,7 +364,7 @@
       break;
 
     default:
-      error = TT_Err_Invalid_File_Format;
+      error = SFNT_Err_Invalid_File_Format;
     }
 
   Exit:
@@ -469,7 +470,7 @@
          num_strikes >= 0x10000L    )
     {
       FT_ERROR(( "TT_Load_SBit_Strikes: invalid table version!\n" ));
-      error = TT_Err_Invalid_File_Format;
+      error = SFNT_Err_Invalid_File_Format;
 
       goto Exit;
     }
@@ -630,7 +631,7 @@
 
     if ( x_ppem < 0 || x_ppem > 255 ||
          y_ppem < 1 || y_ppem > 255 )
-      return TT_Err_Invalid_PPem;
+      return SFNT_Err_Invalid_PPem;
 
     for ( i = 0; i < face->num_sbit_strikes; i++ )
     {
@@ -639,11 +640,11 @@
              ( face->sbit_strikes[i].x_ppem == x_ppem ) ) )
       {
         *astrike_index = i;
-        return TT_Err_Ok;
+        return SFNT_Err_Ok;
       }
     }
 
-    return TT_Err_Invalid_PPem;
+    return SFNT_Err_Invalid_PPem;
   }
 
 
@@ -746,7 +747,7 @@
     *arange        = 0;
     *aglyph_offset = 0;
 
-    return TT_Err_Invalid_Argument;
+    return SFNT_Err_Invalid_Argument;
   }
 
 
@@ -775,7 +776,7 @@
   /*                                                                       */
   /* <Return>                                                              */
   /*    FreeType error code.  0 means success.  Returns                    */
-  /*    TT_Err_Invalid_Argument if no sbit exists for the requested glyph. */
+  /*    SFNT_Err_Invalid_Argument if no sbit exists for the requested glyph. */
   /*                                                                       */
   static
   FT_Error  Find_SBit_Image( TT_Face           face,
@@ -802,7 +803,7 @@
 
     *astrike = strike;
 
-    return TT_Err_Ok;
+    return SFNT_Err_Ok;
 
   Fail:
     /* no embedded bitmap for this glyph in face */
@@ -810,7 +811,7 @@
     *astrike       = 0;
     *aglyph_offset = 0;
 
-    return TT_Err_Invalid_Argument;
+    return SFNT_Err_Invalid_Argument;
   }
 
 
@@ -846,7 +847,7 @@
                                TT_SBit_Range*    range,
                                TT_SBit_Metrics*  metrics )
   {
-    FT_Error  error = TT_Err_Ok;
+    FT_Error  error = SFNT_Err_Ok;
 
 
     switch ( range->image_format )
@@ -905,7 +906,7 @@
       if ( range->index_format == 2 || range->index_format == 5 )
         *metrics = range->metrics;
       else
-        return TT_Err_Invalid_File_Format;
+        return SFNT_Err_Invalid_File_Format;
    }
 
   Exit:
@@ -1134,7 +1135,7 @@
     if ( x_offset < 0 || x_offset + metrics->width  > map->width ||
          y_offset < 0 || y_offset + metrics->height > map->rows  )
     {
-      error = TT_Err_Invalid_Argument;
+      error = SFNT_Err_Invalid_Argument;
 
       goto Exit;
     }
@@ -1177,7 +1178,7 @@
         break;
 
       default:  /* invalid format */
-        return TT_Err_Invalid_File_Format;
+        return SFNT_Err_Invalid_File_Format;
       }
 
       /* Now read data and draw glyph into target pixmap       */
@@ -1256,7 +1257,7 @@
         break;
 
       default:
-        return TT_Err_Invalid_File_Format;
+        return SFNT_Err_Invalid_File_Format;
       }
 
       size = map->rows * map->pitch;
@@ -1287,7 +1288,7 @@
       break;
 
     default: /* invalid image format */
-      return TT_Err_Invalid_File_Format;
+      return SFNT_Err_Invalid_File_Format;
     }
 
     /* All right, we have a compound format.  First of all, read */
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -122,6 +122,7 @@
 
 #else /* _STANDALONE_ */
 
+
 #include <ft2build.h>
 #include "ftgrays.h"
 #include FT_INTERNAL_OBJECTS_H
@@ -128,8 +129,10 @@
 #include FT_INTERNAL_DEBUG_H
 #include FT_OUTLINE_H
 
-#define ErrRaster_Invalid_Mode     FT_Err_Cannot_Render_Glyph
-#define ErrRaster_Invalid_Outline  FT_Err_Invalid_Outline
+#include "ftsmerrs.h"
+
+#define ErrRaster_Invalid_Mode     Smooth_Err_Cannot_Render_Glyph
+#define ErrRaster_Invalid_Outline  Smooth_Err_Invalid_Outline
 
 
 #endif /* _STANDALONE_ */
--- /dev/null
+++ b/src/smooth/ftsmerrs.h
@@ -1,0 +1,44 @@
+/***************************************************************************/
+/*                                                                         */
+/*  ftsmerrs.h                                                             */
+/*                                                                         */
+/*    smooth renderer error codes (specification only).                    */
+/*                                                                         */
+/*  Copyright 2001 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.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the smooth renderer error enumeration     */
+  /* constants.                                                            */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __FTSMERRS_H__
+#define __FTSMERRS_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    Smooth_Err_ ## e = v + FT_Mod_Err_Smooth,
+#define FT_NOERRORDEF( e, v, s )  Smooth_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         Smooth_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __FTSMERRS_H__ */
+
+
+/* END */
--- a/src/smooth/ftsmooth.c
+++ b/src/smooth/ftsmooth.c
@@ -22,7 +22,9 @@
 #include "ftsmooth.h"
 #include "ftgrays.h"
 
+#include "ftsmerrs.h"
 
+
   /* initialize renderer -- init its raster */
   static
   FT_Error  ft_smooth_init( FT_Renderer  render )
@@ -57,12 +59,12 @@
                                  FT_Matrix*    matrix,
                                  FT_Vector*    delta )
   {
-    FT_Error  error = FT_Err_Ok;
+    FT_Error  error = Smooth_Err_Ok;
 
 
     if ( slot->format != render->glyph_format )
     {
-      error = FT_Err_Invalid_Argument;
+      error = Smooth_Err_Invalid_Argument;
       goto Exit;
     }
 
@@ -110,13 +112,13 @@
     /* check glyph image format */
     if ( slot->format != render->glyph_format )
     {
-      error = FT_Err_Invalid_Argument;
+      error = Smooth_Err_Invalid_Argument;
       goto Exit;
     }
 
     /* check mode */
     if ( mode != ft_render_mode_normal )
-      return FT_Err_Cannot_Render_Glyph;
+      return Smooth_Err_Cannot_Render_Glyph;
 
     outline = &slot->outline;
 
--- a/src/smooth/rules.mk
+++ b/src/smooth/rules.mk
@@ -31,7 +31,8 @@
 
 # smooth driver headers
 #
-SMOOTH_DRV_H := $(SMOOTH_DRV_SRC:%c=%h)
+SMOOTH_DRV_H := $(SMOOTH_DRV_SRC:%c=%h)  \
+                $(SMOOTH_DIR_)ftsmerrs.h
 
 
 # smooth driver object(s)
--- a/src/truetype/rules.mk
+++ b/src/truetype/rules.mk
@@ -34,7 +34,8 @@
 
 # TrueType driver headers
 #
-TT_DRV_H := $(TT_DRV_SRC:%.c=%.h)
+TT_DRV_H := $(TT_DRV_SRC:%.c=%.h) \
+            $(TT_DIR_)tterrors.h
 
 
 # TrueType driver object(s)
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -21,10 +21,13 @@
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_SFNT_H
 #include FT_TRUETYPE_IDS_H
+
 #include "ttdriver.h"
 #include "ttgload.h"
 
+#include "tterrors.h"
 
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -298,7 +301,7 @@
 
 
     if ( !slot )
-      return TT_Err_Invalid_Glyph_Handle;
+      return TT_Err_Invalid_Slot_Handle;
 
     /* check whether we want a scaled outline or bitmap */
     if ( !size )
--- /dev/null
+++ b/src/truetype/tterrors.h
@@ -1,0 +1,43 @@
+/***************************************************************************/
+/*                                                                         */
+/*  tterrors.h                                                             */
+/*                                                                         */
+/*    TrueType error codes (specification only).                           */
+/*                                                                         */
+/*  Copyright 2001 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.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the TrueType error enumeration            */
+  /* constants.                                                            */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __TTERRORS_H__
+#define __TTERRORS_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    TT_Err_ ## e = v + FT_Mod_Err_TrueType,
+#define FT_NOERRORDEF( e, v, s )  TT_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         TT_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __TTERRORS_H__ */
+
+/* END */
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -26,7 +26,9 @@
 
 #include "ttgload.h"
 
+#include "tterrors.h"
 
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -300,7 +302,7 @@
     if ( n_ins > face->max_profile.maxSizeOfInstructions )
     {
       FT_TRACE0(( "ERROR: Too many instructions!\n" ));
-      error = TT_Err_Too_Many_Ins;
+      error = TT_Err_Too_Many_Hints;
       goto Fail;
     }
 
@@ -307,7 +309,7 @@
     if ( stream->cursor + n_ins > stream->limit )
     {
       FT_TRACE0(( "ERROR: Instruction count mismatch!\n" ));
-      error = TT_Err_Too_Many_Ins;
+      error = TT_Err_Too_Many_Hints;
       goto Fail;
     }
 
@@ -1019,7 +1021,7 @@
           {
             FT_TRACE0(( "Too many instructions (%d) in composite glyph %ld\n",
                         n_ins, subglyph->index ));
-            return TT_Err_Too_Many_Ins;
+            return TT_Err_Too_Many_Hints;
           }
 
           /* read the instructions */
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -20,8 +20,10 @@
 #include FT_INTERNAL_DEBUG_H
 #include FT_INTERNAL_CALC_H
 #include FT_SYSTEM_H
+
 #include "ttinterp.h"
-#include FT_INTERNAL_TRUETYPE_ERRORS_H
+
+#include "tterrors.h"
 
 
 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -24,10 +24,11 @@
 #include FT_TRUETYPE_TAGS_H
 #include FT_INTERNAL_SFNT_H
 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
-#include FT_INTERNAL_TRUETYPE_ERRORS_H
 
 #include "ttgload.h"
 #include "ttpload.h"
+
+#include "tterrors.h"
 
 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
 #include "ttinterp.h"
--- a/src/truetype/ttobjs.h
+++ b/src/truetype/ttobjs.h
@@ -23,7 +23,6 @@
 #include <ft2build.h>
 #include FT_INTERNAL_OBJECTS_H
 #include FT_INTERNAL_TRUETYPE_TYPES_H
-#include FT_INTERNAL_TRUETYPE_ERRORS_H
 
 
 FT_BEGIN_HEADER
--- a/src/truetype/ttpload.c
+++ b/src/truetype/ttpload.c
@@ -21,8 +21,10 @@
 #include FT_INTERNAL_OBJECTS_H
 #include FT_INTERNAL_STREAM_H
 #include FT_TRUETYPE_TAGS_H
+
 #include "ttpload.h"
-#include FT_INTERNAL_TRUETYPE_ERRORS_H
+
+#include "tterrors.h"
 
 
   /*************************************************************************/
--- a/src/type1/rules.mk
+++ b/src/type1/rules.mk
@@ -36,7 +36,8 @@
 # Type1 driver headers
 #
 T1_DRV_H := $(T1_DRV_SRC:%.c=%.h) \
-             $(T1_DIR_)t1tokens.h
+            $(T1_DIR_)t1tokens.h  \
+            $(T1_DIR_)t1errors.h
 
 
 # Type1 driver object(s)
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -21,6 +21,8 @@
 #include "t1gload.h"
 #include "t1load.h"
 
+#include "t1errors.h"
+
 #ifndef T1_CONFIG_OPTION_NO_AFM
 #include "t1afm.h"
 #endif
--- /dev/null
+++ b/src/type1/t1errors.h
@@ -1,0 +1,43 @@
+/***************************************************************************/
+/*                                                                         */
+/*  t1errors.h                                                             */
+/*                                                                         */
+/*    Type 1 error codes (specification only).                             */
+/*                                                                         */
+/*  Copyright 2001 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.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the Type 1 error enumeration constants.   */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __T1ERRORS_H__
+#define __T1ERRORS_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    T1_Err_ ## e = v + FT_Mod_Err_Type1,
+#define FT_NOERRORDEF( e, v, s )  T1_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         T1_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __T1ERRORS_H__ */
+
+
+/* END */
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -23,6 +23,8 @@
 #include FT_OUTLINE_H
 #include FT_INTERNAL_POSTSCRIPT_AUX_H
 
+#include "t1errors.h"
+
 #include <string.h>     /* for strcmp() */
 
 
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -66,9 +66,10 @@
 #include FT_CONFIG_CONFIG_H
 #include FT_MULTIPLE_MASTERS_H
 #include FT_INTERNAL_TYPE1_TYPES_H
-#include FT_INTERNAL_TYPE1_ERRORS_H
 
 #include "t1load.h"
+
+#include "t1errors.h"
 
 #include <string.h>     /* for strncmp(), strcmp() */
 #include <ctype.h>      /* for isalnum()           */
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -25,6 +25,8 @@
 #include "t1gload.h"
 #include "t1load.h"
 
+#include "t1errors.h"
+
 #ifndef T1_CONFIG_OPTION_NO_AFM
 #include "t1afm.h"
 #endif
--- a/src/type1/t1objs.h
+++ b/src/type1/t1objs.h
@@ -23,7 +23,6 @@
 #include <ft2build.h>
 #include FT_INTERNAL_OBJECTS_H
 #include FT_CONFIG_CONFIG_H
-#include FT_INTERNAL_TYPE1_ERRORS_H
 #include FT_INTERNAL_TYPE1_TYPES_H
 
 
--- a/src/type1/t1parse.c
+++ b/src/type1/t1parse.c
@@ -37,9 +37,11 @@
 #include FT_INTERNAL_DEBUG_H
 #include FT_INTERNAL_CALC_H
 #include FT_INTERNAL_STREAM_H
-#include FT_INTERNAL_TYPE1_ERRORS_H
 #include FT_INTERNAL_POSTSCRIPT_AUX_H
+
 #include "t1parse.h"
+
+#include "t1errors.h"
 
 #include <string.h>     /* for strncmp() */
 
--- /dev/null
+++ b/src/winfonts/fnterrs.h
@@ -1,0 +1,44 @@
+/***************************************************************************/
+/*                                                                         */
+/*  fnterrs.h                                                              */
+/*                                                                         */
+/*    Win FNT/FON error codes (specification only).                        */
+/*                                                                         */
+/*  Copyright 2001 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.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the Windows FNT/FON error enumeration     */
+  /* constants.                                                            */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __FNTERRS_H__
+#define __FNTERRS_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    FNT_Err_ ## e = v + FT_Mod_Err_Winfonts,
+#define FT_NOERRORDEF( e, v, s )  FNT_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         FNT_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __FNTERRS_H__ */
+
+
+/* END */
--- a/src/winfonts/rules.mk
+++ b/src/winfonts/rules.mk
@@ -28,7 +28,8 @@
 
 # Windows driver headers
 #
-FNT_DRV_H := $(FNT_DRV_SRC:%.c=%.h)
+FNT_DRV_H := $(FNT_DRV_SRC:%.c=%.h) \
+             $(FNT_DIR_)fnterrs.h
 
 
 # Windows driver object(s)
--- a/src/winfonts/winfnt.c
+++ b/src/winfonts/winfnt.c
@@ -17,14 +17,16 @@
 
 
 #include <ft2build.h>
-#include FT_ERRORS_H
 #include FT_INTERNAL_DEBUG_H
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_OBJECTS_H
 #include FT_INTERNAL_FNT_TYPES_H
+
 #include "winfnt.h"
 
+#include "fnterrs.h"
 
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -139,7 +141,7 @@
          header->version != 0x300 )
     {
       FT_TRACE2(( "[not a valid FNT file]\n" ));
-      error = FT_Err_Unknown_File_Format;
+      error = FNT_Err_Unknown_File_Format;
       goto Exit;
     }
 
@@ -146,7 +148,7 @@
     if ( header->file_type & 1 )
     {
       FT_TRACE2(( "[can't handle vector FNT fonts]\n" ));
-      error = FT_Err_Unknown_File_Format;
+      error = FNT_Err_Unknown_File_Format;
       goto Exit;
     }
 
@@ -198,7 +200,7 @@
          READ_Fields( winmz_header_fields, &mz_header ) )
       goto Exit;
 
-    error = FT_Err_Unknown_File_Format;
+    error = FNT_Err_Unknown_File_Format;
     if ( mz_header.magic == WINFNT_MZ_MAGIC )
     {
       /* yes, now look for a NE header in the file */
@@ -209,7 +211,7 @@
            READ_Fields( winne_header_fields, &ne_header ) )
         goto Exit;
 
-      error = FT_Err_Unknown_File_Format;
+      error = FNT_Err_Unknown_File_Format;
       if ( ne_header.magic == WINFNT_NE_MAGIC )
       {
         /* good, now look in the resource table for each FNT resource */
@@ -254,7 +256,7 @@
         if ( !font_count || !font_offset )
         {
           FT_TRACE2(( "this file doesn't contain any FNT resources!\n" ));
-          error = FT_Err_Unknown_File_Format;
+          error = FNT_Err_Unknown_File_Format;
           goto Exit;
         }
 
@@ -464,7 +466,7 @@
       }
     }
 
-    return ( size->font ? FT_Err_Ok : FT_Err_Invalid_Pixel_Size );
+    return ( size->font ? FNT_Err_Ok : FNT_Err_Invalid_Pixel_Size );
   }
 
 
@@ -513,7 +515,7 @@
 
     if ( !font )
     {
-      error = FT_Err_Invalid_Argument;
+      error = FNT_Err_Invalid_Argument;
       goto Exit;
     }