1 /***************************************************************************/
5 /* FreeType font driver interface (specification). */
7 /* Copyright 1996-2001, 2002, 2003, 2006, 2008 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
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. */
16 /***************************************************************************/
19 #ifndef __FTDRIVER_H__
20 #define __FTDRIVER_H__
31 (*FT_Face_InitFunc
)( FT_Stream stream
,
33 FT_Int typeface_index
,
35 FT_Parameter
* parameters
);
38 (*FT_Face_DoneFunc
)( FT_Face face
);
42 (*FT_Size_InitFunc
)( FT_Size size
);
45 (*FT_Size_DoneFunc
)( FT_Size size
);
49 (*FT_Slot_InitFunc
)( FT_GlyphSlot slot
);
52 (*FT_Slot_DoneFunc
)( FT_GlyphSlot slot
);
56 (*FT_Size_RequestFunc
)( FT_Size size
,
57 FT_Size_Request req
);
60 (*FT_Size_SelectFunc
)( FT_Size size
,
61 FT_ULong size_index
);
63 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
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
);
73 (*FT_Size_ResetPixelsFunc
)( FT_Size size
,
75 FT_UInt pixel_height
);
77 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
80 (*FT_Slot_LoadFunc
)( FT_GlyphSlot slot
,
83 FT_Int32 load_flags
);
87 (*FT_CharMap_CharIndexFunc
)( FT_CharMap charmap
,
91 (*FT_CharMap_CharNextFunc
)( FT_CharMap charmap
,
96 (*FT_Face_GetKerningFunc
)( FT_Face face
,
103 (*FT_Face_AttachFunc
)( FT_Face face
,
108 (*FT_Face_GetAdvancesFunc
)( FT_Face face
,
112 FT_Fixed
* advances
);
115 /*************************************************************************/
118 /* FT_Driver_ClassRec */
121 /* The font driver class. This structure mostly contains pointers to */
122 /* driver methods. */
125 /* root :: The parent module. */
127 /* face_object_size :: The size of a face object in bytes. */
129 /* size_object_size :: The size of a size object in bytes. */
131 /* slot_object_size :: The size of a glyph object in bytes. */
133 /* init_face :: The format-specific face constructor. */
135 /* done_face :: The format-specific face destructor. */
137 /* init_size :: The format-specific size constructor. */
139 /* done_size :: The format-specific size destructor. */
141 /* init_slot :: The format-specific slot constructor. */
143 /* done_slot :: The format-specific slot destructor. */
146 /* load_glyph :: A function handle to load a glyph to a slot. */
147 /* This field is mandatory! */
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 */
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. */
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. */
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. */
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 */
180 /* Most function pointers, with the exception of `load_glyph', can be */
181 /* set to 0 to indicate a default behaviour. */
183 typedef struct FT_Driver_ClassRec_
185 FT_Module_Class root
;
187 FT_Long face_object_size
;
188 FT_Long size_object_size
;
189 FT_Long slot_object_size
;
191 FT_Face_InitFunc init_face
;
192 FT_Face_DoneFunc done_face
;
194 FT_Size_InitFunc init_size
;
195 FT_Size_DoneFunc done_size
;
197 FT_Slot_InitFunc init_slot
;
198 FT_Slot_DoneFunc done_slot
;
200 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
202 FT_Size_ResetPointsFunc set_char_sizes
;
203 FT_Size_ResetPixelsFunc set_pixel_sizes
;
205 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
207 FT_Slot_LoadFunc load_glyph
;
209 FT_Face_GetKerningFunc get_kerning
;
210 FT_Face_AttachFunc attach_file
;
211 FT_Face_GetAdvancesFunc get_advances
;
213 /* since version 2.2 */
214 FT_Size_RequestFunc request_size
;
215 FT_Size_SelectFunc select_size
;
217 } FT_Driver_ClassRec
, *FT_Driver_Class
;
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'
225 * Implementation is in `src/base/ftobjs.c'.
227 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
230 ft_stub_set_char_sizes( FT_Size size
,
237 ft_stub_set_pixel_sizes( FT_Size size
,
241 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
243 /*************************************************************************/
246 /* FT_DECLARE_DRIVER */
249 /* Used to create a forward declaration of a */
250 /* FT_Driver_ClassRec stract instance. */
253 /* FT_DEFINE_DRIVER */
256 /* Used to initialize an instance of FT_Driver_ClassRec struct. */
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 */
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. */
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 */
277 #ifndef FT_CONFIG_OPTION_PIC
279 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
280 #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) \
283 #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_)
286 #define FT_DECLARE_DRIVER(class_) \
288 const FT_Driver_ClassRec class_;
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_ = \
302 FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,interface_, \
303 init_,done_,get_interface_) \
318 FT_DEFINE_DRIVERS_OLD_INTERNALS(old_set_char_sizes_, old_set_pixel_sizes_) \
330 #else /* FT_CONFIG_OPTION_PIC */
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_;
337 #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_)
340 #define FT_DECLARE_DRIVER(class_) FT_DECLARE_MODULE(class_)
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 ); \
355 FT_Destroy_Class_##class_( FT_Library library, \
356 FT_Module_Class* clazz ) \
358 FT_Memory memory = library->memory; \
359 FT_Driver_Class dclazz = (FT_Driver_Class)clazz; \
360 class_##_pic_free( library ); \
366 FT_Create_Class_##class_( FT_Library library, \
367 FT_Module_Class** output_class ) \
369 FT_Driver_Class clazz; \
371 FT_Memory memory = library->memory; \
373 if ( FT_ALLOC( clazz, sizeof(*clazz) ) ) \
376 error = class_##_pic_init( library ); \
383 FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,interface_, \
384 init_,done_,get_interface_) \
386 clazz->face_object_size = face_object_size_; \
387 clazz->size_object_size = size_object_size_; \
388 clazz->slot_object_size = slot_object_size_; \
390 clazz->init_face = init_face_; \
391 clazz->done_face = done_face_; \
393 clazz->init_size = init_size_; \
394 clazz->done_size = done_size_; \
396 clazz->init_slot = init_slot_; \
397 clazz->done_slot = done_slot_; \
399 FT_DEFINE_DRIVERS_OLD_INTERNALS(old_set_char_sizes_, old_set_pixel_sizes_) \
401 clazz->load_glyph = load_glyph_; \
403 clazz->get_kerning = get_kerning_; \
404 clazz->attach_file = attach_file_; \
405 clazz->get_advances = get_advances_; \
407 clazz->request_size = request_size_; \
408 clazz->select_size = select_size_; \
410 *output_class = (FT_Module_Class*)clazz; \
415 #endif /* FT_CONFIG_OPTION_PIC */
419 #endif /* __FTDRIVER_H__ */