1 /***************************************************************************/
5 /* FreeType font driver interface (specification). */
7 /* Copyright 1996-2003, 2006, 2008, 2011-2013 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 );
64 (*FT_Slot_LoadFunc)( FT_GlyphSlot slot,
67 FT_Int32 load_flags );
71 (*FT_CharMap_CharIndexFunc)( FT_CharMap charmap,
75 (*FT_CharMap_CharNextFunc)( FT_CharMap charmap,
80 (*FT_Face_GetKerningFunc)( FT_Face face,
87 (*FT_Face_AttachFunc)( FT_Face face,
92 (*FT_Face_GetAdvancesFunc)( FT_Face face,
99 /*************************************************************************/
102 /* FT_Driver_ClassRec */
105 /* The font driver class. This structure mostly contains pointers to */
106 /* driver methods. */
109 /* root :: The parent module. */
111 /* face_object_size :: The size of a face object in bytes. */
113 /* size_object_size :: The size of a size object in bytes. */
115 /* slot_object_size :: The size of a glyph object in bytes. */
117 /* init_face :: The format-specific face constructor. */
119 /* done_face :: The format-specific face destructor. */
121 /* init_size :: The format-specific size constructor. */
123 /* done_size :: The format-specific size destructor. */
125 /* init_slot :: The format-specific slot constructor. */
127 /* done_slot :: The format-specific slot destructor. */
130 /* load_glyph :: A function handle to load a glyph to a slot. */
131 /* This field is mandatory! */
133 /* get_kerning :: A function handle to return the unscaled */
134 /* kerning for a given pair of glyphs. Can be */
135 /* set to 0 if the format doesn't support */
138 /* attach_file :: This function handle is used to read */
139 /* additional data for a face from another */
140 /* file/stream. For example, this can be used to */
141 /* add data from AFM or PFM files on a Type 1 */
142 /* face, or a CIDMap on a CID-keyed face. */
144 /* get_advances :: A function handle used to return advance */
145 /* widths of `count' glyphs (in font units), */
146 /* starting at `first'. The `vertical' flag must */
147 /* be set to get vertical advance heights. The */
148 /* `advances' buffer is caller-allocated. */
149 /* The idea of this function is to be able to */
150 /* perform device-independent text layout without */
151 /* loading a single glyph image. */
153 /* request_size :: A handle to a function used to request the new */
154 /* character size. Can be set to 0 if the */
155 /* scaling done in the base layer suffices. */
157 /* select_size :: A handle to a function used to select a new */
158 /* fixed size. It is used only if */
159 /* @FT_FACE_FLAG_FIXED_SIZES is set. Can be set */
160 /* to 0 if the scaling done in the base layer */
163 /* Most function pointers, with the exception of `load_glyph', can be */
164 /* set to 0 to indicate a default behaviour. */
166 typedef struct FT_Driver_ClassRec_
168 FT_Module_Class root;
170 FT_Long face_object_size;
171 FT_Long size_object_size;
172 FT_Long slot_object_size;
174 FT_Face_InitFunc init_face;
175 FT_Face_DoneFunc done_face;
177 FT_Size_InitFunc init_size;
178 FT_Size_DoneFunc done_size;
180 FT_Slot_InitFunc init_slot;
181 FT_Slot_DoneFunc done_slot;
183 FT_Slot_LoadFunc load_glyph;
185 FT_Face_GetKerningFunc get_kerning;
186 FT_Face_AttachFunc attach_file;
187 FT_Face_GetAdvancesFunc get_advances;
189 /* since version 2.2 */
190 FT_Size_RequestFunc request_size;
191 FT_Size_SelectFunc select_size;
193 } FT_Driver_ClassRec, *FT_Driver_Class;
196 /*************************************************************************/
199 /* FT_DECLARE_DRIVER */
202 /* Used to create a forward declaration of an FT_Driver_ClassRec */
203 /* struct instance. */
206 /* FT_DEFINE_DRIVER */
209 /* Used to initialize an instance of FT_Driver_ClassRec struct. */
211 /* When FT_CONFIG_OPTION_PIC is defined a `create' function has to be */
212 /* called with a pointer where the allocated structure is returned. */
213 /* And when it is no longer needed a `destroy' function needs to be */
214 /* called to release that allocation. */
216 /* `fcinit.c' (ft_create_default_module_classes) already contains a */
217 /* mechanism to call these functions for the default modules */
218 /* described in `ftmodule.h'. */
220 /* Notice that the created `create' and `destroy' functions call */
221 /* `pic_init' and `pic_free' to allow you to manually allocate and */
222 /* initialize any additional global data, like a module specific */
223 /* interface, and put them in the global pic container defined in */
224 /* `ftpic.h'. If you don't need them just implement the functions as */
225 /* empty to resolve the link error. Also the `pic_init' and */
226 /* `pic_free' functions should be declared in `pic.h', to be referred */
227 /* by driver definition calling `FT_DEFINE_DRIVER' in following. */
229 /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
230 /* allocated in the global scope (or the scope where the macro is */
233 #ifndef FT_CONFIG_OPTION_PIC
235 #define FT_DECLARE_DRIVER( class_ ) \
237 const FT_Driver_ClassRec class_;
239 #define FT_DEFINE_DRIVER( \
265 FT_CALLBACK_TABLE_DEF \
266 const FT_Driver_ClassRec class_ = \
268 FT_DEFINE_ROOT_MODULE( flags_, \
301 #else /* FT_CONFIG_OPTION_PIC */
303 #define FT_DECLARE_DRIVER( class_ ) FT_DECLARE_MODULE( class_ )
305 #define FT_DEFINE_DRIVER( \
332 FT_Destroy_Class_ ## class_( FT_Library library, \
333 FT_Module_Class* clazz ) \
335 FT_Memory memory = library->memory; \
336 FT_Driver_Class dclazz = (FT_Driver_Class)clazz; \
339 class_ ## _pic_free( library ); \
346 FT_Create_Class_ ## class_( FT_Library library, \
347 FT_Module_Class** output_class ) \
349 FT_Driver_Class clazz = NULL; \
351 FT_Memory memory = library->memory; \
354 if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) ) \
357 error = class_ ## _pic_init( library ); \
364 FT_DEFINE_ROOT_MODULE( flags_, \
374 clazz->face_object_size = face_object_size_; \
375 clazz->size_object_size = size_object_size_; \
376 clazz->slot_object_size = slot_object_size_; \
378 clazz->init_face = init_face_; \
379 clazz->done_face = done_face_; \
381 clazz->init_size = init_size_; \
382 clazz->done_size = done_size_; \
384 clazz->init_slot = init_slot_; \
385 clazz->done_slot = done_slot_; \
387 clazz->load_glyph = load_glyph_; \
389 clazz->get_kerning = get_kerning_; \
390 clazz->attach_file = attach_file_; \
391 clazz->get_advances = get_advances_; \
393 clazz->request_size = request_size_; \
394 clazz->select_size = select_size_; \
396 *output_class = (FT_Module_Class*)clazz; \
402 #endif /* FT_CONFIG_OPTION_PIC */
406 #endif /* __FTDRIVER_H__ */