major re-organisation of the FreeType 2 directory hierarchy
diff --git a/CHANGES b/CHANGES
index 5f36ca9..8bd9900 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,31 @@
-LASTEST CHANGES - 14-apr-2000
+LATEST CHANGES - 
+
+
+
+  - updated the structure of FT_Outline_Funcs in order to allow
+    direct coordinate scaling within the outline decomposition routine
+    (this is important for virtual "on" points with TrueType outlines)
+    + updates to the rasters to support this..
+
+  - updated the OS/2 table loading code in "src/sfnt/ttload.c" in order
+    to support version 2 of the table (see OpenType 1.2 spec)
+
+  - created "include/tttables.h" and "include/t1tables.h" to allow
+    client applications to access some of the SFNT and T1 tables of a
+    face with a procedural interface (see FT_Get_Sfnt_Table())
+    + updates to internal source files to reflect the change..
+
+  - some cleanups in the source code to get rid of warnings when compiling
+    with the "-Wall -W -ansi -pedantic" options in gcc.
+
+  - debugged and moved the smooth renderer to "src/base/ftgrays.c" and
+    its header to "include/ftgrays.h"
+
+  - updated TT_MAX_SUBGLYPHS to 96 as some CJK fonts have composites with
+    up to 80 sub-glyphs !! Thanks to Werner
+
+================================================================================
+OLD CHANGES - 14-apr-2000
 
   - fixed a bug in the TrueType glyph loader that prevented the correct
     loading of some CJK glyphs in mingli.ttf
diff --git a/config/freetype.mk b/config/freetype.mk
deleted file mode 100644
index 84f0e77..0000000
--- a/config/freetype.mk
+++ /dev/null
@@ -1,226 +0,0 @@
-#
-# FreeType 2 library sub-Makefile
-#
-
-
-# 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.
-
-
-# DO NOT INVOKE THIS MAKEFILE DIRECTLY!  IT IS MEANT TO BE INCLUDED BY
-# OTHER MAKEFILES.
-
-
-# The targets `objects' and `library' are defined at the end of this
-# Makefile when all rules have been included.
-#
-.PHONY: build_freetype objects library
-
-# default target -- build objects and library
-#
-build_freetype: objects library
-
-# `multi' target -- build multiple objects and library
-#
-multi: objects library
-
-
-# The FreeType source directory.
-#
-SRC := $(TOP)$(SEP)src
-
-
-# The directory where the base layer components are placed.  By default,
-# this is `freetype/src/base'.
-#
-BASE_DIR := $(SRC)$(SEP)base
-
-
-# A few short-cuts in order to avoid typing $(SEP) all the time for the
-# directory separator.
-#
-# For example:  SRC_ equals to `./src/' where `.' is $(TOP).
-#
-#
-SRC_    := $(SRC)$(SEP)
-BASE_   := $(BASE_DIR)$(SEP)
-OBJ_    := $(OBJ_DIR)$(SEP)
-LIB_    := $(LIB_DIR)$(SEP)
-PUBLIC_ := $(TOP)$(SEP)include$(SEP)
-CONFIG_ := $(TOP)$(SEP)config$(SEP)
-
-
-# The name of the final library file.
-#
-FT_LIBRARY := $(LIB_)$(LIBRARY).$A
-
-
-# include paths
-#
-# IMPORTANT NOTE: The architecture-dependent directory must ALWAYS be placed
-#                 in front of the include list.  Porters are then able to
-#                 put their own version of some of the FreeType components
-#                 in the `freetype/config/<system>' directory, as these
-#                 files will override the default sources.
-#
-INCLUDES := $(BUILD) $(TOP)$(SEP)config $(TOP)$(SEP)include $(INCLUDES)
-
-INCLUDE_FLAGS = $(INCLUDES:%=$I%)
-
-
-# C flags used for the compilation of an object file.  This must include at
-# least the paths for the `base' and `config/<system>' directories,
-# debug/optimization/warning flags + ansi compliance if needed.
-#
-FT_CFLAGS  = $(CFLAGS) $(INCLUDE_FLAGS)
-FT_CC      = $(CC) $(FT_CFLAGS)
-FT_COMPILE = $(CC) $(ANSIFLAGS) $(FT_CFLAGS)
-
-
-# include the `modules' rules file
-#
-include $(CONFIG_)modules.mk
-
-
-# Free the lists of driver objects.
-#
-COMPONENTS_LIST :=
-DRIVERS_LIST    :=
-OBJECTS_LIST    :=
-
-# System-specific component -- this must be defined in this Makefile for
-# easy updates.  The default ANSI ftsystem.c is located in
-# `freetype/config/ftsystem.c'.  However, some system-specific configuration
-# might define $(FTSYS_SRC) to fetch it in other places, like
-# `freetype/config/<system>/ftsystem.c'.
-#
-# $(BASE_H) is defined in `src/base/rules.mk' and contains the list of all
-# base layer header files.
-#
-ifndef FTSYS_SRC
-  FTSYS_SRC = $(BASE_)ftsystem.c
-endif
-FTSYS_OBJ = $(OBJ_)ftsystem.$O
-
-OBJECTS_LIST += $(FTSYS_OBJ)
-
-$(FTSYS_OBJ): $(FTSYS_SRC) $(BASE_H)
-	$(FT_COMPILE) $T$@ $<
-
-
-# ftdebug component
-#
-# FTDebug contains code used to print traces and errors.  It is normally
-# empty for a release build (see ftoption.h).
-#
-FTDEBUG_SRC = $(BASE_)ftdebug.c
-FTDEBUG_OBJ = $(OBJ_)ftdebug.$O
-
-OBJECTS_LIST += $(FTDEBUG_OBJ)
-
-$(FTDEBUG_OBJ): $(FTDEBUG_SRC) $(BASE_H)
-	$(FT_COMPILE) $T$@ $<
-
-
-# Define $(PUBLIC_H) as the list of all public header files located in
-# `$(TOP)/include'.
-#
-PUBLIC_H := $(wildcard $(PUBLIC_)*.h)
-
-
-# Include all rule files from FreeType components.
-#
-include $(wildcard $(SRC)/*/rules.mk)
-
-
-# FTInit file
-#
-#   The C source `ftinit.c' contains the FreeType initialization routines.
-#   It is able to automatically register one or more drivers when the API
-#   function FT_Init_FreeType() is called.
-#
-#   The set of initial drivers is determined by the driver Makefiles
-#   includes above.  Each driver Makefile updates the FTINIT_xxxx lists
-#   which contain additional include paths and macros used to compile the
-#   single `ftinit.c' source.
-#
-FTINIT_SRC := $(BASE_)ftinit.c
-FTINIT_OBJ := $(OBJ_)ftinit.$O
-
-OBJECTS_LIST += $(FTINIT_OBJ)
-
-$(FTINIT_OBJ): $(FTINIT_SRC) $(BASE_H) $(FT_MODULE_LIST)
-	$(FT_COMPILE) $T$@ $<
-
-
-# All FreeType library objects
-#
-#   By default, we include the base layer extensions.  These could be
-#   omitted on builds which do not want them.
-#
-OBJ_M = $(BASE_OBJ_M) $(BASE_EXT_OBJ) $(DRV_OBJS_M)
-OBJ_S = $(BASE_OBJ_S) $(BASE_EXT_OBJ) $(DRV_OBJS_S)
-
-
-# The target `multi' on the Make command line indicates that we want to
-# compile each source file independently.
-#
-# Otherwise, each module/driver is compiled in a single object file through
-# source file inclusion (see `src/base/ftbase.c' or
-# `src/truetype/truetype.c' for examples).
-#
-BASE_OBJECTS := $(OBJECTS_LIST)
-
-ifneq ($(findstring multi,$(MAKECMDGOALS)),)
-  OBJECTS_LIST += $(OBJ_M)
-else
-  OBJECTS_LIST += $(OBJ_S)
-endif
-
-objects: $(OBJECTS_LIST)
-
-library: $(FT_LIBRARY)
-
-.c.$O:
-	$(FT_COMPILE) $T$@ $<
-
-
-# Standard cleaning and distclean rules.  These are not accepted
-# on all systems though.
-#
-clean_freetype_std:
-	-$(DELETE) $(BASE_OBJECTS) $(OBJ_M) $(OBJ_S)
-
-distclean_freetype_std: clean_freetype_std
-	-$(DELETE) $(FT_LIBRARY)
-	-$(DELETE) *.orig *~ core *.core
-
-# The Dos command shell does not support very long list of arguments, so
-# we are stuck with wildcards.
-#
-clean_freetype_dos:
-	-$(DELETE) $(subst $(SEP),$(HOSTSEP),$(OBJ_))*.$O 2> nul
-
-distclean_freetype_dos: clean_freetype_dos
-	-$(DELETE) $(subst $(SEP),$(HOSTSEP),$(FT_LIBRARY)) 2> nul
-
-# Remove configuration file (used for distclean).
-#
-remove_config_mk:
-	-$(DELETE) $(subst $(SEP),$(HOSTSEP),$(CONFIG_MK))
-
-
-# The `config.mk' file must define `clean_freetype' and
-# `distclean_freetype'.  Implementations may use to relay these to either
-# the `std' or `dos' versions, or simply provide their own implementation.
-#
-clean: clean_freetype
-distclean: distclean_freetype remove_config_mk
-
-# EOF
diff --git a/config/modules.mk b/config/modules.mk
index 8978342..876b33e 100644
--- a/config/modules.mk
+++ b/config/modules.mk
@@ -2,7 +2,6 @@
 # FreeType 2 modules sub-Makefile
 #
 
-
 # Copyright 1996-2000 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
diff --git a/demos/Makefile b/demos/Makefile
index 3a69279..9c090ac 100644
--- a/demos/Makefile
+++ b/demos/Makefile
@@ -267,8 +267,8 @@
 	  $(LINK)
 
 
-  $(BIN_)ftview$E: $(OBJ_)ftview.$O $(FTLIB) $(GRAPH_LIB) $(COMMON_OBJ) $(OBJ_)ftrast2.$O
-	  $(GRAPH_LINK) $(OBJ_)ftrast2.$O
+  $(BIN_)ftview$E: $(OBJ_)ftview.$O $(FTLIB) $(GRAPH_LIB) $(COMMON_OBJ) $(OBJ_)ftrast2.$O $(OBJ_)ftrast.$O
+	  $(GRAPH_LINK) $(OBJ_)ftrast2.$O $(OBJ_)ftrast.$O
 
   $(BIN_)ftstring$E: $(OBJ_)ftstring.$O $(FTLIB) $(GRAPH_LIB) $(COMMON_OBJ)
 	  $(GRAPH_LINK)
diff --git a/demos/src/compos.c b/demos/src/compos.c
index d7a77c3..2ae0b0f 100644
--- a/demos/src/compos.c
+++ b/demos/src/compos.c
@@ -13,9 +13,7 @@
 /*                                                                          */
 /****************************************************************************/
 
-#include "freetype.h"
-#include "ftobjs.h"
-#include "ftdriver.h"
+#include <freetype/freetype.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/demos/src/ftlint.c b/demos/src/ftlint.c
index 3a5ff0e..5066906 100644
--- a/demos/src/ftlint.c
+++ b/demos/src/ftlint.c
@@ -13,9 +13,7 @@
 /*                                                                          */
 /****************************************************************************/
 
-#include "freetype.h"
-#include "ftobjs.h"
-#include "ftdriver.h"
+#include <freetype/freetype.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/demos/src/ftrast.c b/demos/src/ftrast.c
index 6f86a72..267261d 100644
--- a/demos/src/ftrast.c
+++ b/demos/src/ftrast.c
@@ -21,7 +21,7 @@
  ******************************************************************/
 
 #include "ftrast.h"
-#include <ftcalc.h>      /* for FT_MulDiv only */
+#include <freetype/internal/ftcalc.h>      /* for FT_MulDiv only */
 
   /*************************************************************************/
   /*                                                                       */
@@ -107,7 +107,7 @@
 #undef  FT_COMPONENT
 #define FT_COMPONENT      trace_raster
 
-#include <ftdebug.h>
+#include <freetype/internal/ftdebug.h>
 
 
 /* The default render pool size */
@@ -2941,7 +2941,7 @@
 
 #else
 
-#include <ftobjs.h>
+#include <freetype/internal/ftobjs.h>
 
   static
   int  ft_black_new( FT_Memory  memory, TRaster_Instance*  *araster )
diff --git a/demos/src/ftrast.h b/demos/src/ftrast.h
index c08dee3..25db0dc 100644
--- a/demos/src/ftrast.h
+++ b/demos/src/ftrast.h
@@ -1,7 +1,7 @@
 #ifndef FTRASTER_H
 #define FTRASTER_H
 
-#include <ftimage.h>
+#include <freetype/ftimage.h>
 
   extern  FT_Raster_Funcs  ft_black_raster;
 
diff --git a/demos/src/ftrast2.c b/demos/src/ftrast2.c
index 67393f0..1d23566 100644
--- a/demos/src/ftrast2.c
+++ b/demos/src/ftrast2.c
@@ -37,14 +37,35 @@
  *
  ******************************************************************/
 
-#include "ftraster.h"
-#include <freetype.h>  /* for FT_Outline_Decompose */
+#include "ftrast2.h"
+#include <freetype/freetype.h>  /* for FT_Outline_Decompose */
 
 #ifndef EXPORT_FUNC
 #define EXPORT_FUNC  /* nothing */
 #endif
 
 
+/**************************************************************************/
+/*                                                                        */
+/* We need a 32-bit unsigned word for our optimized 2x2 filter.. The      */
+/* following uses the ANSI <limits.h> header file to compute exactly      */
+/* wether to use unsigned int or unsigned long                            */
+/*                                                                        */
+#include <limits.h>
+
+/* The number of bytes in an `int' type.  */
+#if   UINT_MAX == 0xFFFFFFFF
+typedef unsigned int  Word32;
+typedef int           Int32;
+#elif ULONG_MAX == 0xFFFFFFFF
+typedef unsigned long Word32;
+typedef long          Int32;
+#else
+#error "could not find a 32-bit word on this machine !!"
+#endif
+
+
+
 #ifndef _xxFREETYPE_
 
 /**************************************************************************/
@@ -98,7 +119,7 @@
 /*   anti-aliasing mode.. Ignored if FT_RASTER_OPTION_ANTI_ALIAS isn't    */
 /*   defined..                                                            */
 /*                                                                        */
-#define FT_RASTER_ANTI_ALIAS_17
+#undef  FT_RASTER_ANTI_ALIAS_17
 
 /**************************************************************************/
 /*                                                                        */
@@ -250,7 +271,7 @@
   /* or high). These are ideals in order to subdivise bezier arcs in halves */
   /* though simple additions and shifts.                                    */
 
-  typedef  long   TPos, *PPos;
+  typedef  Int32   TPos, *PPos;
 
 
   /* The type of a scanline position/coordinate within a map */
@@ -472,7 +493,7 @@
 
     long      grays[20];        /* Palette of gray levels used for render */
 
-    int       gray_width;       /* length in bytes of the onochrome        */
+    int       gray_width;       /* length in bytes of the monochrome       */
                                 /* intermediate scanline of gray_lines.    */
                                 /* Each gray pixel takes 2 or 4 bits long  */
 
@@ -1070,367 +1091,6 @@
 #endif
 
 
-
-
-#ifdef FT_RASTER_CONIC_BEZIERS
-/****************************************************************************/
-/*                                                                          */
-/* <Function>   Conic_Up                                                    */
-/*                                                                          */
-/* <Description>                                                            */
-/*     Computes the scan-line intersections of an ascending second-order    */
-/*     Bezier arc and stores them in the render pool. The arc is taken      */
-/*     from the top of the stack..                                          */
-/*                                                                          */
-/* <Input>                                                                  */
-/*     miny     :: minimum vertical grid coordinate                         */
-/*     maxy     :: maximum vertical grid coordinate                         */
-/*                                                                          */
-/* <Return>                                                                 */
-/*     SUCCESS or FAILURE                                                   */
-/*                                                                          */
-/****************************************************************************/
-
-  static 
-  TBool  Conic_Up( RAS_ARGS TPos  miny, TPos  maxy )
-  {
-    TPos  y1, y2, e, e2, e0;
-    int   f1;
-
-    TPoint*  arc;
-    TPoint*  start_arc;
-
-    PPos top;
-
-
-    arc = ras.arc;
-    y1  = arc[2].y;
-    y2  = arc[0].y;
-    top = ras.cursor; 
-
-    if ( y2 < miny || y1 > maxy )
-      goto Fin;
-    
-    e2 = FLOOR( y2 );
-
-    if ( e2 > maxy )
-      e2 = maxy;
-
-    e0 = miny;
-
-    if ( y1 < miny )
-      e = miny;
-    else
-    {
-      e  = CEILING( y1 );
-      f1 = FRAC( y1 );
-      e0 = e;
-
-      if ( f1 == 0 )
-      {
-        if ( ras.joint )
-        {
-          top--;
-          ras.joint = FALSE;
-        }
-
-        *top++ = arc[2].x;
-
-        DEBUG_PSET;
-
-        e += ras.precision;
-      }
-    }
-
-    if ( ras.fresh )
-    {
-      ras.cur_prof->start = TRUNC( e0 );
-      ras.fresh = FALSE;
-    }
-
-    if ( e2 < e )
-      goto Fin;
-
-    if ( ( top+TRUNC(e2-e)+1 ) >= ras.pool_limit )
-    {
-      ras.cursor = top;
-      ras.error  = ErrRaster_Overflow;
-      return FAILURE;
-    }
-
-    start_arc = arc;
-
-    while ( arc >= start_arc && e <= e2 )
-    {
-      ras.joint = FALSE;
-
-      y2 = arc[0].y;
-
-      if ( y2 > e )
-      {
-        y1 = arc[2].y;
-        if ( y2 - y1 >= ras.precision_step )
-        {
-          Split_Conic( arc );
-          arc += 2;
-        }
-        else
-        {
-          *top++ = arc[2].x + 
-                   FMulDiv( arc[0].x-arc[2].x, 
-                            e  - y1, 
-                            y2 - y1 );
-          DEBUG_PSET;
-            
-          arc -= 2;
-          e   += ras.precision;
-        }
-      }
-      else
-      {
-        if ( y2 == e )
-        {
-          ras.joint  = TRUE;
-          *top++     = arc[0].x;
-        
-          DEBUG_PSET;
-        
-          e += ras.precision;
-        }
-        arc -= 2;
-      }
-    }
-
-  Fin:
-    ras.cursor = top;
-    ras.arc   -= 2;
-    return SUCCESS;
-  }
-
-
-/****************************************************************************/
-/*                                                                          */
-/* <Function>   Conic_Down                                                  */
-/*                                                                          */
-/* <Description>                                                            */
-/*     Computes the scan-line intersections of a descending second-order    */
-/*     Bezier arc and stores them in the render pool. The arc is taken      */
-/*     from the top of the stack..                                          */
-/*                                                                          */
-/* <Input>                                                                  */
-/*     miny     :: minimum vertical grid coordinate                         */
-/*     maxy     :: maximum vertical grid coordinate                         */
-/*                                                                          */
-/* <Return>                                                                 */
-/*     SUCCESS or FAILURE                                                   */
-/*                                                                          */
-/****************************************************************************/
-
-  static 
-  TBool  Conic_Down( RAS_ARGS TPos  miny, TPos  maxy )
-  {
-    TPoint*  arc = ras.arc;
-    TBool     result, fresh;
-
-
-    arc[0].y = -arc[0].y;
-    arc[1].y = -arc[1].y; 
-    arc[2].y = -arc[2].y;
-
-    fresh = ras.fresh;
-
-    result = Conic_Up( RAS_VARS -maxy, -miny );
-
-    if ( fresh && !ras.fresh )
-      ras.cur_prof->start = -ras.cur_prof->start;
-
-    arc[0].y = -arc[0].y;
-    return result;
-  }
-
-#endif /* FT_RASTER_CONIC_BEZIERS */
-
-
-
-#ifdef FT_RASTER_CUBIC_BEZIERS
-/****************************************************************************/
-/*                                                                          */
-/* <Function>   Cubic_Up                                                    */
-/*                                                                          */
-/* <Description>                                                            */
-/*     Computes the scan-line intersections of an ascending third-order     */
-/*     bezier arc and stores them in the render pool                        */
-/*                                                                          */
-/* <Input>                                                                  */
-/*     miny     :: minimum vertical grid coordinate                         */
-/*     maxy     :: maximum vertical grid coordinate                         */
-/*                                                                          */
-/* <Return>                                                                 */
-/*     SUCCESS or FAILURE                                                   */
-/*                                                                          */
-/****************************************************************************/
-  static
-  TBool  Cubic_Up( RAS_ARGS TPos  miny, TPos  maxy )
-  {
-    TPos  y1, y2, e, e2, e0;
-    int   f1;
-
-    TPoint*  arc;
-    TPoint*  start_arc;
-
-    TPos*    top;
-
-
-    arc = ras.arc;
-    y1  = arc[3].y;
-    y2  = arc[0].y;
-    top = ras.cursor; 
-
-    if ( y2 < miny || y1 > maxy )
-      goto Fin;
-    
-    e2 = FLOOR( y2 );
-
-    if ( e2 > maxy )
-      e2 = maxy;
-
-    e0 = miny;
-
-    if ( y1 < miny )
-      e = miny;
-    else
-    {
-      e  = CEILING( y1 );
-      f1 = FRAC( y1 );
-      e0 = e;
-
-      if ( f1 == 0 )
-      {
-        if ( ras.joint )
-        {
-          top--;
-          ras.joint = FALSE;
-        }
-
-        *top++ = arc[3].x;
-
-        DEBUG_PSET;
-
-        e += ras.precision;
-      }
-    }
-
-    if ( ras.fresh )
-    {
-      ras.cur_prof->start = TRUNC( e0 );
-      ras.fresh = FALSE;
-    }
-
-    if ( e2 < e )
-      goto Fin;
-
-    if ( ( top+TRUNC(e2-e)+1 ) >= ras.pool_limit )
-    {
-      ras.cursor = top;
-      ras.error  = ErrRaster_Overflow;
-      return FAILURE;
-    }
-
-    start_arc = arc;
-
-    while ( arc >= start_arc && e <= e2 )
-    {
-      ras.joint = FALSE;
-
-      y2 = arc[0].y;
-
-      if ( y2 > e )
-      {
-        y1 = arc[3].y;
-        if ( y2 - y1 >= ras.precision_step )
-        {
-          Split_Cubic( arc );
-          arc += 3;
-        }
-        else
-        {
-          *top++ = arc[3].x + 
-                   FMulDiv( arc[0].x-arc[3].x, 
-                            e  - y1, 
-                            y2 - y1 );
-          DEBUG_PSET;
-            
-          arc -= 3;
-          e   += ras.precision;
-        }
-      }
-      else
-      {
-        if ( y2 == e )
-        {
-          ras.joint  = TRUE;
-          *top++     = arc[0].x;
-        
-          DEBUG_PSET;
-        
-          e += ras.precision;
-        }
-        arc -= 3;
-      }
-    }
-
-  Fin:
-    ras.cursor = top;
-    ras.arc   -= 3;
-    return SUCCESS;
-  }
-
-
-/****************************************************************************/
-/*                                                                          */
-/* <Function>   Cubic_Down                                                  */
-/*                                                                          */
-/* <Description>                                                            */
-/*     Computes the scan-line intersections of a descending third-order     */
-/*     bezier arc and stores them in the render pool                        */
-/*                                                                          */
-/* <Input>                                                                  */
-/*     miny     :: minimum vertical grid coordinate                         */
-/*     maxy     :: maximum vertical grid coordinate                         */
-/*                                                                          */
-/* <Return>                                                                 */
-/*     SUCCESS or FAILURE                                                   */
-/*                                                                          */
-/****************************************************************************/
-  static 
-  TBool  Cubic_Down( RAS_ARGS TPos  miny, TPos  maxy )
-  {
-    TPoint*  arc = ras.arc;
-    TBool     result, fresh;
-
-
-    arc[0].y = -arc[0].y;
-    arc[1].y = -arc[1].y; 
-    arc[2].y = -arc[2].y;
-    arc[3].y = -arc[3].y;
-
-    fresh = ras.fresh;
-
-    result = Cubic_Up( RAS_VARS -maxy, -miny );
-
-    if ( fresh && !ras.fresh )
-      ras.cur_prof->start = -ras.cur_prof->start;
-
-    arc[0].y = -arc[0].y;
-    return result;
-  }
-
-#endif /* FT_RASTER_CUBIC_BEZIERS */
-
-
-
-
-
  /* A function type describing the functions used to split bezier arcs */
   typedef  void  (*TSplitter)( TPoint*  base );
 
@@ -2756,6 +2416,21 @@
 /*                                                                     */
 /***********************************************************************/
 
+  static
+  const  Word32  LMask5[17] =
+             { 0xF0F0F0F0, 0xF0F0F070, 0xF0F0F030, 0xF0F0F010,
+               0xF0F0F000, 0xF0F07000, 0xF0F03000, 0xF0F01000,
+               0xF0F00000, 0xF0700000, 0xF0300000, 0xF0100000,
+               0xF0000000, 0x70000000, 0x30000000, 0x10000000,
+               0x00000000 };
+
+  static
+  const  Word32  LPos5[17] =
+             { 0x80000000, 0x40000000, 0x20000000, 0x10000000,
+               0x00800000, 0x00400000, 0x00200000, 0x00100000,
+               0x00008000, 0x00004000, 0x00002000, 0x00001000,
+               0x00000080, 0x00000040, 0x00000020, 0x00000010 };
+
   static void  Vertical_Gray5_Sweep_Init( RAS_ARGS int*  min, int*  max )
   {
     long  pitch;
@@ -2775,29 +2450,12 @@
     ras.gray_max_x = -32000;
   }
 
-
   static void  Vertical_Gray5_Sweep_Span( RAS_ARGS TScan  y,
                                                    TPos   x1,
                                                    TPos   x2 )
   {
-    static
-    const unsigned int  LMask[17] =
-#ifdef FT_RASTER_LITTLE_ENDIAN
-             { 0xF0F0F0F0, 0xF0F0F070, 0xF0F0F030, 0xF0F0F010,
-               0xF0F0F000, 0xF0F07000, 0xF0F03000, 0xF0F01000,
-               0xF0F00000, 0xF0700000, 0xF0300000, 0xF0100000,
-               0xF0000000, 0x70000000, 0x30000000, 0x10000000,
-               0x00000000 };
-#else
-             { 0xF0F0F0F0, 0x70F0F0F0, 0x30F0F0F0, 0x10F0F0F0,
-               0x00F0F0F0, 0x0070F0F0, 0x0030F0F0, 0x0010F0F0,
-               0x0000F0F0, 0x000070F0, 0x000030F0, 0x000010F0,
-               0x000000F0, 0x00000070, 0x00000030, 0x00000010,
-               0x00000000 };
-#endif
-
-    TPos   e1, e2;
-    int    c1, c2;
+    TPos    e1, e2;
+    int     c1, c2;
     TByte*  target;
 
     unsigned int    f1, f2;
@@ -2823,9 +2481,9 @@
       c1 = e1 >> 4;
       c2 = e2 >> 4;
 
-      fill = LMask[0];
-      f1   = LMask[ e1 & 15 ];
-      f2   = fill ^ LMask[ 1+(e2 & 15) ];
+      fill = LMask5[0];
+      f1   = LMask5[ e1 & 15 ];
+      f2   = fill ^ LMask5[ 1+(e2 & 15) ];
 
       f1   >>= shift;
       f2   >>= shift;
@@ -2839,7 +2497,7 @@
 
       if (c2 > 0)
       {
-        int*  slice = (int*)target;
+        Word32*  slice = (Word32*)target;
         
         slice[0] |= f1;
         c2--;
@@ -2851,7 +2509,7 @@
         slice[1] |= f2;
       }
       else
-        ((int*)target)[0] |= ( f1 & f2 );
+        ((Word32*)target)[0] |= ( f1 & f2 );
     }
   }
 
@@ -2860,15 +2518,14 @@
   int  Vertical_Gray5_Test_Pixel( RAS_ARGS int  y,
                                            int  x )
   {
-    int c1    = x >> 2;
-    int f1    = x  & 3;
-    int mask  = (0x80 >> f1) >> ((y & 1)*4);
+    int     c1    = x >> 4;
+    Word32  mask  = LPos5[ x & 15 ] >> ((y & 1)*4);
 
     (void)y;
     
     return ( x >= 0                    && 
              x < ras.bit_width         && 
-             ras.bit_buffer[c1] & mask );
+             ((Word32*)ras.bit_buffer + c1)[0] & mask );
   }
 
 
@@ -2882,14 +2539,13 @@
 
     if ( x >= 0 && x < ras.bit_width )
     {
-      int c1   = x >> 2;
-      int f1   = x  & 3;
-      int mask = (0x80 >> f1) >> ((y & 1)*4);
+      int    c1   = x >> 4;
+      Word32 mask = LPos5[ x & 15 ] >> ((y & 1)*4);
   
-      if ( ras.gray_min_x > c1/4 ) ras.gray_min_x = c1/4;
-      if ( ras.gray_max_x < c1/4 ) ras.gray_max_x = c1/4;
+      if ( ras.gray_min_x > c1 ) ras.gray_min_x = c1;
+      if ( ras.gray_max_x < c1 ) ras.gray_max_x = c1;
 
-      ras.bit_buffer[c1] |= mask;
+      ((Word32*)ras.bit_buffer + c1)[0] |= mask;
     }
   }
 
@@ -3886,6 +3542,7 @@
   static
   int  Raster_Render8( FT_Raster       raster )
   {
+    UNUSED_RASTER
     return ErrRaster_Unimplemented;
   }
 
@@ -4004,6 +3661,9 @@
                               int          count,
                               const char*  palette )
   {
+    (void)raster;
+    (void)palette;
+    
     switch (count)
     {
 #ifdef FT_RASTER_OPTION_ANTI_ALIAS
@@ -4077,7 +3737,7 @@
 
 #else
 
-#include <ftobjs.h>
+#include <freetype/internal/ftobjs.h>
 
   static
   int  ft_black2_new( FT_Memory  memory, FT_Raster  *araster )
diff --git a/demos/src/ftrast2.h b/demos/src/ftrast2.h
index 8cd9adb..a0b26b6 100644
--- a/demos/src/ftrast2.h
+++ b/demos/src/ftrast2.h
@@ -19,7 +19,7 @@
 #ifndef FTRAST2_H
 #define FTRAST2_H
 
-#include <ftimage.h>
+#include <freetype/ftimage.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/demos/src/ftstring.c b/demos/src/ftstring.c
index cd232ad..2888c6a 100644
--- a/demos/src/ftstring.c
+++ b/demos/src/ftstring.c
@@ -10,8 +10,8 @@
 /*                                                                          */
 /****************************************************************************/
 
-#include "freetype.h"
-#include "ftglyph.h"
+#include <freetype/freetype.h>
+#include <freetype/ftglyph.h>
 #include "common.h"
 
 #include <stdio.h>
@@ -23,7 +23,7 @@
 #include "graph.h"
 #include "grfont.h"
 
-#include "ftgrays.h"
+#include <freetype/ftgrays.h>
 
 #define  DIM_X   500
 #define  DIM_Y   400
diff --git a/demos/src/fttimer.c b/demos/src/fttimer.c
index 3be2615..78a3ec0 100644
--- a/demos/src/fttimer.c
+++ b/demos/src/fttimer.c
@@ -19,8 +19,7 @@
 /*                                                                          */
 /****************************************************************************/
 
-#include "freetype.h"
-#include "ftoutln.h"
+#include <freetype/freetype.h>
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -28,7 +27,7 @@
 #include <time.h>    /* for clock() */
 
 #include "graph.h"
-#include "ftgrays.h"
+#include <freetype/ftgrays.h>
 
 /* SunOS 4.1.* does not define CLOCKS_PER_SEC, so include <sys/param.h> */
 /* to get the HZ macro which is the equivalent.                         */
diff --git a/demos/src/ftview.c b/demos/src/ftview.c
index e0367b4..9e2a9b0 100644
--- a/demos/src/ftview.c
+++ b/demos/src/ftview.c
@@ -15,8 +15,7 @@
 /*                                                                          */
 /****************************************************************************/
 
-#include "freetype.h"
-#include "ftoutln.h"
+#include <freetype/freetype.h>
 #include "common.h"
 
 #include <stdio.h>
@@ -27,7 +26,8 @@
 #include "graph.h"
 #include "grfont.h"
 
-#include "ftgrays.h"
+#include <freetype/ftgrays.h>
+#include "ftrast.h"
 #include "ftrast2.h"
 
 #define  DIM_X   500
@@ -60,9 +60,9 @@
   int  ptsize;                /* current point size */
   
   int  hinted      = 1;       /* is glyph hinting active ?    */
-  int  antialias = 1;       /* is anti-aliasing active ?    */
+  int  antialias   = 0;       /* is anti-aliasing active ?    */
   int  use_sbits   = 1;       /* do we use embedded bitmaps ? */
-  int  low_prec    = 1;       /* force low precision          */
+  int  low_prec    = 0;       /* force low precision          */
   int  Num;                   /* current first glyph index    */
 
   int    res = 72;
@@ -425,8 +425,10 @@
     
     error = 1;
     if ( !antialias)
-      error = FT_Set_Raster( library, &ft_black2_raster );
-      
+    {
+      error = FT_Set_Raster( library, use_grays ? &ft_black2_raster
+                                                : &ft_black_raster );
+    }                                                
     else if ( use_grays && antialias )
       error = FT_Set_Raster( library, &ft_grays_raster );
       
diff --git a/demos/src/ttdebug.c b/demos/src/ttdebug.c
index 5239a82..c983013 100644
--- a/demos/src/ttdebug.c
+++ b/demos/src/ttdebug.c
@@ -26,7 +26,7 @@
 #endif
 
 
-#include "freetype.h"
+#include <freetype/freetype.h>
 #include "ttobjs.h"
 #include "ttdriver.h"
 #include "ttinterp.h"
diff --git a/include/freetype/config/ftconfig.h b/include/freetype/config/ftconfig.h
new file mode 100644
index 0000000..7db5818
--- /dev/null
+++ b/include/freetype/config/ftconfig.h
@@ -0,0 +1,186 @@
+/***************************************************************************/
+/*                                                                         */
+/*  ftconfig.h                                                             */
+/*                                                                         */
+/*    ANSI-specific configuration file (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.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This header file contains a number of macro definitions that are used */
+  /* by the rest of the engine. Most of the macros here are automatically  */
+  /* determined at compile time, and you should not need to change it to   */
+  /* port FreeType, except to compile the library with a non ANSI compiler */
+  /*                                                                       */
+  /* Note however that if some specific modifications are needed, we       */
+  /* advise you to place a modified copy in your build directory.          */
+  /*                                                                       */
+  /* The build directory is usually "freetype/config/<system>", and        */
+  /* contains system-specific files that are always included first when    */
+  /* building the library..                                                */
+  /*                                                                       */
+  /* This ANSI version should stay in "freetype/config"                    */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef FTCONFIG_H
+#define FTCONFIG_H
+
+/* Include the header file containing all developer build options */
+#include <freetype/config/ftoption.h>
+
+  /*************************************************************************/
+  /*                                                                       */
+  /*               PLATFORM-SPECIFIC CONFIGURATION MACROS                  */
+  /*                                                                       */
+  /* These macros can be toggled to suit a specific system.  The current   */
+  /* ones are defaults used to compile FreeType in an ANSI C environment   */
+  /* (16bit compilers are also supported).  Copy this file to your own     */
+  /* `freetype/arch/<system>'  directory, and edit it to port the engine.  */
+  /*                                                                       */
+  /*************************************************************************/
+
+
+/* Define to empty if the keyword does not work.  */
+/* #undef const */
+
+/* Define if you have the ANSI C header files.  */
+#define STDC_HEADERS 1
+
+/* We use <limits.h> values to know the sizes of the types.  */
+#include <limits.h>
+
+/* The number of bytes in an `int' type.  */
+#if   UINT_MAX == 0xFFFFFFFF
+#define SIZEOF_INT  4
+#elif UINT_MAX == 0xFFFF
+#define SIZEOF_INT  2
+#elif UINT_MAX > 0xFFFFFFFF && UINT_MAX == 0xFFFFFFFFFFFFFFFF
+#define SIZEOF_INT  8
+#else
+#error "Unsupported number of bytes in `int' type!"
+#endif
+
+/* The number of bytes in a `long' type.  */
+#if   ULONG_MAX == 0xFFFFFFFF
+#define SIZEOF_LONG  4
+#elif ULONG_MAX > 0xFFFFFFFF && ULONG_MAX == 0xFFFFFFFFFFFFFFFF
+#define SIZEOF_LONG  8
+#else
+#error "Unsupported number of bytes in `long' type!"
+#endif
+
+/* Define if you have the memcpy function.  */
+#define HAVE_MEMCPY 1
+
+/* Define if you have the <fcntl.h> header file.  */
+#define HAVE_FCNTL_H 0
+
+/* Define if you have the <unistd.h> header file.  */
+#define HAVE_UNISTD_H 0
+
+
+/* Preferred alignment of data */
+#define FT_ALIGNMENT  8
+
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /*                     AUTOMATIC CONFIGURATION MACROS                    */
+  /*                                                                       */
+  /*  These macros are computed from the ones defined above.  Don't touch  */
+  /*  their definition, unless you know precisely what you're doing.  No   */
+  /*  porter should need to mess with them.                                */
+  /*                                                                       */
+  /*************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* IntN types                                                            */
+  /*                                                                       */
+  /*   Used to guarantee the size of some specific integers.               */
+  /*                                                                       */
+  typedef signed short    FT_Int16;
+  typedef unsigned short  FT_Word16;
+
+#if SIZEOF_INT == 4
+
+  typedef signed int      FT_Int32;
+  typedef unsigned int    FT_Word32;
+
+#elif SIZEOF_LONG == 4
+
+  typedef signed long     FT_Int32;
+  typedef unsigned long   FT_Word32;
+
+#else
+#error "no 32bit type found - please check your configuration files"
+#endif
+
+#if SIZEOF_LONG == 8
+
+  /* LONG64 must be defined when a 64-bit type is available */
+#define LONG64
+#define INT64   long
+
+#else
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* many compilers provide the non-ANSI 'long long' 64-bit type.  You can */
+  /* activate it by defining the FTCALC_USE_LONG_LONG macro in `ftoption.h'*/
+  /* Note that this will produce many -ansi warnings during library        */
+  /* compilation, and that in many cases, the generated code will not be   */
+  /* smaller or faster !!                                                  */
+  /*                                                                       */
+#ifdef FTCALC_USE_LONG_LONG
+
+#define LONG64
+#define INT64   long long
+
+#endif /* FTCALC_USE_LONG_LONG */
+#endif
+
+
+#ifdef FT_MAKE_OPTION_SINGLE_OBJECT
+#define  LOCAL_DEF   static
+#define  LOCAL_FUNC  static
+#else
+#define  LOCAL_DEF   extern
+#define  LOCAL_FUNC  /* nothing */
+#endif
+
+#ifdef FT_MAKE_OPTION_SINGLE_LIBRARY_OBJECT
+#define  BASE_DEF    LOCAL_DEF
+#define  BASE_FUNC   LOCAL_FUNC
+#else
+#define  BASE_DEF    extern
+#define  BASE_FUNC   /* nothing */
+#endif
+
+#ifndef  EXPORT_DEF
+#define  EXPORT_DEF   extern
+#endif
+
+#ifndef  EXPORT_FUNC
+#define  EXPORT_FUNC  /* nothing */
+#endif
+
+#endif /* FTCONFIG_H */
+
+
+/* END */
diff --git a/config/ftmodule.h b/include/freetype/config/ftmodule.h
similarity index 100%
rename from config/ftmodule.h
rename to include/freetype/config/ftmodule.h
diff --git a/config/ftoption.h b/include/freetype/config/ftoption.h
similarity index 100%
rename from config/ftoption.h
rename to include/freetype/config/ftoption.h
diff --git a/include/freetype.h b/include/freetype/freetype.h
similarity index 99%
rename from include/freetype.h
rename to include/freetype/freetype.h
index ff4e2a8..ae87c51 100644
--- a/include/freetype.h
+++ b/include/freetype/freetype.h
@@ -52,9 +52,9 @@
 #define EXPORT_DEF  extern
 #endif
 
-#include <fterrors.h>
-#include <ftsystem.h>
-#include <ftimage.h>
+#include <freetype/fterrors.h>
+#include <freetype/ftsystem.h>
+#include <freetype/ftimage.h>
 
 #ifdef __cplusplus
   extern "C" {
diff --git a/include/ftbbox.h b/include/freetype/ftbbox.h
similarity index 98%
rename from include/ftbbox.h
rename to include/freetype/ftbbox.h
index f3dfb60..6b76946 100644
--- a/include/ftbbox.h
+++ b/include/freetype/ftbbox.h
@@ -30,7 +30,7 @@
 #ifndef FTBBOX_H
 #define FTBBOX_H
 
-#include <freetype.h>
+#include <freetype/freetype.h>
 
 #ifdef __cplusplus
   extern "C" {
diff --git a/include/freetype/fterrors.h b/include/freetype/fterrors.h
new file mode 100644
index 0000000..aa67c20
--- /dev/null
+++ b/include/freetype/fterrors.h
@@ -0,0 +1,115 @@
+/***************************************************************************/
+/*                                                                         */
+/*  fterrors.h                                                             */
+/*                                                                         */
+/*  FreeType error codes (specification).                                  */
+/*                                                                         */
+/*  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.                                        */
+/*                                                                         */
+/*  This file is used to define the FreeType error enumeration constants   */
+/*  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 } };                            */
+/*                                                                         */
+/*     const struct { int  err_code; const char*  err_msg }  ft_errors[] = */
+/*     #include <freetype/fterrors.h>                                      */
+/*  }                                                                      */
+/*                                                                         */
+/***************************************************************************/
+
+#ifndef FTERRORS_H
+#define FTERRORS_H
+
+#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 };
+#endif /* FT_ERRORDEF */
+
+#ifdef FT_ERROR_START_LIST
+FT_ERROR_START_LIST
+#endif
+
+  FT_ERRORDEF( FT_Err_Ok,                      0x0000, "no error" )
+  FT_ERRORDEF( FT_Err_Cannot_Open_Resource,    0x0001, "can't open stream"   )
+  FT_ERRORDEF( FT_Err_Unknown_File_Format,     0x0002, "unknown file format" )
+  FT_ERRORDEF( FT_Err_Invalid_File_Format,     0x0003, "broken file" )
+  
+  FT_ERRORDEF( FT_Err_Invalid_Argument,        0x0010, "invalid argument" )
+  FT_ERRORDEF( FT_Err_Invalid_Handle,          0x0011, "invalid object handle" )
+  FT_ERRORDEF( FT_Err_Invalid_Glyph_Index,     0x0012, "invalid glyph index" )
+  FT_ERRORDEF( FT_Err_Invalid_Character_Code,  0x0013, "invalid character code" )
+  
+  FT_ERRORDEF( FT_Err_Unimplemented_Feature,   0x0020, "unimplemented feature" )
+  FT_ERRORDEF( FT_Err_Invalid_Glyph_Format,    0x0021, "invalid glyph image format" )
+  
+  FT_ERRORDEF( FT_Err_Invalid_Library_Handle,  0x0030, "invalid library handle" )
+  FT_ERRORDEF( FT_Err_Invalid_Driver_Handle,   0x0031, "invalid module handle" )
+  FT_ERRORDEF( FT_Err_Invalid_Face_Handle,     0x0032, "invalid face handle" )
+  FT_ERRORDEF( FT_Err_Invalid_Size_Handle,     0x0033, "invalid size handle" )
+  FT_ERRORDEF( FT_Err_Invalid_Slot_Handle,     0x0034, "invalid glyph slot handle" )
+  FT_ERRORDEF( FT_Err_Invalid_CharMap_Handle,  0x0035, "invalid charmap handle" )
+  FT_ERRORDEF( FT_Err_Invalid_Outline,         0x0036, "invalid outline" )
+  FT_ERRORDEF( FT_Err_Invalid_Dimensions,      0x0037, "invalid dimensions" )
+  
+  FT_ERRORDEF( FT_Err_Unavailable_Outline,     0x0040, "unavailable outline" )
+  FT_ERRORDEF( FT_Err_Unavailable_Bitmap,      0x0041, "unavailable bitmap" )
+  FT_ERRORDEF( FT_Err_File_Is_Not_Collection,  0x0042, "file is not a font collection" )
+  FT_ERRORDEF( FT_Err_Too_Many_Drivers,        0x0043, "too many modules" )
+  FT_ERRORDEF( FT_Err_Too_Many_Glyph_Formats,  0x0044, "too many glyph formats" )
+  FT_ERRORDEF( FT_Err_Too_Many_Extensions,     0x0045, "too many extensions" )
+
+  FT_ERRORDEF( FT_Err_Out_Of_Memory,           0x0050, "out of memory" )
+  FT_ERRORDEF( FT_Err_Unlisted_Object,         0x0051, "unlisted object" )
+
+  FT_ERRORDEF( FT_Err_Invalid_Stream_Handle,   0x0060, "invalid stream handle" )
+  FT_ERRORDEF( FT_Err_Cannot_Open_Stream,      0x0061, "cannot open stream" )
+  FT_ERRORDEF( FT_Err_Invalid_Stream_Seek,     0x0062, "invalid stream seek" )
+  FT_ERRORDEF( FT_Err_Invalid_Stream_Skip,     0x0063, "invalid stream skip" )
+  FT_ERRORDEF( FT_Err_Invalid_Stream_Read,     0x0064, "invalid stream read" )
+  FT_ERRORDEF( FT_Err_Invalid_Stream_Operation, 0x0065, "invalid stream operation" )
+  FT_ERRORDEF( FT_Err_Invalid_Frame_Operation, 0x0066, "invalid frame operation" )
+  FT_ERRORDEF( FT_Err_Nested_Frame_Access,     0x0067, "nested frame access" )
+  FT_ERRORDEF( FT_Err_Invalid_Frame_Read,      0x0068, "invalid frame read" )
+  
+  FT_ERRORDEF( FT_Err_Too_Many_Points,         0x0070, "too many points in glyph" )
+  FT_ERRORDEF( FT_Err_Too_Many_Contours,       0x0071, "too many contours in glyph" )
+  FT_ERRORDEF( FT_Err_Invalid_Composite,       0x0072, "invalid composite glyph" )
+  FT_ERRORDEF( FT_Err_Too_Many_Hints,          0x0073, "too many hints in glyph" )
+  FT_ERRORDEF( FT_Err_Too_Many_Edges,          0x0074, "too many edges in glyph" )
+  FT_ERRORDEF( FT_Err_Too_Many_Strokes,        0x0075, "too many strokes in glyph" )
+
+/* range 0x400 - 0x4FF is reserved for TrueType specific stuff */
+
+/* range 0x500 - 0x5FF is reserved for TrueDoc  specific stuff */
+
+/* range 0x600 - 0x6FF is reserved for Type1    specific stuff */
+  
+  FT_ERRORDEF( FT_Err_Raster_Uninitialized,   0x0080, "raster uninitialized" )
+  FT_ERRORDEF( FT_Err_Raster_Corrupted,       0x0081, "raster corrupted !!" )
+  FT_ERRORDEF( FT_Err_Raster_Overflow,        0x0082, "raster overflow !!" )
+
+#ifdef FT_ERROR_END_LIST
+FT_ERROR_END_LIST
+#endif
+
+#undef FT_ERROR_START_LIST
+#undef FT_ERROR_END_LIST
+#undef FT_ERRORDEF
+
+#endif /* FTERRORS_H */
+
+/* END */
diff --git a/include/ftglyph.h b/include/freetype/ftglyph.h
similarity index 99%
rename from include/ftglyph.h
rename to include/freetype/ftglyph.h
index cafc241..6380efa 100644
--- a/include/ftglyph.h
+++ b/include/freetype/ftglyph.h
@@ -26,7 +26,7 @@
 #ifndef FTGLYPH_H
 #define FTGLYPH_H
 
-#include <freetype.h>
+#include <freetype/freetype.h>
 
   typedef enum {
   
diff --git a/include/ftgrays.h b/include/freetype/ftgrays.h
similarity index 95%
rename from include/ftgrays.h
rename to include/freetype/ftgrays.h
index 5a3e156..ca7da37 100644
--- a/include/ftgrays.h
+++ b/include/freetype/ftgrays.h
@@ -1,7 +1,7 @@
 #ifndef FTGRAYS_H
 #define FTGRAYS_H
 
-#include <ftimage.h>
+#include <freetype/ftimage.h>
 
   /*************************************************************************/
   /*                                                                       */
diff --git a/include/ftimage.h b/include/freetype/ftimage.h
similarity index 100%
rename from include/ftimage.h
rename to include/freetype/ftimage.h
diff --git a/include/ftraster.h b/include/freetype/ftraster.h
similarity index 98%
rename from include/ftraster.h
rename to include/freetype/ftraster.h
index 0ba630b..f7ce0f8 100644
--- a/include/ftraster.h
+++ b/include/freetype/ftraster.h
@@ -31,7 +31,7 @@
   /*                                                                       */
 /* #define _STANDALONE_ */
 
-#include <ftimage.h>
+#include <freetype/freetype.h>
 
 #ifndef EXPORT_DEF
 #define EXPORT_DEF  /* nothing */
diff --git a/include/ftsystem.h b/include/freetype/ftsystem.h
similarity index 100%
rename from include/ftsystem.h
rename to include/freetype/ftsystem.h
diff --git a/src/shared/autohint.h b/include/freetype/internal/autohint.h
similarity index 99%
rename from src/shared/autohint.h
rename to include/freetype/internal/autohint.h
index 288d1e4..fced489 100644
--- a/src/shared/autohint.h
+++ b/include/freetype/internal/autohint.h
@@ -62,7 +62,7 @@
   *
   */
 
-#include <freetype.h>
+#include <freetype/freetype.h>
 
   typedef struct FT_AutoHinterRec_  *FT_AutoHinter;
 
diff --git a/src/base/ftcalc.h b/include/freetype/internal/ftcalc.h
similarity index 96%
rename from src/base/ftcalc.h
rename to include/freetype/internal/ftcalc.h
index cbc2e70..aac9374 100644
--- a/src/base/ftcalc.h
+++ b/include/freetype/internal/ftcalc.h
@@ -19,8 +19,8 @@
 #ifndef FTCALC_H
 #define FTCALC_H
 
-#include <freetype.h>
-#include <ftconfig.h>   /* for LONG64 */
+#include <freetype/freetype.h>
+#include <freetype/config/ftconfig.h>   /* for LONG64 */
 
 #ifdef __cplusplus
   extern "C" {
diff --git a/src/base/ftdebug.h b/include/freetype/internal/ftdebug.h
similarity index 98%
rename from src/base/ftdebug.h
rename to include/freetype/internal/ftdebug.h
index 2e90646..bf0e164 100644
--- a/src/base/ftdebug.h
+++ b/include/freetype/internal/ftdebug.h
@@ -43,7 +43,7 @@
 #ifndef FTDEBUG_H
 #define FTDEBUG_H
 
-#include <ftconfig.h>   /* for FT_DEBUG_LEVEL_TRACE, FT_DEBUG_LEVEL_ERROR */
+#include <freetype/config/ftconfig.h>   /* for FT_DEBUG_LEVEL_TRACE, FT_DEBUG_LEVEL_ERROR */
 
 
 #ifdef __cplusplus
diff --git a/src/base/ftdriver.h b/include/freetype/internal/ftdriver.h
similarity index 99%
rename from src/base/ftdriver.h
rename to include/freetype/internal/ftdriver.h
index 3462a18..2f6117f 100644
--- a/src/base/ftdriver.h
+++ b/include/freetype/internal/ftdriver.h
@@ -18,7 +18,7 @@
 #ifndef FTDRIVER_H
 #define FTDRIVER_H
 
-#include <freetype.h>
+#include <freetype/freetype.h>
 
   /*************************************************************************/
   /*************************************************************************/
diff --git a/src/base/ftextend.h b/include/freetype/internal/ftextend.h
similarity index 99%
rename from src/base/ftextend.h
rename to include/freetype/internal/ftextend.h
index ddd891d..5c9232b 100644
--- a/src/base/ftextend.h
+++ b/include/freetype/internal/ftextend.h
@@ -18,7 +18,7 @@
 #ifndef FTEXTEND_H
 #define FTEXTEND_H
 
-#include <ftobjs.h>
+#include <freetype/internal/ftobjs.h>
 
 
 #ifdef __cplusplus
diff --git a/src/base/ftlist.h b/include/freetype/internal/ftlist.h
similarity index 98%
rename from src/base/ftlist.h
rename to include/freetype/internal/ftlist.h
index 6241115..97ef816 100644
--- a/src/base/ftlist.h
+++ b/include/freetype/internal/ftlist.h
@@ -26,7 +26,7 @@
 #ifndef FTLIST_H
 #define FTLIST_H
 
-#include <freetype.h>
+#include <freetype/freetype.h>
 
 #ifdef __cplusplus
   extern "C" {
diff --git a/src/base/ftobjs.h b/include/freetype/internal/ftobjs.h
similarity index 98%
rename from src/base/ftobjs.h
rename to include/freetype/internal/ftobjs.h
index afdda19..f20b0b0 100644
--- a/src/base/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -25,9 +25,9 @@
 #ifndef FTOBJS_H
 #define FTOBJS_H
 
-#include <ftconfig.h>
-#include <ftsystem.h>
-#include <ftdriver.h>
+#include <freetype/config/ftconfig.h>
+#include <freetype/ftsystem.h>
+#include <freetype/internal/ftdriver.h>
 
   /*************************************************************************/
   /*                                                                       */
@@ -67,7 +67,6 @@
 #define ABS( a )     ( (a) < 0 ? -(a) : (a) )
 #endif
 
-
   /*************************************************************************/
   /*                                                                       */
   /* <Macro>                                                               */
@@ -166,6 +165,14 @@
 
 #define FREE( _pointer_ )  FT_Free( memory, (void**)&(_pointer_) )
 
+  /* various useful types and definitions */
+
+  extern void FP_Panic( const char* message );
+
+  extern  FT_Memory  FP_New_Memory( void );
+
+
+
 
 
   EXPORT_DEF
diff --git a/src/base/ftoutln.h b/include/freetype/internal/ftoutln.h
similarity index 61%
rename from src/base/ftoutln.h
rename to include/freetype/internal/ftoutln.h
index 438d00b..a4f92ee 100644
--- a/src/base/ftoutln.h
+++ b/include/freetype/internal/ftoutln.h
@@ -1,6 +1,6 @@
 #ifndef FTOUTLN_H
 #define FTOUTLN_H
 
-#include <ftobjs.h>
+#include <freetype/internal/ftobjs.h>
 
 #endif /* FTOUTLN_H */
diff --git a/src/base/ftstream.h b/include/freetype/internal/ftstream.h
similarity index 99%
rename from src/base/ftstream.h
rename to include/freetype/internal/ftstream.h
index dc6017e..cc0b8de 100644
--- a/src/base/ftstream.h
+++ b/include/freetype/internal/ftstream.h
@@ -1,7 +1,7 @@
 #ifndef FTSTREAM_H
 #define FTSTREAM_H
 
-#include <ftobjs.h>
+#include <freetype/internal/ftobjs.h>
 
 /* format of an 8-bit frame_op value = [ xxxxx | e | s ] */
 /* where s is set to 1 when the value is signed..        */
diff --git a/src/shared/psnames.h b/include/freetype/internal/psnames.h
similarity index 99%
rename from src/shared/psnames.h
rename to include/freetype/internal/psnames.h
index 86fdba2..53011f3 100644
--- a/src/shared/psnames.h
+++ b/include/freetype/internal/psnames.h
@@ -19,7 +19,7 @@
 #ifndef PSNAMES_H
 #define PSNAMES_H
 
-#include <freetype.h>
+#include <freetype/freetype.h>
 
  /**************************************************************************
   *
diff --git a/src/shared/sfnt.h b/include/freetype/internal/sfnt.h
similarity index 99%
rename from src/shared/sfnt.h
rename to include/freetype/internal/sfnt.h
index d08f7f9..b08492a 100644
--- a/src/shared/sfnt.h
+++ b/include/freetype/internal/sfnt.h
@@ -19,8 +19,8 @@
 #ifndef SFNT_H
 #define SFNT_H
 
-#include <freetype.h>
-#include <tttypes.h>
+#include <freetype/freetype.h>
+#include <freetype/internal/tttypes.h>
 
 
   /*************************************************************************/
diff --git a/src/shared/t1types.h b/include/freetype/internal/t1types.h
similarity index 99%
rename from src/shared/t1types.h
rename to include/freetype/internal/t1types.h
index cdcfd88..9c755f5 100644
--- a/src/shared/t1types.h
+++ b/include/freetype/internal/t1types.h
@@ -21,8 +21,8 @@
 #ifndef T1TYPES_H
 #define T1TYPES_H
 
-#include <t1tables.h>
-#include <psnames.h>
+#include <freetype/t1tables.h>
+#include <freetype/internal/psnames.h>
 
 #ifdef __cplusplus
   extern "C" {
diff --git a/src/shared/tterrors.h b/include/freetype/internal/tterrors.h
similarity index 100%
rename from src/shared/tterrors.h
rename to include/freetype/internal/tterrors.h
diff --git a/src/shared/tttypes.h b/include/freetype/internal/tttypes.h
similarity index 99%
rename from src/shared/tttypes.h
rename to include/freetype/internal/tttypes.h
index 29136fe..f28c0b9 100644
--- a/src/shared/tttypes.h
+++ b/include/freetype/internal/tttypes.h
@@ -24,7 +24,7 @@
 #define TTTYPES_H
 
 
-#include <tttables.h>
+#include <freetype/tttables.h>
 
 
 #ifdef __cplusplus
diff --git a/include/t1tables.h b/include/freetype/t1tables.h
similarity index 71%
rename from include/t1tables.h
rename to include/freetype/t1tables.h
index ae7ed90..0f565aa 100644
--- a/include/t1tables.h
+++ b/include/freetype/t1tables.h
@@ -19,7 +19,7 @@
 #ifndef T1TABLES_H
 #define T1TABLES_H
 
-#include <freetype.h>
+#include <freetype/freetype.h>
 
  /* Note that we separate font data in T1_FontInfo and T1_Private structures */
  /* in order to later support multiple master fonts..                        */
@@ -103,6 +103,78 @@
   } T1_Private;
 
 
+ /*************************************************************************
+  *
+  * <Enum>  
+  *    T1_Blend_Flags
+  *
+  * <Description>
+  *    A set of flags used to indicate which fields are present in a
+  *    given blen dictionary (font info or private). Used to support  
+  *    multiple masters..
+  *
+  */
+  typedef enum
+  {
+    t1_blend_none = 0,
+
+    /* required fields in a FontInfo blend dictionary */
+    t1_blend_underline_position,
+    t1_blend_underline_thickness,
+    t1_blend_italic_angle,
+    
+    /* required fields in a Private blend dictionary */    
+    t1_blend_blue_values,
+    t1_blend_other_blues,
+    t1_blend_standard_width,
+    t1_blend_standard_height,
+    t1_blend_stem_snap_widths,
+    t1_blend_stem_snap_heights,
+    t1_blend_blue_scale,
+    t1_blend_blue_shift,
+    t1_blend_family_blues,
+    t1_blend_family_other_blues,
+    t1_blend_force_bold,
+
+    /* never remove */
+    t1_blend_max
+    
+  } T1_Flags;
+
+
+  typedef struct T1_Blend_Pos
+  {
+    FT_Fixed  min;
+    FT_Fixed  max;
+    
+  } T1_Blend_Pos;
+
+ /*************************************************************************
+  *
+  * <Struct>
+  *    T1_Blend
+  *
+  * <Description>
+  *    A structure used to describe the multiple-master fonts information
+  *    of a given Type 1 font.
+  *
+  */
+  typedef struct T1_Blend_
+  {
+    FT_Int       num_axis;
+    FT_String*   axis_types[4];
+    
+    /* XXXX : add /BlendDesignMap entries */   
+    
+    FT_Int       num_blends;
+    T1_Flags*    flags    [17];
+    T1_Private*  privates [17];
+    T1_FontInfo* fontinfos[17];
+  
+  } T1_Blend;
+
+
+
   typedef struct CID_FontDict_
   {
     T1_FontInfo   font_info;
@@ -142,4 +214,5 @@
   } CID_Info;
 
 
+
 #endif /* T1TABLES_H */
diff --git a/include/ttnameid.h b/include/freetype/ttnameid.h
similarity index 100%
rename from include/ttnameid.h
rename to include/freetype/ttnameid.h
diff --git a/include/tttables.h b/include/freetype/tttables.h
similarity index 99%
rename from include/tttables.h
rename to include/freetype/tttables.h
index 87f7600..edd6780 100644
--- a/include/tttables.h
+++ b/include/freetype/tttables.h
@@ -19,7 +19,7 @@
 #ifndef TTTABLES_H
 #define TTTABLES_H
 
-#include <freetype.h>
+#include <freetype/freetype.h>
 
   /*************************************************************************/
   /*                                                                       */
diff --git a/src/shared/tttags.h b/include/freetype/tttags.h
similarity index 97%
rename from src/shared/tttags.h
rename to include/freetype/tttags.h
index 3cb3bc9..e55593f 100644
--- a/src/shared/tttags.h
+++ b/include/freetype/tttags.h
@@ -20,7 +20,7 @@
 #define TTAGS_H
 
 
-#include <freetype.h>   /* for MAKE_TT_TAG() */
+#include <freetype/freetype.h>   /* for MAKE_TT_TAG() */
 
 
 #define TTAG_cmap  FT_MAKE_TAG( 'c', 'm', 'a', 'p' )
diff --git a/include/fterrors.h b/include/fterrors.h
deleted file mode 100644
index 6df9ae3..0000000
--- a/include/fterrors.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/***************************************************************************/
-/*                                                                         */
-/*  fterrors.h                                                             */
-/*                                                                         */
-/*  FreeType error codes (specification).                                  */
-/*                                                                         */
-/*  Copyright 1996-1999 by                                                 */
-/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
-/*                                                                         */
-/*  This file is part of the FreeType project, and may only be used        */
-/*  modified and distributed under the terms of the FreeType project       */
-/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
-/*  this file you indicate that you have read the license and              */
-/*  understand and accept it fully.                                        */
-/*                                                                         */
-/***************************************************************************/
-
-
-#define  FT_Err_Ok                       0x000
-
-#define  FT_Err_Cannot_Open_Resource     0x001
-#define  FT_Err_Unknown_File_Format      0x002
-#define  FT_Err_Invalid_File_Format      0x002
-
-#define  FT_Err_Invalid_Argument         0x003
-#define  FT_Err_Invalid_Handle           0x004
-#define  FT_Err_Invalid_Glyph_Index      0x00A
-#define  FT_Err_Invalid_Character_Code   0x00B
-
-#define  FT_Err_Unimplemented_Feature    0x010
-#define  FT_Err_Invalid_Glyph_Format     0x00D
-
-#define  FT_Err_Invalid_Library_Handle   0x004
-#define  FT_Err_Invalid_Driver_Handle    0x005
-#define  FT_Err_Invalid_Face_Handle      0x006
-#define  FT_Err_Invalid_Size_Handle      0x007
-#define  FT_Err_Invalid_Slot_Handle      0x008
-#define  FT_Err_Invalid_CharMap_Handle   0x009
-#define  FT_Err_Invalid_Outline          0x00B
-#define  FT_Err_Invalid_Dimensions       0x00C
-
-#define  FT_Err_Unavailable_Outline      0x011
-#define  FT_Err_Unavailable_Bitmap       0x012
-#define  FT_Err_Unavailable_Pixmap       0x013
-#define  FT_Err_File_Is_Not_Collection   0x014
-#define  FT_Err_Too_Many_Drivers         0x015
-#define  FT_Err_Too_Many_Glyph_Formats   0x016
-#define  FT_Err_Too_Many_Extensions      0x017
-
-#define  FT_Err_Out_Of_Memory            0x100
-#define  FT_Err_Unlisted_Object          0x101
-
-#define  FT_Err_Invalid_Resource_Handle  0x200
-#define  FT_Err_Invalid_Stream_Handle    0x201
-#define  FT_Err_Cannot_Open_Stream       0x202
-#define  FT_Err_Invalid_Stream_Seek      0x203
-#define  FT_Err_Invalid_Stream_Skip      0x204
-#define  FT_Err_Invalid_Stream_Read      0x205
-#define  FT_Err_Invalid_Stream_Operation 0x206
-#define  FT_Err_Invalid_Frame_Operation  0x207
-#define  FT_Err_Nested_Frame_Access      0x208
-#define  FT_Err_Invalid_Frame_Read       0x209
-
-#define  FT_Err_Too_Many_Points          0x300
-#define  FT_Err_Too_Many_Contours        0x301
-#define  FT_Err_Invalid_Composite        0x302
-#define  FT_Err_Too_Many_Hints           0x303
-#define  FT_Err_Too_Many_Edges           0x304
-#define  FT_Err_Too_Many_Strokes         0x305
-
-/* range 0x400 - 0x4FF is reserved for TrueType specific stuff */
-
-/* range 0x500 - 0x5FF is reserved for TrueDoc  specific stuff */
-
-/* range 0x600 - 0x6FF is reserved for Type1    specific stuff */
-
-#define  FT_Err_Raster_Uninitialized     0xF00
-#define  FT_Err_Raster_Corrupted         0xF01
-#define  FT_Err_Raster_Overflow          0xF02
-
-
-/* END */
diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c
index 3440e42..92ad706 100644
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -30,9 +30,9 @@
   /*                                                                       */
   /*************************************************************************/
 
-#include <ftcalc.h>
-#include <ftdebug.h>
-#include <ftobjs.h>  /* for ABS() */
+#include <freetype/internal/ftcalc.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftobjs.h>  /* for ABS() */
 
 
 #ifdef FT_CONFIG_OPTION_OLD_CALCS
diff --git a/src/base/ftdebug.c b/src/base/ftdebug.c
index 06d2329..fa71216 100644
--- a/src/base/ftdebug.c
+++ b/src/base/ftdebug.c
@@ -16,7 +16,7 @@
 /***************************************************************************/
 
 
-#include <ftdebug.h>
+#include <freetype/internal/ftdebug.h>
 
 #ifdef FT_DEBUG_LEVEL_TRACE
   char  ft_trace_levels[trace_max];
diff --git a/src/base/ftextend.c b/src/base/ftextend.c
index 9bbe0bf..5cddfcd 100644
--- a/src/base/ftextend.c
+++ b/src/base/ftextend.c
@@ -24,7 +24,7 @@
   /*                                                                       */
   /*************************************************************************/
 
-#include <ftextend.h>
+#include <freetype/internal/ftextend.h>
 
 /* required by the tracing mode */
 #undef  FT_COMPONENT
diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c
index 248c386..17e698e 100644
--- a/src/base/ftglyph.c
+++ b/src/base/ftglyph.c
@@ -23,8 +23,8 @@
 /*                                                                         */
 /***************************************************************************/
 
-#include <ftglyph.h>
-#include <ftobjs.h>
+#include <freetype/ftglyph.h>
+#include <freetype/internal/ftobjs.h>
 
   static
   void ft_prepare_glyph( FT_Glyph  glyph,
diff --git a/src/base/ftgrays.c b/src/base/ftgrays.c
index 9362f0b..9228fde 100644
--- a/src/base/ftgrays.c
+++ b/src/base/ftgrays.c
@@ -46,7 +46,7 @@
 /*     - faster than the standard renderer for small (< 20) pixel sizes      */
 /*                                                                           */
 
-#include <ftgrays.h>
+#include <freetype/ftgrays.h>
 
 #if 1
 #include <string.h>  /* for memcpy */
@@ -57,7 +57,7 @@
 #ifdef _STANDALONE_
 #error "implementation of FT_Outline_Decompose missing !!!"
 #else
-#include <freetype.h>  /* to link to FT_Outline_Decompose */
+#include <freetype/freetype.h>  /* to link to FT_Outline_Decompose */
 #endif
 
 /* define this to dump debugging information */
@@ -1428,7 +1428,7 @@
 
 #else
 
-#include "ftobjs.h"
+#include <freetype/internal/ftobjs.h>
 
   static
   int  grays_raster_new( FT_Memory  memory, FT_Raster*  araster )
diff --git a/src/base/ftinit.c b/src/base/ftinit.c
index 01e1454..0399dc4 100644
--- a/src/base/ftinit.c
+++ b/src/base/ftinit.c
@@ -41,10 +41,10 @@
   /*************************************************************************/
 
 
-#include <ftobjs.h>
-#include <ftconfig.h>
-#include <ftdebug.h>
-#include <ftdriver.h>
+#include <freetype/config/ftconfig.h>
+#include <freetype/internal/ftobjs.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftdriver.h>
 
 #undef  FT_COMPONENT
 #define FT_COMPONENT  trace_init
@@ -52,7 +52,7 @@
 #undef  FT_DRIVER
 #define FT_DRIVER( x )  extern FT_DriverInterface  x;
 
-#include <ftmodule.h>
+#include <freetype/config/ftmodule.h>
 
 #undef  FT_DRIVER
 #define FT_DRIVER( x )  &x,
@@ -60,7 +60,7 @@
 static
 const FT_DriverInterface*  ft_default_drivers[] =
   {
-#include <ftmodule.h>
+#include <freetype/config/ftmodule.h>
     0
   };
 
diff --git a/src/base/ftlist.c b/src/base/ftlist.c
index a7db223..ddcba9a 100644
--- a/src/base/ftlist.c
+++ b/src/base/ftlist.c
@@ -23,9 +23,9 @@
   /*************************************************************************/
 
 
-#include <ftlist.h>
-#include <ftdebug.h>
-#include <ftobjs.h>
+#include <freetype/internal/ftlist.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftobjs.h>
 
 
   /*************************************************************************/
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 121ab11..436cee3 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -15,12 +15,12 @@
 /*                                                                         */
 /***************************************************************************/
 
-#include <ftobjs.h>
-#include <ftlist.h>
-#include <ftdebug.h>
-#include <ftstream.h>
+#include <freetype/internal/ftobjs.h>
+#include <freetype/internal/ftlist.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftstream.h>
 
-#include <tttables.h>
+#include <freetype/tttables.h>
 
   /*************************************************************************/
   /*************************************************************************/
diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c
index f63115f..4018168 100644
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -23,11 +23,10 @@
   /*************************************************************************/
 
 
-#include <freetype.h>
-#include <ftconfig.h>
-#include <ftobjs.h>
-#include <ftimage.h>
-#include <ftoutln.h>
+#include <freetype/freetype.h>
+#include <freetype/config/ftconfig.h>
+#include <freetype/internal/ftobjs.h>
+#include <freetype/internal/ftoutln.h>
 
   static
   const FT_Outline  null_outline = { 0, 0, 0, 0, 0, 0 };
diff --git a/src/base/ftraster.c b/src/base/ftraster.c
index 82ecd0e..c0c444a 100644
--- a/src/base/ftraster.c
+++ b/src/base/ftraster.c
@@ -61,10 +61,9 @@
 #endif
 
 
-#include <ftraster.h>
+#include <freetype/ftraster.h>
 #ifndef _STANDALONE_
-#include <ftconfig.h>
-#include <ftdebug.h>
+#include <freetype/internal/ftdebug.h>
 #endif
 
 #ifndef EXPORT_FUNC
@@ -167,8 +166,8 @@
 
 #else /* _STANDALONE_ */
 
-#include <freetype.h>
-#include <ftconfig.h>
+#include <freetype/freetype.h>
+#include <freetype/config/ftconfig.h>
 
   /*************************************************************************/
   /*                                                                       */
@@ -3924,7 +3923,7 @@
 
 #else
 
-#include "ftobjs.h"
+#include <freetype/internal/ftobjs.h>
 
   static
   int  ft_raster_new( FT_Memory  memory, FT_Raster*  araster )
diff --git a/src/base/ftstream.c b/src/base/ftstream.c
index a391068..03abfb5 100644
--- a/src/base/ftstream.c
+++ b/src/base/ftstream.c
@@ -1,5 +1,5 @@
-#include <ftstream.h>
-#include <ftdebug.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/internal/ftdebug.h>
 
 #undef  FT_COMPONENT
 #define FT_COMPONENT  trace_stream
diff --git a/src/base/ftsystem.c b/src/base/ftsystem.c
index 0da26b8..9836e41 100644
--- a/src/base/ftsystem.c
+++ b/src/base/ftsystem.c
@@ -20,8 +20,8 @@
  *                                                                           
  **************************************************************************/
 
-#include <ftsystem.h>
-#include <fterrors.h>
+#include <freetype/ftsystem.h>
+#include <freetype/fterrors.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/base/rules.mk b/src/base/rules.mk
index 875bd0d..7ea7488 100644
--- a/src/base/rules.mk
+++ b/src/base/rules.mk
@@ -39,13 +39,13 @@
 
 # Base layer headers
 #
-BASE_H := $(BASE_)ftcalc.h    \
-          $(BASE_)ftdebug.h   \
-          $(BASE_)ftdriver.h  \
-          $(BASE_)ftextend.h  \
-          $(BASE_)ftlist.h    \
-          $(BASE_)ftobjs.h    \
-          $(BASE_)ftstream.h
+BASE_H := $(INTERNAL_)ftcalc.h    \
+          $(INTERNAL_)ftdebug.h   \
+          $(INTERNAL_)ftdriver.h  \
+          $(INTERNAL_)ftextend.h  \
+          $(INTERNAL_)ftlist.h    \
+          $(INTERNAL_)ftobjs.h    \
+          $(INTERNAL_)ftstream.h
 
 
 # Base layer `extensions' sources
diff --git a/src/macfond/fonddrvr.c b/src/macfond/fonddrvr.c
index f004f5f..b0a03f3 100644
--- a/src/macfond/fonddrvr.c
+++ b/src/macfond/fonddrvr.c
@@ -63,8 +63,8 @@
       change to ftobjs.c to make this work.
 */
 
-#include <ttobjs.h>
-#include <t1objs.h>
+#include <freetype/internal/ttobjs.h>
+#include <freetype/internal/t1objs.h>
 
 #include <Resources.h>
 #include <Fonts.h>
diff --git a/src/oldapi/ttapi.c b/src/oldapi/ttapi.c
index ae31f02..6367251 100644
--- a/src/oldapi/ttapi.c
+++ b/src/oldapi/ttapi.c
@@ -21,17 +21,17 @@
  *
  ******************************************************************/
 
-#include <freetype.h>
+#include <freetype/freetype.h>
 
-#include <ftdebug.h>
-#include <ftstream.h>
-#include <ftcalc.h>
-#include <ftlist.h>
-#include <ftraster.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/internal/ftcalc.h>
+#include <freetype/internal/ftlist.h>
+#include <freetype/internal/ftraster.h>
 
-#include <ttdriver.h>
-#include <ttobjs.h>
-#include <ttcmap.h>
+#include <../truetype/ttdriver.h>
+#include <../truetype/ttobjs.h>
+#include <../truetype/ttcmap.h>
 
 #define _TRUETYPE_
 #include <truetype.h>  /* backwards compatible interface */
diff --git a/src/psnames/psdriver.c b/src/psnames/psdriver.c
index 8162bd4..23d59b8 100644
--- a/src/psnames/psdriver.c
+++ b/src/psnames/psdriver.c
@@ -1,6 +1,6 @@
+#include <freetype/internal/psnames.h>
+#include <freetype/internal/ftobjs.h>
 #include <psdriver.h>
-#include <psnames.h>
-#include <ftobjs.h>
 #include <stdlib.h>
 
 #ifndef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES
diff --git a/src/psnames/psdriver.h b/src/psnames/psdriver.h
index 4349457..615eb93 100644
--- a/src/psnames/psdriver.h
+++ b/src/psnames/psdriver.h
@@ -19,8 +19,8 @@
 #ifndef PSDRIVER_H
 #define PSDRIVER_H
 
-#include <freetype.h>
-#include <ftdriver.h>
+#include <freetype/freetype.h>
+#include <freetype/internal/ftdriver.h>
 
   EXPORT_DEF
   const FT_DriverInterface  psnames_driver_interface;
diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c
index 93472d9..0273067 100644
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -1,9 +1,9 @@
+#include <freetype/internal/sfnt.h>
 #include <sfdriver.h>
 #include <ttload.h>
 #include <ttsbit.h>
 #include <ttpost.h>
 #include <ttcmap.h>
-#include <sfnt.h>
 
   static const SFNT_Interface  sfnt_interface =
   {
diff --git a/src/sfnt/sfdriver.h b/src/sfnt/sfdriver.h
index b0eb258..43640eb 100644
--- a/src/sfnt/sfdriver.h
+++ b/src/sfnt/sfdriver.h
@@ -19,8 +19,7 @@
 #ifndef SFDRIVER_H
 #define SFDRIVER_H
 
-#include <freetype.h>
-#include <ftdriver.h>
+#include <freetype/internal/ftdriver.h>
 
   EXPORT_DEF
   const FT_DriverInterface  sfnt_driver_interface;
diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c
index 7a1a2ad..32604e0 100644
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -16,11 +16,11 @@
 /***************************************************************************/
 
 
-#include <ftdebug.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/tterrors.h>
 
 #include <ttload.h>
 #include <ttcmap.h>
-#include <tterrors.h>
 
 /* required by the tracing mode */
 #undef  FT_COMPONENT
diff --git a/src/sfnt/ttcmap.h b/src/sfnt/ttcmap.h
index d5da240..49ac80d 100644
--- a/src/sfnt/ttcmap.h
+++ b/src/sfnt/ttcmap.h
@@ -19,7 +19,7 @@
 #ifndef TTCMAP_H
 #define TTCMAP_H
 
-#include <tttypes.h>
+#include <freetype/internal/tttypes.h>
 
 #ifdef __cplusplus
   extern "C" {
diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c
index 211ee4a..0a7f087 100644
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -21,13 +21,12 @@
 /***************************************************************************/
 
 
-#include <ftdebug.h>
-#include <ftconfig.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/tterrors.h>
+#include <freetype/tttags.h>
 
 #include <ttload.h>
-#include <tttags.h>
 #include <ttcmap.h>
-#include <tterrors.h>
 
 /* required by the tracing mode */
 #undef  FT_COMPONENT
diff --git a/src/sfnt/ttload.h b/src/sfnt/ttload.h
index 28902e7..7a6d69a 100644
--- a/src/sfnt/ttload.h
+++ b/src/sfnt/ttload.h
@@ -21,8 +21,8 @@
 #define TTLOAD_H
 
 
-#include <ftstream.h>
-#include <tttypes.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/internal/tttypes.h>
 /*
 #include <ttobjs.h>
 */
diff --git a/src/sfnt/ttpost.c b/src/sfnt/ttpost.c
index b55eb5b..9055da5 100644
--- a/src/sfnt/ttpost.c
+++ b/src/sfnt/ttpost.c
@@ -24,17 +24,17 @@
   /*                                                                       */
   /*************************************************************************/
 
-#include <ftstream.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/internal/tterrors.h>
+#include <freetype/tttags.h>
 
 #include <ttpost.h>
-#include <tterrors.h>
 #include <ttload.h>
-#include <tttags.h>
 
 /* When this configuration macro is defined, we rely on the "psnames" */
 /* module to grab the glyph names..                                   */
 #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
-#include <psnames.h>
+#include <freetype/internal/psnames.h>
 #define  MAC_NAME(x)  ((TT_String*)psnames->macintosh_name(x))
 
 #else
diff --git a/src/sfnt/ttpost.h b/src/sfnt/ttpost.h
index eeb0bf1..944c00c 100644
--- a/src/sfnt/ttpost.h
+++ b/src/sfnt/ttpost.h
@@ -29,8 +29,8 @@
 #ifndef TTPOST_H
 #define TTPOST_H
 
-#include <ftconfig.h>
-#include <tttypes.h>
+#include <freetype/config/ftconfig.h>
+#include <freetype/internal/tttypes.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c
index b7020bb..1e63db2 100644
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -21,11 +21,11 @@
 /***************************************************************************/
 
 
-#include <ftdebug.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/tterrors.h>
+#include <freetype/tttags.h>
 
 #include <ttsbit.h>
-#include <tttags.h>
-#include <tterrors.h>
 
 
   /*************************************************************************/
diff --git a/src/shared/readme.txt b/src/shared/readme.txt
deleted file mode 100644
index b48163a..0000000
--- a/src/shared/readme.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-WARNING:
-
-The files in these subdirectories are shared by several font drivers.
-
-All C source files are included by at least one of the drivers, and
-thus should _never_ be compiled directly.
diff --git a/src/shared/rules.mk b/src/shared/rules.mk
deleted file mode 100644
index 6fc1d58..0000000
--- a/src/shared/rules.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# FreeType 2 shared files configuration rules
-#
-
-
-# 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 SHARED_RULES
-  SHARED_RULES := 1
-
-  SHARED  := $(SRC_)shared
-  SHARED_ := $(SHARED)$(SEP)
-
-  SHARED_H   := $(wildcard $(SHARED_)*.h)
-  SHARED_SRC := $(wildcard $(SHARED_)*.c) 
-
-endif
-
-# EOF
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index 7673f6a..82bcd6c 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -16,10 +16,10 @@
 /***************************************************************************/
 
 
-#include <ftdebug.h>
-#include <ftstream.h>
-#include <ttnameid.h>
-#include <sfnt.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/internal/sfnt.h>
+#include <freetype/ttnameid.h>
 
 #include <ttdriver.h>
 #include <ttgload.h>
diff --git a/src/truetype/ttdriver.h b/src/truetype/ttdriver.h
index 062e701..5e31b75 100644
--- a/src/truetype/ttdriver.h
+++ b/src/truetype/ttdriver.h
@@ -19,11 +19,10 @@
 #ifndef TTDRIVER_H
 #define TTDRIVER_H
 
-#include <freetype.h>
-#include <ftdriver.h>
+#include <freetype/internal/ftdriver.h>
+#include <freetype/ttnameid.h>
 #include <ttobjs.h>
 #include <tterrors.h>
-#include <ttnameid.h>
 
 
   EXPORT_DEF
diff --git a/src/truetype/tterrors.h b/src/truetype/tterrors.h
index 90286e3..c8b272c 100644
--- a/src/truetype/tterrors.h
+++ b/src/truetype/tterrors.h
@@ -19,7 +19,6 @@
 #ifndef TTERRORS_H
 #define TTERRORS_H
 
-
   /*************************************************************************/
   /*                                                                       */
   /* Error codes declaration                                               */
@@ -92,6 +91,9 @@
 #define TT_Err_Invalid_Displacement     0x410
 #define TT_Err_Execution_Too_Long       0x411
 
+#define TT_Err_Too_Many_Instruction_Defs  0x412
+#define TT_Err_Too_Many_Function_Defs     0x412
+
   /* Other TrueType specific error codes. */
 
 #define TT_Err_Table_Missing            0x420
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index e824f62..bd66e8f 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -16,16 +16,15 @@
 /***************************************************************************/
 
 
-#include <freetype.h>
-#include <ftdebug.h>
-#include <ftcalc.h>
-#include <ftstream.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftcalc.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/internal/sfnt.h>
+#include <freetype/tttags.h>
 
-#include <sfnt.h>
+
 #include <ttgload.h>
 
-#include <tttags.h>
-
 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
 #include <ttinterp.h>
 #endif
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index 8f84abd..d26293d 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -16,11 +16,12 @@
 /***************************************************************************/
 
 
-#include <ftdebug.h>
-#include <ftsystem.h>
-#include <ftcalc.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftcalc.h>
+#include <freetype/ftsystem.h>
 
 #include <ttobjs.h>
+#include <tterrors.h>
 #include <ttinterp.h>
 
 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c
index abb9599..2023f36 100644
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -16,15 +16,14 @@
 /***************************************************************************/
 
 
-#include <freetype.h>
-#include <ftdebug.h>
-#include <ftcalc.h>
-#include <ftstream.h>
-#include <ttnameid.h>
-#include <tttags.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftcalc.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/ttnameid.h>
+#include <freetype/tttags.h>
 
-#include <sfnt.h>
-#include <psnames.h>
+#include <freetype/internal/sfnt.h>
+#include <freetype/internal/psnames.h>
 #include <ttobjs.h>
 
 #include <ttpload.h>
diff --git a/src/truetype/ttobjs.h b/src/truetype/ttobjs.h
index e22d3f6..ac57b7b 100644
--- a/src/truetype/ttobjs.h
+++ b/src/truetype/ttobjs.h
@@ -20,8 +20,8 @@
 #define TTOBJS_H
 
 
-#include <ftobjs.h>
-#include <tttypes.h>
+#include <freetype/internal/ftobjs.h>
+#include <freetype/internal/tttypes.h>
 #include <tterrors.h>
 
 
diff --git a/src/truetype/ttpload.c b/src/truetype/ttpload.c
index 4293b93..56d61cc 100644
--- a/src/truetype/ttpload.c
+++ b/src/truetype/ttpload.c
@@ -16,12 +16,12 @@
 /***************************************************************************/
 
 
-#include <ftdebug.h>
-#include <ftobjs.h>
-#include <ftstream.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftobjs.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/tttags.h>
 
 #include <ttpload.h>
-#include <tttags.h>
 #include <tterrors.h>
 
 #undef  FT_COMPONENT
diff --git a/src/truetype/ttpload.h b/src/truetype/ttpload.h
index bb7c517..30b2972 100644
--- a/src/truetype/ttpload.h
+++ b/src/truetype/ttpload.h
@@ -19,7 +19,7 @@
 #ifndef TTPLOAD_H
 #define TTPLOAD_H
 
-#include <tttypes.h>
+#include <freetype/internal/tttypes.h>
 
 
 #ifdef __cplusplus
diff --git a/src/type1/t1afm.c b/src/type1/t1afm.c
index f619e28..2b904af 100644
--- a/src/type1/t1afm.c
+++ b/src/type1/t1afm.c
@@ -5,10 +5,10 @@
  *
  ***************************************************************************/
 
-#include <t1afm.h>
-#include <ftstream.h>
-#include <t1types.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/internal/t1types.h>
 #include <stdlib.h>  /* for qsort */
+#include <t1afm.h>
 
   LOCAL_FUNC
   void  T1_Done_AFM( FT_Memory memory, T1_AFM*  afm )
diff --git a/src/type1/t1afm.h b/src/type1/t1afm.h
index 567ed63..61e18b8 100644
--- a/src/type1/t1afm.h
+++ b/src/type1/t1afm.h
@@ -8,7 +8,7 @@
 #ifndef T1AFM_H
 #define T1AFM_H
 
-#include <ftobjs.h>
+#include <freetype/internal/ftobjs.h>
 
 /* In this version, we only read the kerning table from the */
 /* AFM file. We may add support for ligatures a bit later.. */
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index ed59201..78fe415 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -19,9 +19,9 @@
 #include <t1gload.h>
 #include <t1afm.h>
 
-#include <ftdebug.h>
-#include <ftstream.h>
-#include <psnames.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/internal/psnames.h>
 
 #undef  FT_COMPONENT
 #define FT_COMPONENT  trace_t1driver
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index d644267..e9cd8a3 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -16,8 +16,8 @@
  ******************************************************************/
 
 #include <t1gload.h>
-#include <ftdebug.h>
-#include <ftstream.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftstream.h>
 
 #ifndef T1_CONFIG_OPTION_DISABLE_HINTER
 #include <t1hinter.h>
diff --git a/src/type1/t1hinter.c b/src/type1/t1hinter.c
index 3a09ed7..f9d5db9 100644
--- a/src/type1/t1hinter.c
+++ b/src/type1/t1hinter.c
@@ -20,7 +20,7 @@
  *
  ******************************************************************/
 
-#include <ftdebug.h>
+#include <freetype/internal/ftdebug.h>
 #include <t1objs.h>
 #include <t1hinter.h>
 
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index 87c2d1f..e4802da 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -1,7 +1,7 @@
-#include <ftconfig.h>
-#include <ftdebug.h>
+#include <freetype/config/ftconfig.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/t1types.h>
 
-#include <t1types.h>
 #include <t1tokens.h>
 #include <t1parse.h>
 
diff --git a/src/type1/t1load.h b/src/type1/t1load.h
index 9e0ee47..673316a 100644
--- a/src/type1/t1load.h
+++ b/src/type1/t1load.h
@@ -18,7 +18,7 @@
 #ifndef T1LOAD_H
 #define T1LOAD_H
 
-#include <ftstream.h>
+#include <freetype/internal/ftstream.h>
 #include <t1parse.h>
 
 #ifdef __cplusplus
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index 79d26db..23b6a90 100644
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -15,8 +15,8 @@
  *
  ******************************************************************/
 
-#include <ftdebug.h>
-#include <ftstream.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftstream.h>
 
 #include <t1gload.h>
 #include <t1load.h>
@@ -26,7 +26,7 @@
 #include <t1hinter.h>
 #endif
 
-#include <psnames.h>
+#include <freetype/internal/psnames.h>
 
 /* Required by tracing mode */
 #undef   FT_COMPONENT
diff --git a/src/type1/t1objs.h b/src/type1/t1objs.h
index e11a3a1..51c7186 100644
--- a/src/type1/t1objs.h
+++ b/src/type1/t1objs.h
@@ -18,11 +18,11 @@
 #ifndef T1OBJS_H
 #define T1OBJS_H
 
-#include <ftobjs.h>
-#include <ftconfig.h>
+#include <freetype/config/ftconfig.h>
+#include <freetype/internal/ftobjs.h>
+#include <freetype/internal/t1types.h>
 
 #include <t1errors.h>
-#include <t1types.h>
 
 #ifdef __cplusplus
   extern "C" {
diff --git a/src/type1/t1parse.c b/src/type1/t1parse.c
index e3710b0..d897d74 100644
--- a/src/type1/t1parse.c
+++ b/src/type1/t1parse.c
@@ -1,5 +1,5 @@
-#include <ftdebug.h>
-#include <t1types.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/t1types.h>
 #include <t1parse.h>
 
 #include <stdio.h>  /* for sscanf */
diff --git a/src/type1/t1parse.h b/src/type1/t1parse.h
index b124c08..9966680 100644
--- a/src/type1/t1parse.h
+++ b/src/type1/t1parse.h
@@ -25,7 +25,7 @@
 #ifndef T1PARSE_H
 #define T1PARSE_H
 
-#include <ftstream.h>
+#include <freetype/internal/ftstream.h>
 #include <t1tokens.h>
 
 #ifdef __cplusplus
diff --git a/src/type1/t1tokens.c b/src/type1/t1tokens.c
index 92a16d7..f4aca28 100644
--- a/src/type1/t1tokens.c
+++ b/src/type1/t1tokens.c
@@ -23,8 +23,8 @@
  *
  ******************************************************************/
 
-#include <ftstream.h>
-#include <ftdebug.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/internal/ftdebug.h>
 
 #include <t1tokens.h>
 #include <t1load.h>
diff --git a/src/type1z/t1afm.c b/src/type1z/t1afm.c
index f619e28..b9f8d83 100644
--- a/src/type1z/t1afm.c
+++ b/src/type1z/t1afm.c
@@ -6,8 +6,8 @@
  ***************************************************************************/
 
 #include <t1afm.h>
-#include <ftstream.h>
-#include <t1types.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/internal/t1types.h>
 #include <stdlib.h>  /* for qsort */
 
   LOCAL_FUNC
diff --git a/src/type1z/t1afm.h b/src/type1z/t1afm.h
index 567ed63..61e18b8 100644
--- a/src/type1z/t1afm.h
+++ b/src/type1z/t1afm.h
@@ -8,7 +8,7 @@
 #ifndef T1AFM_H
 #define T1AFM_H
 
-#include <ftobjs.h>
+#include <freetype/internal/ftobjs.h>
 
 /* In this version, we only read the kerning table from the */
 /* AFM file. We may add support for ligatures a bit later.. */
diff --git a/src/type1z/t1driver.c b/src/type1z/t1driver.c
index d25b957..3cef9b5 100644
--- a/src/type1z/t1driver.c
+++ b/src/type1z/t1driver.c
@@ -19,9 +19,9 @@
 #include <t1gload.h>
 #include <t1afm.h>
 
-#include <ftdebug.h>
-#include <ftstream.h>
-#include <psnames.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/internal/psnames.h>
 
 #undef  FT_COMPONENT
 #define FT_COMPONENT  trace_t1driver
diff --git a/src/type1z/t1errors.h b/src/type1z/t1errors.h
index f268d87..93731c1 100644
--- a/src/type1z/t1errors.h
+++ b/src/type1z/t1errors.h
@@ -18,7 +18,7 @@
 #ifndef T1ERRORS_H
 #define T1ERRORS_H
 
-#include <fterrors.h>
+#include <freetype/fterrors.h>
 
   /************************ error codes declaration **************/
 
diff --git a/src/type1z/t1gload.c b/src/type1z/t1gload.c
index 200ed35..b75098e 100644
--- a/src/type1z/t1gload.c
+++ b/src/type1z/t1gload.c
@@ -16,8 +16,8 @@
  ******************************************************************/
 
 #include <t1gload.h>
-#include <ftdebug.h>
-#include <ftstream.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftstream.h>
 
 #undef  FT_COMPONENT
 #define FT_COMPONENT  trace_t1gload
diff --git a/src/type1z/t1load.c b/src/type1z/t1load.c
index 3e4ef92..2566419 100644
--- a/src/type1z/t1load.c
+++ b/src/type1z/t1load.c
@@ -59,10 +59,10 @@
  *
  ******************************************************************/
 
-#include <ftdebug.h>
-#include <ftconfig.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/config/ftconfig.h>
 
-#include <t1types.h>
+#include <freetype/internal/t1types.h>
 #include <t1errors.h>
 #include <t1load.h>
 #include <stdio.h>
diff --git a/src/type1z/t1load.h b/src/type1z/t1load.h
index 6a1a45c..093096c 100644
--- a/src/type1z/t1load.h
+++ b/src/type1z/t1load.h
@@ -18,7 +18,7 @@
 #ifndef T1LOAD_H
 #define T1LOAD_H
 
-#include <ftstream.h>
+#include <freetype/internal/ftstream.h>
 #include <t1parse.h>
 
 #ifdef __cplusplus
diff --git a/src/type1z/t1objs.c b/src/type1z/t1objs.c
index c034c16..43d876b 100644
--- a/src/type1z/t1objs.c
+++ b/src/type1z/t1objs.c
@@ -15,12 +15,12 @@
  *
  ******************************************************************/
 
-#include <ftdebug.h>
-#include <ftstream.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftstream.h>
 
 #include <t1gload.h>
 #include <t1load.h>
-#include <psnames.h>
+#include <freetype/internal/psnames.h>
 #include <t1afm.h>
 
 /* Required by tracing mode */
diff --git a/src/type1z/t1objs.h b/src/type1z/t1objs.h
index 8a16863..5b41f3a 100644
--- a/src/type1z/t1objs.h
+++ b/src/type1z/t1objs.h
@@ -18,10 +18,10 @@
 #ifndef T1OBJS_H
 #define T1OBJS_H
 
-#include <ftobjs.h>
-#include <ftconfig.h>
+#include <freetype/internal/ftobjs.h>
+#include <freetype/config/ftconfig.h>
 #include <t1errors.h>
-#include <t1types.h>
+#include <freetype/internal/t1types.h>
 
 #ifdef __cplusplus
   extern "C" {
diff --git a/src/type1z/t1parse.c b/src/type1z/t1parse.c
index a1f4be9..3cb47a9 100644
--- a/src/type1z/t1parse.c
+++ b/src/type1z/t1parse.c
@@ -28,10 +28,10 @@
  *
  ******************************************************************/
  
-#include <ftdebug.h>
-#include <ftcalc.h>
-#include <ftobjs.h>
-#include <ftstream.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftcalc.h>
+#include <freetype/internal/ftobjs.h>
+#include <freetype/internal/ftstream.h>
 #include <t1errors.h>
 #include <t1parse.h>
 
diff --git a/src/type1z/t1parse.h b/src/type1z/t1parse.h
index 4487193..6866918 100644
--- a/src/type1z/t1parse.h
+++ b/src/type1z/t1parse.h
@@ -31,7 +31,7 @@
 #ifndef T1PARSE_H
 #define T1PARSE_H
 
-#include <t1types.h>
+#include <freetype/internal/t1types.h>
 
 #ifdef __cplusplus
   extern "C" {