1 /***************************************************************************/
5 /* FreeType font driver interface (specification). */
7 /* Copyright 1996-2003, 2006, 2008, 2011 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 /* The idea of this function is to be able to */
166 /* perform device-independent text layout without */
167 /* loading a single glyph image. */
169 /* request_size :: A handle to a function used to request the new */
170 /* character size. Can be set to 0 if the */
171 /* scaling done in the base layer suffices. */
173 /* select_size :: A handle to a function used to select a new */
174 /* fixed size. It is used only if */
175 /* @FT_FACE_FLAG_FIXED_SIZES is set. Can be set */
176 /* to 0 if the scaling done in the base layer */
179 /* Most function pointers, with the exception of `load_glyph', can be */
180 /* set to 0 to indicate a default behaviour. */
182 typedef struct FT_Driver_ClassRec_
184 FT_Module_Class root;
186 FT_Long face_object_size;
187 FT_Long size_object_size;
188 FT_Long slot_object_size;
190 FT_Face_InitFunc init_face;
191 FT_Face_DoneFunc done_face;
193 FT_Size_InitFunc init_size;
194 FT_Size_DoneFunc done_size;
196 FT_Slot_InitFunc init_slot;
197 FT_Slot_DoneFunc done_slot;
199 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
201 FT_Size_ResetPointsFunc set_char_sizes;
202 FT_Size_ResetPixelsFunc set_pixel_sizes;
204 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
206 FT_Slot_LoadFunc load_glyph;
208 FT_Face_GetKerningFunc get_kerning;
209 FT_Face_AttachFunc attach_file;
210 FT_Face_GetAdvancesFunc get_advances;
212 /* since version 2.2 */
213 FT_Size_RequestFunc request_size;
214 FT_Size_SelectFunc select_size;
216 } FT_Driver_ClassRec, *FT_Driver_Class;
220 * The following functions are used as stubs for `set_char_sizes' and
221 * `set_pixel_sizes'; the code uses `request_size' and `select_size'
224 * Implementation is in `src/base/ftobjs.c'.
226 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
229 ft_stub_set_char_sizes( FT_Size size,
236 ft_stub_set_pixel_sizes( FT_Size size,
240 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
242 /*************************************************************************/
245 /* FT_DECLARE_DRIVER */
248 /* Used to create a forward declaration of a */
249 /* FT_Driver_ClassRec stract instance. */
252 /* FT_DEFINE_DRIVER */
255 /* Used to initialize an instance of FT_Driver_ClassRec struct. */
257 /* When FT_CONFIG_OPTION_PIC is defined a Create funtion will need */
258 /* to called with a pointer where the allocated stracture is returned.*/
259 /* And when it is no longer needed a Destroy function needs */
260 /* to be called to release that allocation. */
261 /* fcinit.c (ft_create_default_module_classes) already contains */
262 /* a mechanism to call these functions for the default modules */
263 /* described in ftmodule.h */
265 /* Notice that the created Create and Destroy functions call */
266 /* pic_init and pic_free function to allow you to manually allocate */
267 /* and initialize any additional global data, like module specific */
268 /* interface, and put them in the global pic container defined in */
269 /* ftpic.h. if you don't need them just implement the functions as */
270 /* empty to resolve the link error. Also the pic_init and pic_free */
271 /* functions should be declared in pic.h, to be referred by driver */
272 /* definition calling FT_DEFINE_DRIVER() in following. */
274 /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
275 /* allocated in the global scope (or the scope where the macro */
278 #ifndef FT_CONFIG_OPTION_PIC
280 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
281 #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) \
284 #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_)
287 #define FT_DECLARE_DRIVER(class_) \
289 const FT_Driver_ClassRec class_;
291 #define FT_DEFINE_DRIVER(class_, \
292 flags_, size_, name_, version_, requires_, \
293 interface_, init_, done_, get_interface_, \
294 face_object_size_, size_object_size_, \
295 slot_object_size_, init_face_, done_face_, \
296 init_size_, done_size_, init_slot_, done_slot_, \
297 old_set_char_sizes_, old_set_pixel_sizes_, \
298 load_glyph_, get_kerning_, attach_file_, \
299 get_advances_, request_size_, select_size_ ) \
300 FT_CALLBACK_TABLE_DEF \
301 const FT_Driver_ClassRec class_ = \
303 FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,interface_, \
304 init_,done_,get_interface_) \
319 FT_DEFINE_DRIVERS_OLD_INTERNALS(old_set_char_sizes_, old_set_pixel_sizes_) \
331 #else /* FT_CONFIG_OPTION_PIC */
333 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
334 #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) \
335 clazz->set_char_sizes = a_; \
336 clazz->set_pixel_sizes = b_;
338 #define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_)
341 #define FT_DECLARE_DRIVER(class_) FT_DECLARE_MODULE(class_)
343 #define FT_DEFINE_DRIVER(class_, \
344 flags_, size_, name_, version_, requires_, \
345 interface_, init_, done_, get_interface_, \
346 face_object_size_, size_object_size_, \
347 slot_object_size_, init_face_, done_face_, \
348 init_size_, done_size_, init_slot_, done_slot_, \
349 old_set_char_sizes_, old_set_pixel_sizes_, \
350 load_glyph_, get_kerning_, attach_file_, \
351 get_advances_, request_size_, select_size_ ) \
354 FT_Destroy_Class_##class_( FT_Library library, \
355 FT_Module_Class* clazz ) \
357 FT_Memory memory = library->memory; \
358 FT_Driver_Class dclazz = (FT_Driver_Class)clazz; \
359 class_##_pic_free( library ); \
365 FT_Create_Class_##class_( FT_Library library, \
366 FT_Module_Class** output_class ) \
368 FT_Driver_Class clazz; \
370 FT_Memory memory = library->memory; \
372 if ( FT_ALLOC( clazz, sizeof(*clazz) ) ) \
375 error = class_##_pic_init( library ); \
382 FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,interface_, \
383 init_,done_,get_interface_) \
385 clazz->face_object_size = face_object_size_; \
386 clazz->size_object_size = size_object_size_; \
387 clazz->slot_object_size = slot_object_size_; \
389 clazz->init_face = init_face_; \
390 clazz->done_face = done_face_; \
392 clazz->init_size = init_size_; \
393 clazz->done_size = done_size_; \
395 clazz->init_slot = init_slot_; \
396 clazz->done_slot = done_slot_; \
398 FT_DEFINE_DRIVERS_OLD_INTERNALS(old_set_char_sizes_, old_set_pixel_sizes_) \
400 clazz->load_glyph = load_glyph_; \
402 clazz->get_kerning = get_kerning_; \
403 clazz->attach_file = attach_file_; \
404 clazz->get_advances = get_advances_; \
406 clazz->request_size = request_size_; \
407 clazz->select_size = select_size_; \
409 *output_class = (FT_Module_Class*)clazz; \
414 #endif /* FT_CONFIG_OPTION_PIC */
418 #endif /* __FTDRIVER_H__ */