sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
ftsystem.h
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * ftsystem.h
4 *
5 * FreeType low-level system interface definition (specification).
6 *
7 * Copyright (C) 1996-2025 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
23#ifndef FTSYSTEM_H_
24#define FTSYSTEM_H_
25
26
27
28
29FT_BEGIN_HEADER
30
31
32 /**************************************************************************
33 *
34 * @section:
35 * system_interface
36 *
37 * @title:
38 * System Interface
39 *
40 * @abstract:
41 * How FreeType manages memory and i/o.
42 *
43 * @description:
44 * This section contains various definitions related to memory management
45 * and i/o access. You need to understand this information if you want to
46 * use a custom memory manager or you own i/o streams.
47 *
48 */
49
50
51 /**************************************************************************
52 *
53 * M E M O R Y M A N A G E M E N T
54 *
55 */
56
57
58 /**************************************************************************
59 *
60 * @type:
61 * FT_Memory
62 *
63 * @description:
64 * A handle to a given memory manager object, defined with an
65 * @FT_MemoryRec structure.
66 *
67 */
68 typedef struct FT_MemoryRec_* FT_Memory;
69
70
71 /**************************************************************************
72 *
73 * @functype:
74 * FT_Alloc_Func
75 *
76 * @description:
77 * A function used to allocate `size` bytes from `memory`.
78 *
79 * @input:
80 * memory ::
81 * A handle to the source memory manager.
82 *
83 * size ::
84 * The size in bytes to allocate.
85 *
86 * @return:
87 * Address of new memory block. 0~in case of failure.
88 *
89 */
90 typedef void*
91 (*FT_Alloc_Func)( FT_Memory memory,
92 long size );
93
94
95 /**************************************************************************
96 *
97 * @functype:
98 * FT_Free_Func
99 *
100 * @description:
101 * A function used to release a given block of memory.
102 *
103 * @input:
104 * memory ::
105 * A handle to the source memory manager.
106 *
107 * block ::
108 * The address of the target memory block.
109 *
110 */
111 typedef void
112 (*FT_Free_Func)( FT_Memory memory,
113 void* block );
114
115
116 /**************************************************************************
117 *
118 * @functype:
119 * FT_Realloc_Func
120 *
121 * @description:
122 * A function used to re-allocate a given block of memory.
123 *
124 * @input:
125 * memory ::
126 * A handle to the source memory manager.
127 *
128 * cur_size ::
129 * The block's current size in bytes.
130 *
131 * new_size ::
132 * The block's requested new size.
133 *
134 * block ::
135 * The block's current address.
136 *
137 * @return:
138 * New block address. 0~in case of memory shortage.
139 *
140 * @note:
141 * In case of error, the old block must still be available.
142 *
143 */
144 typedef void*
145 (*FT_Realloc_Func)( FT_Memory memory,
146 long cur_size,
147 long new_size,
148 void* block );
149
150
151 /**************************************************************************
152 *
153 * @struct:
154 * FT_MemoryRec
155 *
156 * @description:
157 * A structure used to describe a given memory manager to FreeType~2.
158 *
159 * @fields:
160 * user ::
161 * A generic typeless pointer for user data.
162 *
163 * alloc ::
164 * A pointer type to an allocation function.
165 *
166 * free ::
167 * A pointer type to an memory freeing function.
168 *
169 * realloc ::
170 * A pointer type to a reallocation function.
171 *
172 */
174 {
175 void* user;
176 FT_Alloc_Func alloc;
177 FT_Free_Func free;
178 FT_Realloc_Func realloc;
179 };
180
181
182 /**************************************************************************
183 *
184 * I / O M A N A G E M E N T
185 *
186 */
187
188
189 /**************************************************************************
190 *
191 * @type:
192 * FT_Stream
193 *
194 * @description:
195 * A handle to an input stream.
196 *
197 * @also:
198 * See @FT_StreamRec for the publicly accessible fields of a given stream
199 * object.
200 *
201 */
202 typedef struct FT_StreamRec_* FT_Stream;
203
204
205 /**************************************************************************
206 *
207 * @struct:
208 * FT_StreamDesc
209 *
210 * @description:
211 * A union type used to store either a long or a pointer. This is used
212 * to store a file descriptor or a `FILE*` in an input stream.
213 *
214 */
215 typedef union FT_StreamDesc_
216 {
217 long value;
218 void* pointer;
219
220 } FT_StreamDesc;
221
222
223 /**************************************************************************
224 *
225 * @functype:
226 * FT_Stream_IoFunc
227 *
228 * @description:
229 * A function used to seek and read data from a given input stream.
230 *
231 * @input:
232 * stream ::
233 * A handle to the source stream.
234 *
235 * offset ::
236 * The offset from the start of the stream to seek to.
237 *
238 * buffer ::
239 * The address of the read buffer.
240 *
241 * count ::
242 * The number of bytes to read from the stream.
243 *
244 * @return:
245 * If count >~0, return the number of bytes effectively read by the
246 * stream (after seeking to `offset`). If count ==~0, return the status
247 * of the seek operation (non-zero indicates an error).
248 *
249 */
250 typedef unsigned long
251 (*FT_Stream_IoFunc)( FT_Stream stream,
252 unsigned long offset,
253 unsigned char* buffer,
254 unsigned long count );
255
256
257 /**************************************************************************
258 *
259 * @functype:
260 * FT_Stream_CloseFunc
261 *
262 * @description:
263 * A function used to close a given input stream.
264 *
265 * @input:
266 * stream ::
267 * A handle to the target stream.
268 *
269 */
270 typedef void
271 (*FT_Stream_CloseFunc)( FT_Stream stream );
272
273
274 /**************************************************************************
275 *
276 * @struct:
277 * FT_StreamRec
278 *
279 * @description:
280 * A structure used to describe an input stream.
281 *
282 * @input:
283 * base ::
284 * For memory-based streams, this is the address of the first stream
285 * byte in memory. This field should always be set to `NULL` for
286 * disk-based streams.
287 *
288 * size ::
289 * The stream size in bytes.
290 *
291 * In case of compressed streams where the size is unknown before
292 * actually doing the decompression, the value is set to 0x7FFFFFFF.
293 * (Note that this size value can occur for normal streams also; it is
294 * thus just a hint.)
295 *
296 * pos ::
297 * The current position within the stream.
298 *
299 * descriptor ::
300 * This field is a union that can hold an integer or a pointer. It is
301 * used by stream implementations to store file descriptors or `FILE*`
302 * pointers.
303 *
304 * pathname ::
305 * This field is completely ignored by FreeType. However, it is often
306 * useful during debugging to use it to store the stream's filename
307 * (where available).
308 *
309 * read ::
310 * The stream's input function.
311 *
312 * close ::
313 * The stream's close function.
314 *
315 * memory ::
316 * The memory manager to use to preload frames. This is set internally
317 * by FreeType and shouldn't be touched by stream implementations.
318 *
319 * cursor ::
320 * This field is set and used internally by FreeType when parsing
321 * frames. In particular, the `FT_GET_XXX` macros use this instead of
322 * the `pos` field.
323 *
324 * limit ::
325 * This field is set and used internally by FreeType when parsing
326 * frames.
327 *
328 */
329 typedef struct FT_StreamRec_
330 {
331 unsigned char* base;
332 unsigned long size;
333 unsigned long pos;
334
335 FT_StreamDesc descriptor;
336 FT_StreamDesc pathname;
337 FT_Stream_IoFunc read;
338 FT_Stream_CloseFunc close;
339
340 FT_Memory memory;
341 unsigned char* cursor;
342 unsigned char* limit;
343
344 } FT_StreamRec;
345
346 /* */
347
348
349FT_END_HEADER
350
351#endif /* FTSYSTEM_H_ */
352
353
354/* END */