1 /***************************************************************************/
5 /* FreeType internal font driver interface (specification). */
7 /* Copyright 1996-2018 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 /***************************************************************************/
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_Face_GetKerningFunc
)( FT_Face face
,
78 (*FT_Face_AttachFunc
)( FT_Face face
,
83 (*FT_Face_GetAdvancesFunc
)( FT_Face face
,
90 /*************************************************************************/
93 /* FT_Driver_ClassRec */
96 /* The font driver class. This structure mostly contains pointers to */
100 /* root :: The parent module. */
102 /* face_object_size :: The size of a face object in bytes. */
104 /* size_object_size :: The size of a size object in bytes. */
106 /* slot_object_size :: The size of a glyph object in bytes. */
108 /* init_face :: The format-specific face constructor. */
110 /* done_face :: The format-specific face destructor. */
112 /* init_size :: The format-specific size constructor. */
114 /* done_size :: The format-specific size destructor. */
116 /* init_slot :: The format-specific slot constructor. */
118 /* done_slot :: The format-specific slot destructor. */
121 /* load_glyph :: A function handle to load a glyph to a slot. */
122 /* This field is mandatory! */
124 /* get_kerning :: A function handle to return the unscaled */
125 /* kerning for a given pair of glyphs. Can be */
126 /* set to 0 if the format doesn't support */
129 /* attach_file :: This function handle is used to read */
130 /* additional data for a face from another */
131 /* file/stream. For example, this can be used to */
132 /* add data from AFM or PFM files on a Type 1 */
133 /* face, or a CIDMap on a CID-keyed face. */
135 /* get_advances :: A function handle used to return advance */
136 /* widths of `count' glyphs (in font units), */
137 /* starting at `first'. The `vertical' flag must */
138 /* be set to get vertical advance heights. The */
139 /* `advances' buffer is caller-allocated. */
140 /* The idea of this function is to be able to */
141 /* perform device-independent text layout without */
142 /* loading a single glyph image. */
144 /* request_size :: A handle to a function used to request the new */
145 /* character size. Can be set to 0 if the */
146 /* scaling done in the base layer suffices. */
148 /* select_size :: A handle to a function used to select a new */
149 /* fixed size. It is used only if */
150 /* @FT_FACE_FLAG_FIXED_SIZES is set. Can be set */
151 /* to 0 if the scaling done in the base layer */
154 /* Most function pointers, with the exception of `load_glyph', can be */
155 /* set to 0 to indicate a default behaviour. */
157 typedef struct FT_Driver_ClassRec_
159 FT_Module_Class root
;
161 FT_Long face_object_size
;
162 FT_Long size_object_size
;
163 FT_Long slot_object_size
;
165 FT_Face_InitFunc init_face
;
166 FT_Face_DoneFunc done_face
;
168 FT_Size_InitFunc init_size
;
169 FT_Size_DoneFunc done_size
;
171 FT_Slot_InitFunc init_slot
;
172 FT_Slot_DoneFunc done_slot
;
174 FT_Slot_LoadFunc load_glyph
;
176 FT_Face_GetKerningFunc get_kerning
;
177 FT_Face_AttachFunc attach_file
;
178 FT_Face_GetAdvancesFunc get_advances
;
180 /* since version 2.2 */
181 FT_Size_RequestFunc request_size
;
182 FT_Size_SelectFunc select_size
;
184 } FT_Driver_ClassRec
, *FT_Driver_Class
;
187 /*************************************************************************/
190 /* FT_DECLARE_DRIVER */
193 /* Used to create a forward declaration of an FT_Driver_ClassRec */
194 /* struct instance. */
197 /* FT_DEFINE_DRIVER */
200 /* Used to initialize an instance of FT_Driver_ClassRec struct. */
202 /* When FT_CONFIG_OPTION_PIC is defined a `create' function has to be */
203 /* called with a pointer where the allocated structure is returned. */
204 /* And when it is no longer needed a `destroy' function needs to be */
205 /* called to release that allocation. */
207 /* `ftinit.c' (ft_create_default_module_classes) already contains a */
208 /* mechanism to call these functions for the default modules */
209 /* described in `ftmodule.h'. */
211 /* Notice that the created `create' and `destroy' functions call */
212 /* `pic_init' and `pic_free' to allow you to manually allocate and */
213 /* initialize any additional global data, like a module specific */
214 /* interface, and put them in the global pic container defined in */
215 /* `ftpic.h'. If you don't need them just implement the functions as */
216 /* empty to resolve the link error. Also the `pic_init' and */
217 /* `pic_free' functions should be declared in `pic.h', to be referred */
218 /* by driver definition calling `FT_DEFINE_DRIVER' in following. */
220 /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
221 /* allocated in the global scope (or the scope where the macro is */
224 #ifndef FT_CONFIG_OPTION_PIC
226 #define FT_DECLARE_DRIVER( class_ ) \
228 const FT_Driver_ClassRec class_;
230 #define FT_DEFINE_DRIVER( \
256 FT_CALLBACK_TABLE_DEF \
257 const FT_Driver_ClassRec class_ = \
259 FT_DEFINE_ROOT_MODULE( flags_, \
292 #else /* FT_CONFIG_OPTION_PIC */
294 #define FT_DECLARE_DRIVER( class_ ) FT_DECLARE_MODULE( class_ )
296 #define FT_DEFINE_DRIVER( \
323 FT_Destroy_Class_ ## class_( FT_Library library, \
324 FT_Module_Class* clazz ) \
326 FT_Memory memory = library->memory; \
327 FT_Driver_Class dclazz = (FT_Driver_Class)clazz; \
330 class_ ## _pic_free( library ); \
337 FT_Create_Class_ ## class_( FT_Library library, \
338 FT_Module_Class** output_class ) \
340 FT_Driver_Class clazz = NULL; \
342 FT_Memory memory = library->memory; \
345 if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) ) \
348 error = class_ ## _pic_init( library ); \
355 FT_DEFINE_ROOT_MODULE( flags_, \
365 clazz->face_object_size = face_object_size_; \
366 clazz->size_object_size = size_object_size_; \
367 clazz->slot_object_size = slot_object_size_; \
369 clazz->init_face = init_face_; \
370 clazz->done_face = done_face_; \
372 clazz->init_size = init_size_; \
373 clazz->done_size = done_size_; \
375 clazz->init_slot = init_slot_; \
376 clazz->done_slot = done_slot_; \
378 clazz->load_glyph = load_glyph_; \
380 clazz->get_kerning = get_kerning_; \
381 clazz->attach_file = attach_file_; \
382 clazz->get_advances = get_advances_; \
384 clazz->request_size = request_size_; \
385 clazz->select_size = select_size_; \
387 *output_class = (FT_Module_Class*)clazz; \
393 #endif /* FT_CONFIG_OPTION_PIC */
397 #endif /* FTDRV_H_ */