Commit 3abf617b5e83a5cbe588169844fe931e7b91e50f

Chris Morgan 2011-07-20T06:48:08

Add FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT. Useful for embedded systems which don't need file stream support. * src/base/ftsystem.c, src/base/ftobjs.c (FT_Stream_New): Implement it.

diff --git a/ChangeLog b/ChangeLog
index 851b378..23f1194 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-07-20  Chris Morgan  <cmorgan@cybexintl.com>
+
+	Add FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT.
+
+	Useful for embedded systems which don't need file stream support.
+
+	* src/base/ftsystem.c, src/base/ftobjs.c (FT_Stream_New): Implement
+	it.
+
 2011-07-20  Elton Chung  <elton328@gmail.com>
 
 	* src/base/ftpatent.c (FT_Face_SetUnpatentedHinting): Fix typo.
diff --git a/devel/ftoption.h b/devel/ftoption.h
index a84f650..4da0221 100644
--- a/devel/ftoption.h
+++ b/devel/ftoption.h
@@ -205,6 +205,17 @@ FT_BEGIN_HEADER
 
   /*************************************************************************/
   /*                                                                       */
+  /* Define to disable the use of file stream functions and types, FILE,   */
+  /* fopen() etc.  Enables the use of smaller system libraries on embedded */
+  /* systems that have multiple system libraries, some with or without     */
+  /* file stream support, in the cases where file stream support is not    */
+  /* necessary such as memory loading of font files.                       */
+  /*                                                                       */
+/* #define FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */
+
+
+  /*************************************************************************/
+  /*                                                                       */
   /* DLL export compilation                                                */
   /*                                                                       */
   /*   When compiling FreeType as a DLL, some systems/compilers need a     */
diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
index 17c1d1d..041e24a 100644
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -205,6 +205,17 @@ FT_BEGIN_HEADER
 
   /*************************************************************************/
   /*                                                                       */
+  /* Define to disable the use of file stream functions and types, FILE,   */
+  /* fopen() etc.  Enables the use of smaller system libraries on embedded */
+  /* systems that have multiple system libraries, some with or without     */
+  /* file stream support, in the cases where file stream support is not    */
+  /* necessary such as memory loading of font files.                       */
+  /*                                                                       */
+/* #define FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */
+
+
+  /*************************************************************************/
+  /*                                                                       */
   /* DLL export compilation                                                */
   /*                                                                       */
   /*   When compiling FreeType as a DLL, some systems/compilers need a     */
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index c627c0b..5069afb 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -155,6 +155,9 @@
                             (const FT_Byte*)args->memory_base,
                             args->memory_size );
     }
+
+#ifndef FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT
+
     else if ( args->flags & FT_OPEN_PATHNAME )
     {
       /* create a normal system stream */
@@ -170,6 +173,9 @@
       FT_FREE( stream );
       stream = args->stream;
     }
+
+#endif
+
     else
       error = FT_Err_Invalid_Argument;
 
diff --git a/src/base/ftsystem.c b/src/base/ftsystem.c
index 66c5d76..7e203be 100644
--- a/src/base/ftsystem.c
+++ b/src/base/ftsystem.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    ANSI-specific FreeType low-level system interface (body).            */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2006, 2008, 2009, 2010 by                   */
+/*  Copyright 1996-2002, 2006, 2008-2011 by                                */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -137,6 +137,7 @@
   /*                                                                       */
   /*************************************************************************/
 
+#ifndef FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT
 
   /*************************************************************************/
   /*                                                                       */
@@ -267,6 +268,7 @@
     return FT_Err_Ok;
   }
 
+#endif /* !FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */
 
 #ifdef FT_DEBUG_MEMORY