Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4680 | right-hear | 1 | /***************************************************************************/ |
2 | /* */ |
||
3 | /* ftdriver.h */ |
||
4 | /* */ |
||
5 | /* FreeType font driver interface (specification). */ |
||
6 | /* */ |
||
7 | /* Copyright 1996-2001, 2002, 2003, 2006, 2008 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 | #ifndef __FTDRIVER_H__ |
||
20 | #define __FTDRIVER_H__ |
||
21 | |||
22 | |||
23 | #include |
||
24 | #include FT_MODULE_H |
||
25 | |||
26 | |||
27 | FT_BEGIN_HEADER |
||
28 | |||
29 | |||
30 | typedef FT_Error |
||
31 | (*FT_Face_InitFunc)( FT_Stream stream, |
||
32 | FT_Face face, |
||
33 | FT_Int typeface_index, |
||
34 | FT_Int num_params, |
||
35 | FT_Parameter* parameters ); |
||
36 | |||
37 | typedef void |
||
38 | (*FT_Face_DoneFunc)( FT_Face face ); |
||
39 | |||
40 | |||
41 | typedef FT_Error |
||
42 | (*FT_Size_InitFunc)( FT_Size size ); |
||
43 | |||
44 | typedef void |
||
45 | (*FT_Size_DoneFunc)( FT_Size size ); |
||
46 | |||
47 | |||
48 | typedef FT_Error |
||
49 | (*FT_Slot_InitFunc)( FT_GlyphSlot slot ); |
||
50 | |||
51 | typedef void |
||
52 | (*FT_Slot_DoneFunc)( FT_GlyphSlot slot ); |
||
53 | |||
54 | |||
55 | typedef FT_Error |
||
56 | (*FT_Size_RequestFunc)( FT_Size size, |
||
57 | FT_Size_Request req ); |
||
58 | |||
59 | typedef FT_Error |
||
60 | (*FT_Size_SelectFunc)( FT_Size size, |
||
61 | FT_ULong size_index ); |
||
62 | |||
63 | #ifdef FT_CONFIG_OPTION_OLD_INTERNALS |
||
64 | |||
65 | typedef FT_Error |
||
66 | (*FT_Size_ResetPointsFunc)( FT_Size size, |
||
67 | FT_F26Dot6 char_width, |
||
68 | FT_F26Dot6 char_height, |
||
69 | FT_UInt horz_resolution, |
||
70 | FT_UInt vert_resolution ); |
||
71 | |||
72 | typedef FT_Error |
||
73 | (*FT_Size_ResetPixelsFunc)( FT_Size size, |
||
74 | FT_UInt pixel_width, |
||
75 | FT_UInt pixel_height ); |
||
76 | |||
77 | #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ |
||
78 | |||
79 | typedef FT_Error |
||
80 | (*FT_Slot_LoadFunc)( FT_GlyphSlot slot, |
||
81 | FT_Size size, |
||
82 | FT_UInt glyph_index, |
||
83 | FT_Int32 load_flags ); |
||
84 | |||
85 | |||
86 | typedef FT_UInt |
||
87 | (*FT_CharMap_CharIndexFunc)( FT_CharMap charmap, |
||
88 | FT_Long charcode ); |
||
89 | |||
90 | typedef FT_Long |
||
91 | (*FT_CharMap_CharNextFunc)( FT_CharMap charmap, |
||
92 | FT_Long charcode ); |
||
93 | |||
94 | |||
95 | typedef FT_Error |
||
96 | (*FT_Face_GetKerningFunc)( FT_Face face, |
||
97 | FT_UInt left_glyph, |
||
98 | FT_UInt right_glyph, |
||
99 | FT_Vector* kerning ); |
||
100 | |||
101 | |||
102 | typedef FT_Error |
||
103 | (*FT_Face_AttachFunc)( FT_Face face, |
||
104 | FT_Stream stream ); |
||
105 | |||
106 | |||
107 | typedef FT_Error |
||
108 | (*FT_Face_GetAdvancesFunc)( FT_Face face, |
||
109 | FT_UInt first, |
||
110 | FT_UInt count, |
||
111 | FT_Int32 flags, |
||
112 | FT_Fixed* advances ); |
||
113 | |||
114 | |||
115 | /*************************************************************************/ |
||
116 | /* */ |
||
117 | /* |
||
118 | /* FT_Driver_ClassRec */ |
||
119 | /* */ |
||
120 | /* |
||
121 | /* The font driver class. This structure mostly contains pointers to */ |
||
122 | /* driver methods. */ |
||
123 | /* */ |
||
124 | /* |
||
125 | /* root :: The parent module. */ |
||
126 | /* */ |
||
127 | /* face_object_size :: The size of a face object in bytes. */ |
||
128 | /* */ |
||
129 | /* size_object_size :: The size of a size object in bytes. */ |
||
130 | /* */ |
||
131 | /* slot_object_size :: The size of a glyph object in bytes. */ |
||
132 | /* */ |
||
133 | /* init_face :: The format-specific face constructor. */ |
||
134 | /* */ |
||
135 | /* done_face :: The format-specific face destructor. */ |
||
136 | /* */ |
||
137 | /* init_size :: The format-specific size constructor. */ |
||
138 | /* */ |
||
139 | /* done_size :: The format-specific size destructor. */ |
||
140 | /* */ |
||
141 | /* init_slot :: The format-specific slot constructor. */ |
||
142 | /* */ |
||
143 | /* done_slot :: The format-specific slot destructor. */ |
||
144 | /* */ |
||
145 | /* */ |
||
146 | /* load_glyph :: A function handle to load a glyph to a slot. */ |
||
147 | /* This field is mandatory! */ |
||
148 | /* */ |
||
149 | /* get_kerning :: A function handle to return the unscaled */ |
||
150 | /* kerning for a given pair of glyphs. Can be */ |
||
151 | /* set to 0 if the format doesn't support */ |
||
152 | /* kerning. */ |
||
153 | /* */ |
||
154 | /* attach_file :: This function handle is used to read */ |
||
155 | /* additional data for a face from another */ |
||
156 | /* file/stream. For example, this can be used to */ |
||
157 | /* add data from AFM or PFM files on a Type 1 */ |
||
158 | /* face, or a CIDMap on a CID-keyed face. */ |
||
159 | /* */ |
||
160 | /* get_advances :: A function handle used to return advance */ |
||
161 | /* widths of `count' glyphs (in font units), */ |
||
162 | /* starting at `first'. The `vertical' flag must */ |
||
163 | /* be set to get vertical advance heights. The */ |
||
164 | /* `advances' buffer is caller-allocated. */ |
||
165 | /* Currently not implemented. The idea of this */ |
||
166 | /* function is to be able to perform */ |
||
167 | /* device-independent text layout without loading */ |
||
168 | /* a single glyph image. */ |
||
169 | /* */ |
||
170 | /* request_size :: A handle to a function used to request the new */ |
||
171 | /* character size. Can be set to 0 if the */ |
||
172 | /* scaling done in the base layer suffices. */ |
||
173 | /* */ |
||
174 | /* select_size :: A handle to a function used to select a new */ |
||
175 | /* fixed size. It is used only if */ |
||
176 | /* @FT_FACE_FLAG_FIXED_SIZES is set. Can be set */ |
||
177 | /* to 0 if the scaling done in the base layer */ |
||
178 | /* suffices. */ |
||
179 | /* |
||
180 | /* Most function pointers, with the exception of `load_glyph', can be */ |
||
181 | /* set to 0 to indicate a default behaviour. */ |
||
182 | /* */ |
||
183 | typedef struct FT_Driver_ClassRec_ |
||
184 | { |
||
185 | FT_Module_Class root; |
||
186 | |||
187 | FT_Long face_object_size; |
||
188 | FT_Long size_object_size; |
||
189 | FT_Long slot_object_size; |
||
190 | |||
191 | FT_Face_InitFunc init_face; |
||
192 | FT_Face_DoneFunc done_face; |
||
193 | |||
194 | FT_Size_InitFunc init_size; |
||
195 | FT_Size_DoneFunc done_size; |
||
196 | |||
197 | FT_Slot_InitFunc init_slot; |
||
198 | FT_Slot_DoneFunc done_slot; |
||
199 | |||
200 | #ifdef FT_CONFIG_OPTION_OLD_INTERNALS |
||
201 | |||
202 | FT_Size_ResetPointsFunc set_char_sizes; |
||
203 | FT_Size_ResetPixelsFunc set_pixel_sizes; |
||
204 | |||
205 | #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ |
||
206 | |||
207 | FT_Slot_LoadFunc load_glyph; |
||
208 | |||
209 | FT_Face_GetKerningFunc get_kerning; |
||
210 | FT_Face_AttachFunc attach_file; |
||
211 | FT_Face_GetAdvancesFunc get_advances; |
||
212 | |||
213 | /* since version 2.2 */ |
||
214 | FT_Size_RequestFunc request_size; |
||
215 | FT_Size_SelectFunc select_size; |
||
216 | |||
217 | } FT_Driver_ClassRec, *FT_Driver_Class; |
||
218 | |||
219 | |||
220 | /* |
||
221 | * The following functions are used as stubs for `set_char_sizes' and |
||
222 | * `set_pixel_sizes'; the code uses `request_size' and `select_size' |
||
223 | * functions instead. |
||
224 | * |
||
225 | * Implementation is in `src/base/ftobjs.c'. |
||
226 | */ |
||
227 | #ifdef FT_CONFIG_OPTION_OLD_INTERNALS |
||
228 | |||
229 | FT_BASE( FT_Error ) |
||
230 | ft_stub_set_char_sizes( FT_Size size, |
||
231 | FT_F26Dot6 width, |
||
232 | FT_F26Dot6 height, |
||
233 | FT_UInt horz_res, |
||
234 | FT_UInt vert_res ); |
||
235 | |||
236 | FT_BASE( FT_Error ) |
||
237 | ft_stub_set_pixel_sizes( FT_Size size, |
||
238 | FT_UInt width, |
||
239 | FT_UInt height ); |
||
240 | |||
241 | #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ |
||
242 | |||
243 | /*************************************************************************/ |
||
244 | /* */ |
||
245 | /* |
||
246 | /* FT_DECLARE_DRIVER */ |
||
247 | /* */ |
||
248 | /* |
||
249 | /* Used to create a forward declaration of a */ |
||
250 | /* FT_Driver_ClassRec stract instance. */ |
||
251 | /* */ |
||
252 | /* |
||
253 | /* FT_DEFINE_DRIVER */ |
||
254 | /* */ |
||
255 | /* |
||
256 | /* Used to initialize an instance of FT_Driver_ClassRec struct. */ |
||
257 | /* */ |
||
258 | /* When FT_CONFIG_OPTION_PIC is defined a Create funtion will need */ |
||
259 | /* to called with a pointer where the allocated stracture is returned.*/ |
||
260 | /* And when it is no longer needed a Destroy function needs */ |
||
261 | /* to be called to release that allocation. */ |
||
262 | /* fcinit.c (ft_create_default_module_classes) already contains */ |
||
263 | /* a mechanism to call these functions for the default modules */ |
||
264 | /* described in ftmodule.h */ |
||
265 | /* */ |
||
266 | /* Notice that the created Create and Destroy functions call */ |
||
267 | /* pic_init and pic_free function to allow you to manually allocate */ |
||
268 | /* and initialize any additional global data, like module specific */ |
||
269 | /* interface, and put them in the global pic container defined in */ |
||
270 | /* ftpic.h. if you don't need them just implement the functions as */ |
||
271 | /* empty to resolve the link error. */ |
||
272 | /* */ |
||
273 | /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ |
||
274 | /* allocated in the global scope (or the scope where the macro */ |
||
275 | /* is used). */ |
||
276 | /* */ |
||
277 | #ifndef FT_CONFIG_OPTION_PIC |
||
278 | |||
279 | #ifdef FT_CONFIG_OPTION_OLD_INTERNALS |
||
280 | #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) \ |
||
281 | a_, b_, |
||
282 | #else |
||
283 | #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) |
||
284 | #endif |
||
285 | |||
286 | #define FT_DECLARE_DRIVER(class_) \ |
||
287 | FT_CALLBACK_TABLE \ |
||
288 | const FT_Driver_ClassRec class_; |
||
289 | |||
290 | #define FT_DEFINE_DRIVER(class_, \ |
||
291 | flags_, size_, name_, version_, requires_, \ |
||
292 | interface_, init_, done_, get_interface_, \ |
||
293 | face_object_size_, size_object_size_, \ |
||
294 | slot_object_size_, init_face_, done_face_, \ |
||
295 | init_size_, done_size_, init_slot_, done_slot_, \ |
||
296 | old_set_char_sizes_, old_set_pixel_sizes_, \ |
||
297 | load_glyph_, get_kerning_, attach_file_, \ |
||
298 | get_advances_, request_size_, select_size_ ) \ |
||
299 | FT_CALLBACK_TABLE_DEF \ |
||
300 | const FT_Driver_ClassRec class_ = \ |
||
301 | { \ |
||
302 | FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,interface_, \ |
||
303 | init_,done_,get_interface_) \ |
||
304 | \ |
||
305 | face_object_size_, \ |
||
306 | size_object_size_, \ |
||
307 | slot_object_size_, \ |
||
308 | \ |
||
309 | init_face_, \ |
||
310 | done_face_, \ |
||
311 | \ |
||
312 | init_size_, \ |
||
313 | done_size_, \ |
||
314 | \ |
||
315 | init_slot_, \ |
||
316 | done_slot_, \ |
||
317 | \ |
||
318 | FT_DEFINE_DRIVERS_OLD_INTERNALS(old_set_char_sizes_, old_set_pixel_sizes_) \ |
||
319 | \ |
||
320 | load_glyph_, \ |
||
321 | \ |
||
322 | get_kerning_, \ |
||
323 | attach_file_, \ |
||
324 | get_advances_, \ |
||
325 | \ |
||
326 | request_size_, \ |
||
327 | select_size_ \ |
||
328 | }; |
||
329 | |||
330 | #else /* FT_CONFIG_OPTION_PIC */ |
||
331 | |||
332 | #ifdef FT_CONFIG_OPTION_OLD_INTERNALS |
||
333 | #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) \ |
||
334 | clazz->set_char_sizes = a_; \ |
||
335 | clazz->set_pixel_sizes = b_; |
||
336 | #else |
||
337 | #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) |
||
338 | #endif |
||
339 | |||
340 | #define FT_DECLARE_DRIVER(class_) FT_DECLARE_MODULE(class_) |
||
341 | |||
342 | #define FT_DEFINE_DRIVER(class_, \ |
||
343 | flags_, size_, name_, version_, requires_, \ |
||
344 | interface_, init_, done_, get_interface_, \ |
||
345 | face_object_size_, size_object_size_, \ |
||
346 | slot_object_size_, init_face_, done_face_, \ |
||
347 | init_size_, done_size_, init_slot_, done_slot_, \ |
||
348 | old_set_char_sizes_, old_set_pixel_sizes_, \ |
||
349 | load_glyph_, get_kerning_, attach_file_, \ |
||
350 | get_advances_, request_size_, select_size_ ) \ |
||
351 | void class_##_pic_free( FT_Library library ); \ |
||
352 | FT_Error class_##_pic_init( FT_Library library ); \ |
||
353 | \ |
||
354 | void \ |
||
355 | FT_Destroy_Class_##class_( FT_Library library, \ |
||
356 | FT_Module_Class* clazz ) \ |
||
357 | { \ |
||
358 | FT_Memory memory = library->memory; \ |
||
359 | FT_Driver_Class dclazz = (FT_Driver_Class)clazz; \ |
||
360 | class_##_pic_free( library ); \ |
||
361 | if ( dclazz ) \ |
||
362 | FT_FREE( dclazz ); \ |
||
363 | } \ |
||
364 | \ |
||
365 | FT_Error \ |
||
366 | FT_Create_Class_##class_( FT_Library library, \ |
||
367 | FT_Module_Class** output_class ) \ |
||
368 | { \ |
||
369 | FT_Driver_Class clazz; \ |
||
370 | FT_Error error; \ |
||
371 | FT_Memory memory = library->memory; \ |
||
372 | \ |
||
373 | if ( FT_ALLOC( clazz, sizeof(*clazz) ) ) \ |
||
374 | return error; \ |
||
375 | \ |
||
376 | error = class_##_pic_init( library ); \ |
||
377 | if(error) \ |
||
378 | { \ |
||
379 | FT_FREE( clazz ); \ |
||
380 | return error; \ |
||
381 | } \ |
||
382 | \ |
||
383 | FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,interface_, \ |
||
384 | init_,done_,get_interface_) \ |
||
385 | \ |
||
386 | clazz->face_object_size = face_object_size_; \ |
||
387 | clazz->size_object_size = size_object_size_; \ |
||
388 | clazz->slot_object_size = slot_object_size_; \ |
||
389 | \ |
||
390 | clazz->init_face = init_face_; \ |
||
391 | clazz->done_face = done_face_; \ |
||
392 | \ |
||
393 | clazz->init_size = init_size_; \ |
||
394 | clazz->done_size = done_size_; \ |
||
395 | \ |
||
396 | clazz->init_slot = init_slot_; \ |
||
397 | clazz->done_slot = done_slot_; \ |
||
398 | \ |
||
399 | FT_DEFINE_DRIVERS_OLD_INTERNALS(old_set_char_sizes_, old_set_pixel_sizes_) \ |
||
400 | \ |
||
401 | clazz->load_glyph = load_glyph_; \ |
||
402 | \ |
||
403 | clazz->get_kerning = get_kerning_; \ |
||
404 | clazz->attach_file = attach_file_; \ |
||
405 | clazz->get_advances = get_advances_; \ |
||
406 | \ |
||
407 | clazz->request_size = request_size_; \ |
||
408 | clazz->select_size = select_size_; \ |
||
409 | \ |
||
410 | *output_class = (FT_Module_Class*)clazz; \ |
||
411 | return FT_Err_Ok; \ |
||
412 | } |
||
413 | |||
414 | |||
415 | #endif /* FT_CONFIG_OPTION_PIC */ |
||
416 | |||
417 | FT_END_HEADER |
||
418 | |||
419 | #endif /* __FTDRIVER_H__ */ |
||
420 | |||
421 | |||
422 | /* END */ |