Commit 12d09050f59d0733e9b0caacc246823f9ee92d2a

David Turner 2003-01-15T22:48:27

* include/freetype/config/ftheader.h, include/freetype/internal/fnttypes.h, include/freetype/ftwinfnt.h, src/base/winfnt.c, src/winfonts/winfnt.c, src/base/Jamfile, src/base/rules.mk, src/base/descrip.mms: added a Windows .FNT specific API (mostly for Wine). Also fixed a nasty bug in the header loader which would cause invalid memory overwrites

diff --git a/ChangeLog b/ChangeLog
index 2011123..80e3e27 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,19 @@
+2003-01-15  Huw D M Davies <h.davies1@physics.ox.ac.uk>
+
+    * include/freetype/config/ftheader.h, include/freetype/internal/fnttypes.h,
+    include/freetype/ftwinfnt.h, src/base/winfnt.c, src/winfonts/winfnt.c,
+    src/base/Jamfile, src/base/rules.mk, src/base/descrip.mms:
+
+      added a Windows .FNT specific API (mostly for Wine). Also fixed a nasty
+      bug in the header loader which would cause invalid memory overwrites
+
 2003-01-14  Graham Asher  <graham.asher@btinternet.com>
-    * /include/freetype/ftglyph.h, /src/base/ftglyph.c
+
+    * include/freetype/ftglyph.h, src/base/ftglyph.c:
     Added 'const' to the type of the first argument to FT_Matrix_Multiply,
     which isn't changed - this adds documentation and convenience.
 
+
 2003-01-13  Graham Asher  <graham.asher@btinternet.com>
 
     * src/sfnt/ttload.c (tt_face_load_metrics)
@@ -12,6 +23,7 @@
     function, implying that metrics will be supplied from outside.
     This happens for certain Type 42 fonts passed from GhostScript.
 
+
 2003-01-11  David Chester  <davidchester@qmx.net>
 
         * include/freetype/config/ftoption.h, src/autohint/ahglobal.h,
diff --git a/include/freetype/config/ftheader.h b/include/freetype/config/ftheader.h
index 3ce1773..e5ae7e4 100644
--- a/include/freetype/config/ftheader.h
+++ b/include/freetype/config/ftheader.h
@@ -376,6 +376,17 @@
   /*************************************************************************/
   /*                                                                       */
   /* @macro:                                                               */
+  /*    FT_WINFONTS_H                                                      */
+  /*                                                                       */
+  /* @description:                                                         */
+  /*    A macro used in #include statements to name the file containing    */
+  /*    the definitions of an API to support Windows .FNT files            */
+  /*                                                                       */
+#define FT_WINFONTS_H   <freetype/ftwinfnt.h>
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* @macro:                                                               */
   /*    FT_GLYPH_H                                                         */
   /*                                                                       */
   /* @description:                                                         */
diff --git a/include/freetype/internal/fnttypes.h b/include/freetype/internal/fnttypes.h
index 2edc567..a85d6ab 100644
--- a/include/freetype/internal/fnttypes.h
+++ b/include/freetype/internal/fnttypes.h
@@ -23,6 +23,7 @@
 
 #include <ft2build.h>
 #include FT_FREETYPE_H
+#include FT_WINFONTS_H
 
 
 FT_BEGIN_HEADER
@@ -71,57 +72,15 @@ FT_BEGIN_HEADER
 #define WINFNT_NE_MAGIC  0x454E
 
 
-  typedef struct  WinFNT_HeaderRec_
-  {
-    FT_UShort  version;
-    FT_ULong   file_size;
-    FT_Byte    copyright[60];
-    FT_UShort  file_type;
-    FT_UShort  nominal_point_size;
-    FT_UShort  vertical_resolution;
-    FT_UShort  horizontal_resolution;
-    FT_UShort  ascent;
-    FT_UShort  internal_leading;
-    FT_UShort  external_leading;
-    FT_Byte    italic;
-    FT_Byte    underline;
-    FT_Byte    strike_out;
-    FT_UShort  weight;
-    FT_Byte    charset;
-    FT_UShort  pixel_width;
-    FT_UShort  pixel_height;
-    FT_Byte    pitch_and_family;
-    FT_UShort  avg_width;
-    FT_UShort  max_width;
-    FT_Byte    first_char;
-    FT_Byte    last_char;
-    FT_Byte    default_char;
-    FT_Byte    break_char;
-    FT_UShort  bytes_per_row;
-    FT_ULong   device_offset;
-    FT_ULong   face_name_offset;
-    FT_ULong   bits_pointer;
-    FT_ULong   bits_offset;
-    FT_Byte    reserved;
-    FT_ULong   flags;
-    FT_UShort  A_space;
-    FT_UShort  B_space;
-    FT_UShort  C_space;
-    FT_UShort  color_table_offset;
-    FT_Byte    reserved2[16];
-
-  } WinFNT_HeaderRec, *WinFNT_Header;
-
-
   typedef struct  FNT_FontRec_
   {
-    FT_ULong          offset;
-    FT_Int            size_shift;
+    FT_ULong             offset;
+    FT_Int               size_shift;
 
-    WinFNT_HeaderRec  header;
+    FT_WinFNT_HeaderRec  header;
 
-    FT_Byte*          fnt_frame;
-    FT_ULong          fnt_size;
+    FT_Byte*             fnt_frame;
+    FT_ULong             fnt_size;
 
   } FNT_FontRec, *FNT_Font;
 
diff --git a/src/base/Jamfile b/src/base/Jamfile
index 55e5e6a..5ebcd7c 100644
--- a/src/base/Jamfile
+++ b/src/base/Jamfile
@@ -22,9 +22,10 @@ SubDir  FT2_TOP $(FT2_SRC_DIR) base ;
 
 # Add the optional/replaceable files.
 #
-Library  $(FT2_LIB) : ftsystem.c ftinit.c   ftglyph.c  ftmm.c     ftbdf.c
-                      ftbbox.c   ftdebug.c  ftxf86.c   fttype1.c  ftpfr.c
-                      ftstroker.c ;
+Library  $(FT2_LIB) : ftsystem.c   ftinit.c    ftglyph.c  ftmm.c     ftbdf.c
+                      ftbbox.c     ftdebug.c   ftxf86.c   fttype1.c  ftpfr.c
+                      ftstroker.c  ftwinfnt.c
+                      ;
 
 # Add Macintosh-specific file to the library when necessary.
 #
diff --git a/src/base/descrip.mms b/src/base/descrip.mms
index 895da06..02a806a 100644
--- a/src/base/descrip.mms
+++ b/src/base/descrip.mms
@@ -15,7 +15,7 @@
 
 CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.builds.vms],[--.include],[--.src.base])
 
-OBJS=ftbase.obj,ftinit.obj,ftglyph.obj,ftdebug.obj,ftbdf.obj,ftmm.obj,fttype1.obj,ftxf86.obj,ftpfr.obj, ftstroker.obj
+OBJS=ftbase.obj,ftinit.obj,ftglyph.obj,ftdebug.obj,ftbdf.obj,ftmm.obj,fttype1.obj,ftxf86.obj,ftpfr.obj,ftstroker.obj,ftwinfnt.obj
 
 all : $(OBJS)
         library [--.lib]freetype.olb $(OBJS)
diff --git a/src/base/rules.mk b/src/base/rules.mk
index d83b1e4..da345dd 100644
--- a/src/base/rules.mk
+++ b/src/base/rules.mk
@@ -56,6 +56,7 @@ BASE_EXT_SRC := $(BASE_)ftglyph.c   \
                 $(BASE_)ftxf86.c    \
                 $(BASE_)ftpfr.c     \
                 $(BASE_)ftstroker.c \
+                $(BASE_)ftwinfnt.c  \
                 $(BASE_)ftbbox.c
 
 # Default extensions objects
diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c
index 9d29b9b..7b2a0e4 100644
--- a/src/winfonts/winfnt.c
+++ b/src/winfonts/winfnt.c
@@ -17,6 +17,7 @@
 
 
 #include <ft2build.h>
+#include FT_WINFONTS_H
 #include FT_INTERNAL_DEBUG_H
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_OBJECTS_H
@@ -68,7 +69,7 @@
   const FT_Frame_Field  winfnt_header_fields[] =
   {
 #undef  FT_STRUCTURE
-#define FT_STRUCTURE  WinFNT_HeaderRec
+#define FT_STRUCTURE  FT_WinFNT_HeaderRec
 
     FT_FRAME_START( 146 ),
       FT_FRAME_USHORT_LE( version ),
@@ -106,7 +107,7 @@
       FT_FRAME_USHORT_LE( B_space ),
       FT_FRAME_USHORT_LE( C_space ),
       FT_FRAME_USHORT_LE( color_table_offset ),
-      FT_FRAME_BYTES    ( reserved2, 16 ),
+      FT_FRAME_BYTES    ( reserved1, 16 ),
     FT_FRAME_END
   };
 
@@ -127,8 +128,8 @@
   fnt_font_load( FNT_Font   font,
                  FT_Stream  stream )
   {
-    FT_Error       error;
-    WinFNT_Header  header = &font->header;
+    FT_Error          error;
+    FT_WinFNT_Header  header = &font->header;
 
 
     /* first of all, read the FNT header */