This commit was manufactured by cvs2svn to create branch 'captive'.
[reactos.git] / subsys / win32k / freetype / src / base / ftinit.c
1 /***************************************************************************/
2 /*                                                                         */
3 /*  ftinit.c                                                               */
4 /*                                                                         */
5 /*    FreeType initialization layer (body).                                */
6 /*                                                                         */
7 /*  Copyright 1996-2000 by                                                 */
8 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
9 /*                                                                         */
10 /*  This file is part of the FreeType project, and may only be used,       */
11 /*  modified, and distributed under the terms of the FreeType project      */
12 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
13 /*  this file you indicate that you have read the license and              */
14 /*  understand and accept it fully.                                        */
15 /*                                                                         */
16 /***************************************************************************/
17
18   /*************************************************************************/
19   /*                                                                       */
20   /*  The purpose of this file is to implement the following two           */
21   /*  functions:                                                           */
22   /*                                                                       */
23   /*  FT_Add_Default_Modules():                                            */
24   /*     This function is used to add the set of default modules to a      */
25   /*     fresh new library object.  The set is taken from the header file  */
26   /*     `freetype/config/ftmodule.h'.  See the document `FreeType 2.0     */
27   /*     Build System' for more information.                               */
28   /*                                                                       */
29   /*  FT_Init_FreeType():                                                  */
30   /*     This function creates a system object for the current platform,   */
31   /*     builds a library out of it, then calls FT_Default_Drivers().      */
32   /*                                                                       */
33   /*  Note that even if FT_Init_FreeType() uses the implementation of the  */
34   /*  system object defined at build time, client applications are still   */
35   /*  able to provide their own `ftsystem.c'.                              */
36   /*                                                                       */
37   /*************************************************************************/
38
39
40 #include <freetype/config/ftconfig.h>
41 #include <freetype/internal/ftobjs.h>
42
43 #include <freetype/internal/ftdebug.h>
44 #include <freetype/ftmodule.h>
45
46
47   /*************************************************************************/
48   /*                                                                       */
49   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
50   /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
51   /* messages during execution.                                            */
52   /*                                                                       */
53 #undef  FT_COMPONENT
54 #define FT_COMPONENT  trace_init
55
56 #undef  FT_USE_MODULE
57 #define FT_USE_MODULE( x )  extern const FT_Module_Class*  x;
58
59 #ifdef macintosh
60     FT_USE_MODULE(fond_driver_class)
61 #endif
62 #include <freetype/config/ftmodule.h>
63
64 #undef  FT_USE_MODULE
65 #define FT_USE_MODULE( x )  (const FT_Module_Class*)&x,
66
67 static
68 const FT_Module_Class*  ft_default_modules[] =
69   {
70 #ifdef macintosh
71     FT_USE_MODULE(fond_driver_class)
72 #endif
73 #include <freetype/config/ftmodule.h>
74     0
75   };
76
77
78   /*************************************************************************/
79   /*                                                                       */
80   /* <Function>                                                            */
81   /*    FT_Add_Default_Modules                                             */
82   /*                                                                       */
83   /* <Description>                                                         */
84   /*    Adds the set of default drivers to a given library object.         */
85   /*    This is only useful when you create a library object with          */
86   /*    FT_New_Library() (usually to plug a custom memory manager).        */
87   /*                                                                       */
88   /* <InOut>                                                               */
89   /*    library :: A handle to a new library object.                       */
90   /*                                                                       */
91   FT_EXPORT_FUNC( void )  FT_Add_Default_Modules( FT_Library  library )
92   {
93     FT_Error                 error;
94     const FT_Module_Class**  cur;
95
96
97     /* test for valid `library' delayed to FT_Add_Module() */
98
99     cur = ft_default_modules;
100     while ( *cur )
101     {
102       error = FT_Add_Module( library, *cur );
103       /* notify errors, but don't stop */
104       if ( error )
105       {
106         FT_ERROR(( "FT_Add_Default_Module: Cannot install `%s', error = %x\n",
107                    (*cur)->module_name, error ));
108       }
109       cur++;
110     }
111   }
112
113
114   /*************************************************************************/
115   /*                                                                       */
116   /* <Function>                                                            */
117   /*    FT_Init_FreeType                                                   */
118   /*                                                                       */
119   /* <Description>                                                         */
120   /*    Initializes a new FreeType library object.  The set of drivers     */
121   /*    that are registered by this function is determined at build time.  */
122   /*                                                                       */
123   /* <Output>                                                              */
124   /*    library :: A handle to a new library object.                       */
125   /*                                                                       */
126   /* <Return>                                                              */
127   /*    FreeType error code.  0 means success.                             */
128   /*                                                                       */
129   FT_EXPORT_FUNC( FT_Error )  FT_Init_FreeType( FT_Library*  library )
130   {
131     FT_Error   error;
132     FT_Memory  memory;
133
134
135     /* First of all, allocate a new system object -- this function is part */
136     /* of the system-specific component, i.e. `ftsystem.c'.                */
137
138     memory = FT_New_Memory();
139     if ( !memory )
140     {
141       FT_ERROR(( "FT_Init_FreeType: cannot find memory manager\n" ));
142       return FT_Err_Unimplemented_Feature;
143     }
144
145     /* build a library out of it, then fill it with the set of */
146     /* default drivers.                                        */
147
148     error = FT_New_Library( memory, library );
149     if ( !error )
150       FT_Add_Default_Modules( *library );
151
152     return error;
153   }
154
155
156 /* END */