ReactOS 0.4.16-dev-981-g80eb313
ftinit.c
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * ftinit.c
4 *
5 * FreeType initialization layer (body).
6 *
7 * Copyright (C) 1996-2019 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 <ft2build.h>
41#include FT_CONFIG_CONFIG_H
42#include FT_INTERNAL_OBJECTS_H
43#include FT_INTERNAL_DEBUG_H
44#include FT_MODULE_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 init
55
56
57#undef FT_USE_MODULE
58#ifdef __cplusplus
59#define FT_USE_MODULE( type, x ) extern "C" const type x;
60#else
61#define FT_USE_MODULE( type, x ) extern const type x;
62#endif
63
64#include FT_CONFIG_MODULES_H
65
66#undef FT_USE_MODULE
67#define FT_USE_MODULE( type, x ) (const FT_Module_Class*)&(x),
68
69 static
71 {
72#include FT_CONFIG_MODULES_H
73 0
74 };
75
76
77 /* documentation is in ftmodapi.h */
78
79 FT_EXPORT_DEF( void )
81 {
83 const FT_Module_Class* const* cur;
84
85
86 /* GCC 4.6 warns the type difference:
87 * FT_Module_Class** != const FT_Module_Class* const*
88 */
89 cur = (const FT_Module_Class* const*)ft_default_modules;
90
91 /* test for valid `library' delayed to FT_Add_Module() */
92 while ( *cur )
93 {
95 /* notify errors, but don't stop */
96 if ( error )
97 FT_TRACE0(( "FT_Add_Default_Module:"
98 " Cannot install `%s', error = 0x%x\n",
99 (*cur)->module_name, error ));
100 cur++;
101 }
102 }
103
104
105#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
106
107#define MAX_LENGTH 128
108
109 /* documentation is in ftmodapi.h */
110
111 FT_EXPORT_DEF( void )
113 {
114 const char* env;
115 const char* p;
116 const char* q;
117
118 char module_name[MAX_LENGTH + 1];
119 char property_name[MAX_LENGTH + 1];
120 char property_value[MAX_LENGTH + 1];
121
122 int i;
123
124
125 env = ft_getenv( "FREETYPE_PROPERTIES" );
126 if ( !env )
127 return;
128
129 for ( p = env; *p; p++ )
130 {
131 /* skip leading whitespace and separators */
132 if ( *p == ' ' || *p == '\t' )
133 continue;
134
135 /* read module name, followed by `:' */
136 q = p;
137 for ( i = 0; i < MAX_LENGTH; i++ )
138 {
139 if ( !*p || *p == ':' )
140 break;
141 module_name[i] = *p++;
142 }
143 module_name[i] = '\0';
144
145 if ( !*p || *p != ':' || p == q )
146 break;
147
148 /* read property name, followed by `=' */
149 q = ++p;
150 for ( i = 0; i < MAX_LENGTH; i++ )
151 {
152 if ( !*p || *p == '=' )
153 break;
154 property_name[i] = *p++;
155 }
156 property_name[i] = '\0';
157
158 if ( !*p || *p != '=' || p == q )
159 break;
160
161 /* read property value, followed by whitespace (if any) */
162 q = ++p;
163 for ( i = 0; i < MAX_LENGTH; i++ )
164 {
165 if ( !*p || *p == ' ' || *p == '\t' )
166 break;
167 property_value[i] = *p++;
168 }
169 property_value[i] = '\0';
170
171 if ( !( *p == '\0' || *p == ' ' || *p == '\t' ) || p == q )
172 break;
173
174 /* we completely ignore errors */
175 ft_property_string_set( library,
177 property_name,
178 property_value );
179 }
180 }
181
182#else
183
184 FT_EXPORT_DEF( void )
186 {
188 }
189
190#endif
191
192
193 /* documentation is in freetype.h */
194
197 {
200
201
202 /* check of `alibrary' delayed to `FT_New_Library' */
203
204 /* First of all, allocate a new system object -- this function is part */
205 /* of the system-specific component, i.e. `ftsystem.c'. */
206
208 if ( !memory )
209 {
210 FT_ERROR(( "FT_Init_FreeType: cannot find memory manager\n" ));
211 return FT_THROW( Unimplemented_Feature );
212 }
213
214 /* build a library out of it, then fill it with the set of */
215 /* default drivers. */
216
217 error = FT_New_Library( memory, alibrary );
218 if ( error )
220 else
221 FT_Add_Default_Modules( *alibrary );
222
223 FT_Set_Default_Properties( *alibrary );
224
225 return error;
226 }
227
228
229 /* documentation is in freetype.h */
230
233 {
235
236
237 if ( !library )
238 return FT_THROW( Invalid_Library_Handle );
239
241
242 /* Discard the library object */
244
245 /* discard memory manager */
247
248 return FT_Err_Ok;
249 }
250
251
252/* END */
FT_Library library
Definition: cffdrivr.c:661
static LPCWSTR LPCWSTR module_name
Definition: db.cpp:170
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:170
return FT_Err_Ok
Definition: ftbbox.c:527
#define FT_UNUSED(arg)
Definition: ftconfig.h:100
#define FT_EXPORT_DEF(x)
Definition: ftconfig.h:494
#define FT_TRACE0(varformat)
Definition: ftdebug.h:185
#define FT_ERROR(varformat)
Definition: ftdebug.h:209
#define FT_THROW(e)
Definition: ftdebug.h:241
FT_Set_Default_Properties(FT_Library library)
Definition: ftinit.c:185
static const FT_Module_Class *const ft_default_modules[]
Definition: ftinit.c:70
FT_Add_Default_Modules(FT_Library library)
Definition: ftinit.c:80
FT_Done_FreeType(FT_Library library)
Definition: ftinit.c:232
FT_Init_FreeType(FT_Library *alibrary)
Definition: ftinit.c:196
FT_Add_Module(FT_Library library, const FT_Module_Class *clazz)
Definition: ftobjs.c:4851
FT_Done_Library(FT_Library library)
Definition: ftobjs.c:5333
FT_New_Library(FT_Memory memory, FT_Library *alibrary)
Definition: ftobjs.c:5265
FT_New_Memory(void)
Definition: ftsystem.c:300
FT_Done_Memory(FT_Memory memory)
Definition: ftsystem.c:324
#define ft_getenv
Definition: ftstdlib.h:146
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:65
int FT_Error
Definition: fttypes.h:299
FxCollectionEntry * cur
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLfloat GLfloat p
Definition: glext.h:8902
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define error(str)
Definition: mkdosfs.c:1605
static char memory[1024 *256]
Definition: process.c:116
FT_Memory memory
Definition: ftobjs.h:897