* include/freetype/internal/psaux.h (PS_Table): Use FT_Offset for
`cursor' and `capacity'.
* src/psaux/psobjc.c (reallocate_t1_table): Use FT_Long for second
parameter.
(PS_Table_Add): Use FT_Offset for `new_size'.


* src/base/ftsynth.c: Include ftcalc.h unconditionally.
diff --git a/ChangeLog b/ChangeLog
index 769445c..8043121 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2001-07-17  Werner Lemberg  <wl@gnu.org>
+
+	* include/freetype/internal/psaux.h (PS_Table): Use FT_Offset for
+	`cursor' and `capacity'.
+	* src/psaux/psobjc.c (reallocate_t1_table): Use FT_Long for second
+	parameter.
+	(PS_Table_Add): Use FT_Offset for `new_size'.
+
+2001-07-13  Werner Lemberg  <wl@gnu.org>
+
+	* src/base/ftsynth.c: Include ftcalc.h unconditionally.
+
 2001-07-07  David Turner  <david@freetype.org>
 
 	* src/truetype/ttgload.c, src/truetype/ttinterp.c, src/pcf/pcfread:
diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h
index cfc0888..1911829 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -115,8 +115,8 @@
   struct  PS_Table_
   {
     FT_Byte*        block;          /* current memory block           */
-    FT_Int          cursor;         /* current cursor in memory block */
-    FT_Int          capacity;       /* current size of memory block   */
+    FT_Offset       cursor;         /* current cursor in memory block */
+    FT_Offset       capacity;       /* current size of memory block   */
     FT_Long         init;
 
     FT_Int          max_elems;
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index ac9057d..e38c104 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -101,7 +101,7 @@
 
   static FT_Error
   reallocate_t1_table( PS_Table*  table,
-                       FT_Int     new_size )
+                       FT_Long    new_size )
   {
     FT_Memory  memory   = table->memory;
     FT_Byte*   old_base = table->block;
@@ -163,8 +163,8 @@
     /* grow the base block if needed */
     if ( table->cursor + length > table->capacity )
     {
-      FT_Error  error;
-      FT_Int    new_size = table->capacity;
+      FT_Error   error;
+      FT_Offset  new_size = table->capacity;
 
 
       while ( new_size < table->cursor + length )
diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c
index ae72f37..ab55342 100644
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -566,9 +566,15 @@
 #undef  FT_STRUCTURE
 #define FT_STRUCTURE  TT_MaxProfile
 
-      FT_FRAME_START( 32 ),
-        FT_FRAME_ULONG ( version ),
+      FT_FRAME_START( 6 ),
+        FT_FRAME_LONG  ( version ),
         FT_FRAME_USHORT( numGlyphs ),
+      FT_FRAME_END
+    };
+
+    const FT_Frame_Field  maxp_fields_extra[] =
+    {
+      FT_FRAME_START( 26 ),
         FT_FRAME_USHORT( maxPoints ),
         FT_FRAME_USHORT( maxContours ),
         FT_FRAME_USHORT( maxCompositePoints ),
@@ -582,7 +588,8 @@
         FT_FRAME_USHORT( maxSizeOfInstructions ),
         FT_FRAME_USHORT( maxComponentElements ),
         FT_FRAME_USHORT( maxComponentDepth ),
-      FT_FRAME_END };
+      FT_FRAME_END
+    };
 
 
     FT_TRACE2(( "Load_TT_MaxProfile: %08p\n", face ));
@@ -594,37 +601,57 @@
     if ( READ_Fields( maxp_fields, maxProfile ) )
       goto Exit;
 
-    /* XXX: an adjustment that is necessary to load certain */
-    /*      broken fonts like `Keystrokes MT' :-(           */
-    /*                                                      */
-    /*   We allocate 64 function entries by default when    */
-    /*   the maxFunctionDefs field is null.                 */
+    maxProfile->maxPoints             = 0;
+    maxProfile->maxContours           = 0;
+    maxProfile->maxCompositePoints    = 0;
+    maxProfile->maxCompositeContours  = 0;
+    maxProfile->maxZones              = 0;
+    maxProfile->maxTwilightPoints     = 0;
+    maxProfile->maxStorage            = 0;
+    maxProfile->maxFunctionDefs       = 0;
+    maxProfile->maxInstructionDefs    = 0;
+    maxProfile->maxStackElements      = 0;
+    maxProfile->maxSizeOfInstructions = 0;
+    maxProfile->maxComponentElements  = 0;
+    maxProfile->maxComponentDepth     = 0;
 
-    if ( maxProfile->maxFunctionDefs == 0 )
-      maxProfile->maxFunctionDefs = 64;
+    if ( maxProfile->version >= 0x10000L )
+    {
+      if ( READ_Fields( maxp_fields_extra, maxProfile ) )
+        goto Exit;
 
-    face->root.num_glyphs = maxProfile->numGlyphs;
+      /* XXX: an adjustment that is necessary to load certain */
+      /*      broken fonts like `Keystrokes MT' :-(           */
+      /*                                                      */
+      /*   We allocate 64 function entries by default when    */
+      /*   the maxFunctionDefs field is null.                 */
 
-    face->root.internal->max_points =
-      (FT_UShort)MAX( maxProfile->maxCompositePoints,
-                      maxProfile->maxPoints );
+      if ( maxProfile->maxFunctionDefs == 0 )
+        maxProfile->maxFunctionDefs = 64;
 
-    face->root.internal->max_contours =
-      (FT_Short)MAX( maxProfile->maxCompositeContours,
-                     maxProfile->maxContours );
+      face->root.num_glyphs = maxProfile->numGlyphs;
 
-    face->max_components = (FT_ULong)maxProfile->maxComponentElements +
-                           maxProfile->maxComponentDepth;
+      face->root.internal->max_points =
+        (FT_UShort)MAX( maxProfile->maxCompositePoints,
+                        maxProfile->maxPoints );
 
-    /* XXX: some fonts have maxComponents set to 0; we will */
-    /*      then use 16 of them by default.                 */
-    if ( face->max_components == 0 )
-      face->max_components = 16;
+      face->root.internal->max_contours =
+        (FT_Short)MAX( maxProfile->maxCompositeContours,
+                       maxProfile->maxContours );
 
-    /* We also increase maxPoints and maxContours in order to support */
-    /* some broken fonts.                                             */
-    face->root.internal->max_points   += 8;
-    face->root.internal->max_contours += 4;
+      face->max_components = (FT_ULong)maxProfile->maxComponentElements +
+                             maxProfile->maxComponentDepth;
+
+      /* XXX: some fonts have maxComponents set to 0; we will */
+      /*      then use 16 of them by default.                 */
+      if ( face->max_components == 0 )
+        face->max_components = 16;
+
+      /* We also increase maxPoints and maxContours in order to support */
+      /* some broken fonts.                                             */
+      face->root.internal->max_points   += 8;
+      face->root.internal->max_contours += 4;
+    }
 
     FT_TRACE2(( "MAXP loaded.\n" ));
 
@@ -1211,11 +1238,11 @@
     FT_Error  error;
     TT_OS2*   os2;
 
+    const FT_Frame_Field  os2_fields[] =
+    {
 #undef  FT_STRUCTURE
 #define FT_STRUCTURE  TT_OS2
 
-    const FT_Frame_Field  os2_fields[] =
-    {
       FT_FRAME_START( 78 ),
         FT_FRAME_USHORT( version ),
         FT_FRAME_SHORT ( xAvgCharWidth ),
@@ -1304,6 +1331,11 @@
 
     os2->ulCodePageRange1 = 0;
     os2->ulCodePageRange2 = 0;
+    os2->sxHeight         = 0;
+    os2->sCapHeight       = 0;
+    os2->usDefaultChar    = 0;
+    os2->usBreakChar      = 0;
+    os2->usMaxContext     = 0;
 
     if ( os2->version >= 0x0001 )
     {