sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
ftdrv.h
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * ftdrv.h
4 *
5 * FreeType internal font driver interface (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 FTDRV_H_
24#define FTDRV_H_
25
26
27#include <freetype/ftmodapi.h>
28
29#include "compiler-macros.h"
30
31FT_BEGIN_HEADER
32
33
34 typedef FT_Error
35 (*FT_Face_InitFunc)( FT_Stream stream,
36 FT_Face face,
37 FT_Int typeface_index,
38 FT_Int num_params,
39 FT_Parameter* parameters );
40
41 typedef void
42 (*FT_Face_DoneFunc)( FT_Face face );
43
44
45 typedef FT_Error
46 (*FT_Size_InitFunc)( FT_Size size );
47
48 typedef void
49 (*FT_Size_DoneFunc)( FT_Size size );
50
51
52 typedef FT_Error
53 (*FT_Slot_InitFunc)( FT_GlyphSlot slot );
54
55 typedef void
56 (*FT_Slot_DoneFunc)( FT_GlyphSlot slot );
57
58
59 typedef FT_Error
60 (*FT_Size_RequestFunc)( FT_Size size,
61 FT_Size_Request req );
62
63 typedef FT_Error
64 (*FT_Size_SelectFunc)( FT_Size size,
65 FT_ULong size_index );
66
67 typedef FT_Error
68 (*FT_Slot_LoadFunc)( FT_GlyphSlot slot,
69 FT_Size size,
70 FT_UInt glyph_index,
71 FT_Int32 load_flags );
72
73
74 typedef FT_Error
75 (*FT_Face_GetKerningFunc)( FT_Face face,
76 FT_UInt left_glyph,
77 FT_UInt right_glyph,
78 FT_Vector* kerning );
79
80
81 typedef FT_Error
82 (*FT_Face_AttachFunc)( FT_Face face,
83 FT_Stream stream );
84
85
86 typedef FT_Error
87 (*FT_Face_GetAdvancesFunc)( FT_Face face,
88 FT_UInt first,
89 FT_UInt count,
90 FT_Int32 flags,
91 FT_Fixed* advances );
92
93
94 /**************************************************************************
95 *
96 * @struct:
97 * FT_Driver_ClassRec
98 *
99 * @description:
100 * The font driver class. This structure mostly contains pointers to
101 * driver methods.
102 *
103 * @fields:
104 * root ::
105 * The parent module.
106 *
107 * face_object_size ::
108 * The size of a face object in bytes.
109 *
110 * size_object_size ::
111 * The size of a size object in bytes.
112 *
113 * slot_object_size ::
114 * The size of a glyph object in bytes.
115 *
116 * init_face ::
117 * The format-specific face constructor.
118 *
119 * done_face ::
120 * The format-specific face destructor.
121 *
122 * init_size ::
123 * The format-specific size constructor.
124 *
125 * done_size ::
126 * The format-specific size destructor.
127 *
128 * init_slot ::
129 * The format-specific slot constructor.
130 *
131 * done_slot ::
132 * The format-specific slot destructor.
133 *
134 *
135 * load_glyph ::
136 * A function handle to load a glyph to a slot. This field is
137 * mandatory!
138 *
139 * get_kerning ::
140 * A function handle to return the unscaled kerning for a given pair of
141 * glyphs. Can be set to 0 if the format doesn't support kerning.
142 *
143 * attach_file ::
144 * This function handle is used to read additional data for a face from
145 * another file/stream. For example, this can be used to add data from
146 * AFM or PFM files on a Type 1 face, or a CIDMap on a CID-keyed face.
147 *
148 * get_advances ::
149 * A function handle used to return advance widths of 'count' glyphs
150 * (in font units), starting at 'first'. The 'vertical' flag must be
151 * set to get vertical advance heights. The 'advances' buffer is
152 * caller-allocated. The idea of this function is to be able to
153 * perform device-independent text layout without loading a single
154 * glyph image.
155 *
156 * request_size ::
157 * A handle to a function used to request the new character size. Can
158 * be set to 0 if the scaling done in the base layer suffices.
159 *
160 * select_size ::
161 * A handle to a function used to select a new fixed size. It is used
162 * only if @FT_FACE_FLAG_FIXED_SIZES is set. Can be set to 0 if the
163 * scaling done in the base layer suffices.
164 *
165 * @note:
166 * Most function pointers, with the exception of `load_glyph`, can be set
167 * to 0 to indicate a default behaviour.
168 */
169 typedef struct FT_Driver_ClassRec_
170 {
171 FT_Module_Class root;
172
173 FT_Long face_object_size;
174 FT_Long size_object_size;
175 FT_Long slot_object_size;
176
177 FT_Face_InitFunc init_face;
178 FT_Face_DoneFunc done_face;
179
180 FT_Size_InitFunc init_size;
181 FT_Size_DoneFunc done_size;
182
183 FT_Slot_InitFunc init_slot;
184 FT_Slot_DoneFunc done_slot;
185
186 FT_Slot_LoadFunc load_glyph;
187
188 FT_Face_GetKerningFunc get_kerning;
189 FT_Face_AttachFunc attach_file;
190 FT_Face_GetAdvancesFunc get_advances;
191
192 /* since version 2.2 */
193 FT_Size_RequestFunc request_size;
194 FT_Size_SelectFunc select_size;
195
196 } FT_Driver_ClassRec, *FT_Driver_Class;
197
198
199 /**************************************************************************
200 *
201 * @macro:
202 * FT_DECLARE_DRIVER
203 *
204 * @description:
205 * Used to create a forward declaration of an FT_Driver_ClassRec struct
206 * instance.
207 *
208 * @macro:
209 * FT_DEFINE_DRIVER
210 *
211 * @description:
212 * Used to initialize an instance of FT_Driver_ClassRec struct.
213 *
214 * `ftinit.c` (ft_create_default_module_classes) already contains a
215 * mechanism to call these functions for the default modules described in
216 * `ftmodule.h`.
217 *
218 * The struct will be allocated in the global scope (or the scope where
219 * the macro is used).
220 */
221#define FT_DECLARE_DRIVER( class_ ) \
222 FT_CALLBACK_TABLE \
223 const FT_Driver_ClassRec class_;
224
225#define FT_DEFINE_DRIVER( \
226 class_, \
227 flags_, \
228 size_, \
229 name_, \
230 version_, \
231 requires_, \
232 interface_, \
233 init_, \
234 done_, \
235 get_interface_, \
236 face_object_size_, \
237 size_object_size_, \
238 slot_object_size_, \
239 init_face_, \
240 done_face_, \
241 init_size_, \
242 done_size_, \
243 init_slot_, \
244 done_slot_, \
245 load_glyph_, \
246 get_kerning_, \
247 attach_file_, \
248 get_advances_, \
249 request_size_, \
250 select_size_ ) \
251 FT_CALLBACK_TABLE_DEF \
252 const FT_Driver_ClassRec class_ = \
253 { \
254 FT_DEFINE_ROOT_MODULE( flags_, \
255 size_, \
256 name_, \
257 version_, \
258 requires_, \
259 interface_, \
260 init_, \
261 done_, \
262 get_interface_ ) \
263 \
264 face_object_size_, \
265 size_object_size_, \
266 slot_object_size_, \
267 \
268 init_face_, \
269 done_face_, \
270 \
271 init_size_, \
272 done_size_, \
273 \
274 init_slot_, \
275 done_slot_, \
276 \
277 load_glyph_, \
278 \
279 get_kerning_, \
280 attach_file_, \
281 get_advances_, \
282 \
283 request_size_, \
284 select_size_ \
285 };
286
287
288FT_END_HEADER
289
290#endif /* FTDRV_H_ */
291
292
293/* END */