• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /****************************************************************************
2  *
3  * ftdrv.h
4  *
5  *   FreeType internal font driver interface (specification).
6  *
7  * Copyright 1996-2018 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 FTDRV_H_
20 #define FTDRV_H_
21 
22 
23 #include <ft2build.h>
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   typedef FT_Error
64   (*FT_Slot_LoadFunc)( FT_GlyphSlot  slot,
65                        FT_Size       size,
66                        FT_UInt       glyph_index,
67                        FT_Int32      load_flags );
68 
69 
70   typedef FT_Error
71   (*FT_Face_GetKerningFunc)( FT_Face     face,
72                              FT_UInt     left_glyph,
73                              FT_UInt     right_glyph,
74                              FT_Vector*  kerning );
75 
76 
77   typedef FT_Error
78   (*FT_Face_AttachFunc)( FT_Face    face,
79                          FT_Stream  stream );
80 
81 
82   typedef FT_Error
83   (*FT_Face_GetAdvancesFunc)( FT_Face    face,
84                               FT_UInt    first,
85                               FT_UInt    count,
86                               FT_Int32   flags,
87                               FT_Fixed*  advances );
88 
89 
90   /**************************************************************************
91    *
92    * @struct:
93    *   FT_Driver_ClassRec
94    *
95    * @description:
96    *   The font driver class.  This structure mostly contains pointers to
97    *   driver methods.
98    *
99    * @fields:
100    *   root ::
101    *     The parent module.
102    *
103    *   face_object_size ::
104    *     The size of a face object in bytes.
105    *
106    *   size_object_size ::
107    *     The size of a size object in bytes.
108    *
109    *   slot_object_size ::
110    *     The size of a glyph object in bytes.
111    *
112    *   init_face ::
113    *     The format-specific face constructor.
114    *
115    *   done_face ::
116    *     The format-specific face destructor.
117    *
118    *   init_size ::
119    *     The format-specific size constructor.
120    *
121    *   done_size ::
122    *     The format-specific size destructor.
123    *
124    *   init_slot ::
125    *     The format-specific slot constructor.
126    *
127    *   done_slot ::
128    *     The format-specific slot destructor.
129    *
130    *
131    *   load_glyph ::
132    *     A function handle to load a glyph to a slot.
133    *     This field is mandatory!
134    *
135    *   get_kerning ::
136    *     A function handle to return the unscaled
137    *     kerning for a given pair of glyphs.  Can be
138    *     set to 0 if the format doesn't support
139    *     kerning.
140    *
141    *   attach_file ::
142    *     This function handle is used to read
143    *     additional data for a face from another
144    *     file/stream.  For example, this can be used to
145    *     add data from AFM or PFM files on a Type 1
146    *     face, or a CIDMap on a CID-keyed face.
147    *
148    *   get_advances ::
149    *     A function handle used to return advance
150    *     widths of `count' glyphs (in font units),
151    *     starting at `first'.  The `vertical' flag must
152    *     be set to get vertical advance heights.  The
153    *     `advances' buffer is caller-allocated.
154    *     The idea of this function is to be able to
155    *     perform device-independent text layout without
156    *     loading a single glyph image.
157    *
158    *   request_size ::
159    *     A handle to a function used to request the new
160    *     character size.  Can be set to 0 if the
161    *     scaling done in the base layer suffices.
162    *
163    *   select_size ::
164    *     A handle to a function used to select a new
165    *     fixed size.  It is used only if
166    *     @FT_FACE_FLAG_FIXED_SIZES is set.  Can be set
167    *     to 0 if the scaling done in the base layer
168    *     suffices.
169    * @note:
170    *   Most function pointers, with the exception of `load_glyph', can be
171    *   set to 0 to indicate a default behaviour.
172    */
173   typedef struct  FT_Driver_ClassRec_
174   {
175     FT_Module_Class          root;
176 
177     FT_Long                  face_object_size;
178     FT_Long                  size_object_size;
179     FT_Long                  slot_object_size;
180 
181     FT_Face_InitFunc         init_face;
182     FT_Face_DoneFunc         done_face;
183 
184     FT_Size_InitFunc         init_size;
185     FT_Size_DoneFunc         done_size;
186 
187     FT_Slot_InitFunc         init_slot;
188     FT_Slot_DoneFunc         done_slot;
189 
190     FT_Slot_LoadFunc         load_glyph;
191 
192     FT_Face_GetKerningFunc   get_kerning;
193     FT_Face_AttachFunc       attach_file;
194     FT_Face_GetAdvancesFunc  get_advances;
195 
196     /* since version 2.2 */
197     FT_Size_RequestFunc      request_size;
198     FT_Size_SelectFunc       select_size;
199 
200   } FT_Driver_ClassRec, *FT_Driver_Class;
201 
202 
203   /**************************************************************************
204    *
205    * @macro:
206    *   FT_DECLARE_DRIVER
207    *
208    * @description:
209    *   Used to create a forward declaration of an FT_Driver_ClassRec
210    *   struct instance.
211    *
212    * @macro:
213    *   FT_DEFINE_DRIVER
214    *
215    * @description:
216    *   Used to initialize an instance of FT_Driver_ClassRec struct.
217    *
218    *   `ftinit.c' (ft_create_default_module_classes) already contains a
219    *   mechanism to call these functions for the default modules
220    *   described in `ftmodule.h'.
221    *
222    *   The struct will be allocated in the global scope (or the scope
223    *   where the macro is used).
224    */
225 #define FT_DECLARE_DRIVER( class_ )  \
226   FT_CALLBACK_TABLE                  \
227   const FT_Driver_ClassRec  class_;
228 
229 #define FT_DEFINE_DRIVER(                    \
230           class_,                            \
231           flags_,                            \
232           size_,                             \
233           name_,                             \
234           version_,                          \
235           requires_,                         \
236           interface_,                        \
237           init_,                             \
238           done_,                             \
239           get_interface_,                    \
240           face_object_size_,                 \
241           size_object_size_,                 \
242           slot_object_size_,                 \
243           init_face_,                        \
244           done_face_,                        \
245           init_size_,                        \
246           done_size_,                        \
247           init_slot_,                        \
248           done_slot_,                        \
249           load_glyph_,                       \
250           get_kerning_,                      \
251           attach_file_,                      \
252           get_advances_,                     \
253           request_size_,                     \
254           select_size_ )                     \
255   FT_CALLBACK_TABLE_DEF                      \
256   const FT_Driver_ClassRec  class_ =         \
257   {                                          \
258     FT_DEFINE_ROOT_MODULE( flags_,           \
259                            size_,            \
260                            name_,            \
261                            version_,         \
262                            requires_,        \
263                            interface_,       \
264                            init_,            \
265                            done_,            \
266                            get_interface_ )  \
267                                              \
268     face_object_size_,                       \
269     size_object_size_,                       \
270     slot_object_size_,                       \
271                                              \
272     init_face_,                              \
273     done_face_,                              \
274                                              \
275     init_size_,                              \
276     done_size_,                              \
277                                              \
278     init_slot_,                              \
279     done_slot_,                              \
280                                              \
281     load_glyph_,                             \
282                                              \
283     get_kerning_,                            \
284     attach_file_,                            \
285     get_advances_,                           \
286                                              \
287     request_size_,                           \
288     select_size_                             \
289   };
290 
291 
292 FT_END_HEADER
293 
294 #endif /* FTDRV_H_ */
295 
296 
297 /* END */
298