Visualization Library 2.0.0-b5

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
ftdriver.h
Go to the documentation of this file.
1 /***************************************************************************/
2 /* */
3 /* ftdriver.h */
4 /* */
5 /* FreeType font driver interface (specification). */
6 /* */
7 /* Copyright 1996-2003, 2006, 2008, 2011-2012 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 __FTDRIVER_H__
20 #define __FTDRIVER_H__
21 
22 
23 #include <ft2build.h>
24 #include FT_MODULE_H
25 
26 
28 
29 
30  typedef FT_Error
32  FT_Face face,
33  FT_Int typeface_index,
34  FT_Int num_params,
35  FT_Parameter* parameters );
36 
37  typedef void
39 
40 
41  typedef FT_Error
43 
44  typedef void
46 
47 
48  typedef FT_Error
50 
51  typedef void
53 
54 
55  typedef FT_Error
57  FT_Size_Request req );
58 
59  typedef FT_Error
61  FT_ULong size_index );
62 
63 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
64 
65  typedef FT_Error
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 );
71 
72  typedef FT_Error
73  (*FT_Size_ResetPixelsFunc)( FT_Size size,
74  FT_UInt pixel_width,
75  FT_UInt pixel_height );
76 
77 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
78 
79  typedef FT_Error
81  FT_Size size,
82  FT_UInt glyph_index,
83  FT_Int32 load_flags );
84 
85 
86  typedef FT_UInt
88  FT_Long charcode );
89 
90  typedef FT_Long
92  FT_Long charcode );
93 
94 
95  typedef FT_Error
97  FT_UInt left_glyph,
98  FT_UInt right_glyph,
99  FT_Vector* kerning );
100 
101 
102  typedef FT_Error
104  FT_Stream stream );
105 
106 
107  typedef FT_Error
109  FT_UInt first,
110  FT_UInt count,
111  FT_Int32 flags,
112  FT_Fixed* advances );
113 
114 
115  /*************************************************************************/
116  /* */
117  /* <Struct> */
118  /* FT_Driver_ClassRec */
119  /* */
120  /* <Description> */
121  /* The font driver class. This structure mostly contains pointers to */
122  /* driver methods. */
123  /* */
124  /* <Fields> */
125  /* root :: The parent module. */
126  /* */
127  /* face_object_size :: The size of a face object in bytes. */
128  /* */
129  /* size_object_size :: The size of a size object in bytes. */
130  /* */
131  /* slot_object_size :: The size of a glyph object in bytes. */
132  /* */
133  /* init_face :: The format-specific face constructor. */
134  /* */
135  /* done_face :: The format-specific face destructor. */
136  /* */
137  /* init_size :: The format-specific size constructor. */
138  /* */
139  /* done_size :: The format-specific size destructor. */
140  /* */
141  /* init_slot :: The format-specific slot constructor. */
142  /* */
143  /* done_slot :: The format-specific slot destructor. */
144  /* */
145  /* */
146  /* load_glyph :: A function handle to load a glyph to a slot. */
147  /* This field is mandatory! */
148  /* */
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 */
152  /* kerning. */
153  /* */
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. */
159  /* */
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. */
168  /* */
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. */
172  /* */
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 */
177  /* suffices. */
178  /* <Note> */
179  /* Most function pointers, with the exception of `load_glyph', can be */
180  /* set to 0 to indicate a default behaviour. */
181  /* */
182  typedef struct FT_Driver_ClassRec_
183  {
185 
189 
192 
195 
198 
199 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
200 
201  FT_Size_ResetPointsFunc set_char_sizes;
202  FT_Size_ResetPixelsFunc set_pixel_sizes;
203 
204 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
205 
207 
211 
212  /* since version 2.2 */
215 
217 
218 
219  /*
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'
222  * functions instead.
223  *
224  * Implementation is in `src/base/ftobjs.c'.
225  */
226 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
227 
228  FT_BASE( FT_Error )
229  ft_stub_set_char_sizes( FT_Size size,
232  FT_UInt horz_res,
233  FT_UInt vert_res );
234 
235  FT_BASE( FT_Error )
236  ft_stub_set_pixel_sizes( FT_Size size,
237  FT_UInt width,
238  FT_UInt height );
239 
240 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
241 
242 
243  /*************************************************************************/
244  /* */
245  /* <Macro> */
246  /* FT_DECLARE_DRIVER */
247  /* */
248  /* <Description> */
249  /* Used to create a forward declaration of an FT_Driver_ClassRec */
250  /* struct instance. */
251  /* */
252  /* <Macro> */
253  /* FT_DEFINE_DRIVER */
254  /* */
255  /* <Description> */
256  /* Used to initialize an instance of FT_Driver_ClassRec struct. */
257  /* */
258  /* When FT_CONFIG_OPTION_PIC is defined a `create' function has to be */
259  /* called with a pointer where the allocated structure is returned. */
260  /* And when it is no longer needed a `destroy' function needs to be */
261  /* called to release that allocation. */
262  /* */
263  /* `fcinit.c' (ft_create_default_module_classes) already contains a */
264  /* mechanism to call these functions for the default modules */
265  /* described in `ftmodule.h'. */
266  /* */
267  /* Notice that the created `create' and `destroy' functions call */
268  /* `pic_init' and `pic_free' to allow you to manually allocate and */
269  /* initialize any additional global data, like a module specific */
270  /* interface, and put them in the global pic container defined in */
271  /* `ftpic.h'. If you don't need them just implement the functions as */
272  /* empty to resolve the link error. Also the `pic_init' and */
273  /* `pic_free' functions should be declared in `pic.h', to be referred */
274  /* by driver definition calling `FT_DEFINE_DRIVER' in following. */
275  /* */
276  /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
277  /* allocated in the global scope (or the scope where the macro is */
278  /* used). */
279  /* */
280 #ifndef FT_CONFIG_OPTION_PIC
281 
282 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
283 #define FT_DEFINE_DRIVERS_OLD_INTERNALS( a_, b_ ) \
284  a_, b_,
285 #else
286 #define FT_DEFINE_DRIVERS_OLD_INTERNALS( a_, b_ ) /* empty */
287 #endif
288 
289 #define FT_DECLARE_DRIVER( class_ ) \
290  FT_CALLBACK_TABLE \
291  const FT_Driver_ClassRec class_;
292 
293 #define FT_DEFINE_DRIVER( \
294  class_, \
295  flags_, \
296  size_, \
297  name_, \
298  version_, \
299  requires_, \
300  interface_, \
301  init_, \
302  done_, \
303  get_interface_, \
304  face_object_size_, \
305  size_object_size_, \
306  slot_object_size_, \
307  init_face_, \
308  done_face_, \
309  init_size_, \
310  done_size_, \
311  init_slot_, \
312  done_slot_, \
313  old_set_char_sizes_, \
314  old_set_pixel_sizes_, \
315  load_glyph_, \
316  get_kerning_, \
317  attach_file_, \
318  get_advances_, \
319  request_size_, \
320  select_size_ ) \
321  FT_CALLBACK_TABLE_DEF \
322  const FT_Driver_ClassRec class_ = \
323  { \
324  FT_DEFINE_ROOT_MODULE( flags_, \
325  size_, \
326  name_, \
327  version_, \
328  requires_, \
329  interface_, \
330  init_, \
331  done_, \
332  get_interface_ ) \
333  \
334  face_object_size_, \
335  size_object_size_, \
336  slot_object_size_, \
337  \
338  init_face_, \
339  done_face_, \
340  \
341  init_size_, \
342  done_size_, \
343  \
344  init_slot_, \
345  done_slot_, \
346  \
347  FT_DEFINE_DRIVERS_OLD_INTERNALS( old_set_char_sizes_, \
348  old_set_pixel_sizes_ ) \
349  \
350  load_glyph_, \
351  \
352  get_kerning_, \
353  attach_file_, \
354  get_advances_, \
355  \
356  request_size_, \
357  select_size_ \
358  };
359 
360 #else /* FT_CONFIG_OPTION_PIC */
361 
362 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
363 #define FT_DEFINE_DRIVERS_OLD_INTERNALS( a_, b_ ) \
364  clazz->set_char_sizes = a_; \
365  clazz->set_pixel_sizes = b_;
366 #else
367 #define FT_DEFINE_DRIVERS_OLD_INTERNALS( a_, b_ ) /* empty */
368 #endif
369 
370 #define FT_DECLARE_DRIVER( class_ ) FT_DECLARE_MODULE( class_ )
371 
372 #define FT_DEFINE_DRIVER( \
373  class_, \
374  flags_, \
375  size_, \
376  name_, \
377  version_, \
378  requires_, \
379  interface_, \
380  init_, \
381  done_, \
382  get_interface_, \
383  face_object_size_, \
384  size_object_size_, \
385  slot_object_size_, \
386  init_face_, \
387  done_face_, \
388  init_size_, \
389  done_size_, \
390  init_slot_, \
391  done_slot_, \
392  old_set_char_sizes_, \
393  old_set_pixel_sizes_, \
394  load_glyph_, \
395  get_kerning_, \
396  attach_file_, \
397  get_advances_, \
398  request_size_, \
399  select_size_ ) \
400  void \
401  FT_Destroy_Class_ ## class_( FT_Library library, \
402  FT_Module_Class* clazz ) \
403  { \
404  FT_Memory memory = library->memory; \
405  FT_Driver_Class dclazz = (FT_Driver_Class)clazz; \
406  \
407  \
408  class_ ## _pic_free( library ); \
409  if ( dclazz ) \
410  FT_FREE( dclazz ); \
411  } \
412  \
413  \
414  FT_Error \
415  FT_Create_Class_ ## class_( FT_Library library, \
416  FT_Module_Class** output_class ) \
417  { \
418  FT_Driver_Class clazz = NULL; \
419  FT_Error error; \
420  FT_Memory memory = library->memory; \
421  \
422  \
423  if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) ) \
424  return error; \
425  \
426  error = class_ ## _pic_init( library ); \
427  if ( error ) \
428  { \
429  FT_FREE( clazz ); \
430  return error; \
431  } \
432  \
433  FT_DEFINE_ROOT_MODULE( flags_, \
434  size_, \
435  name_, \
436  version_, \
437  requires_, \
438  interface_, \
439  init_, \
440  done_, \
441  get_interface_ ) \
442  \
443  clazz->face_object_size = face_object_size_; \
444  clazz->size_object_size = size_object_size_; \
445  clazz->slot_object_size = slot_object_size_; \
446  \
447  clazz->init_face = init_face_; \
448  clazz->done_face = done_face_; \
449  \
450  clazz->init_size = init_size_; \
451  clazz->done_size = done_size_; \
452  \
453  clazz->init_slot = init_slot_; \
454  clazz->done_slot = done_slot_; \
455  \
456  FT_DEFINE_DRIVERS_OLD_INTERNALS( old_set_char_sizes_, \
457  old_set_pixel_sizes_ ) \
458  \
459  clazz->load_glyph = load_glyph_; \
460  \
461  clazz->get_kerning = get_kerning_; \
462  clazz->attach_file = attach_file_; \
463  clazz->get_advances = get_advances_; \
464  \
465  clazz->request_size = request_size_; \
466  clazz->select_size = select_size_; \
467  \
468  *output_class = (FT_Module_Class*)clazz; \
469  \
470  return FT_Err_Ok; \
471  }
472 
473 
474 #endif /* FT_CONFIG_OPTION_PIC */
475 
477 
478 #endif /* __FTDRIVER_H__ */
479 
480 
481 /* END */
GLint GLint GLsizei GLsizei height
void(* FT_Size_DoneFunc)(FT_Size size)
Definition: ftdriver.h:45
int FT_Error
Definition: fttypes.h:296
GLuint GLuint stream
signed long FT_Long
Definition: fttypes.h:238
unsigned long FT_ULong
Definition: fttypes.h:249
FT_Error(* FT_Size_RequestFunc)(FT_Size size, FT_Size_Request req)
Definition: ftdriver.h:56
FT_Size_InitFunc init_size
Definition: ftdriver.h:193
#define FT_END_HEADER
Definition: ftheader.h:54
void(* FT_Face_DoneFunc)(FT_Face face)
Definition: ftdriver.h:38
signed int FT_Int
Definition: fttypes.h:216
FT_Slot_DoneFunc done_slot
Definition: ftdriver.h:197
FT_Error(* FT_Slot_InitFunc)(FT_GlyphSlot slot)
Definition: ftdriver.h:49
FT_Module_Class root
Definition: ftdriver.h:184
GLint GLint GLsizei width
FT_UInt(* FT_CharMap_CharIndexFunc)(FT_CharMap charmap, FT_Long charcode)
Definition: ftdriver.h:87
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
FT_Error(* FT_Size_InitFunc)(FT_Size size)
Definition: ftdriver.h:42
GLenum GLuint GLint GLenum face
FT_Size_SelectFunc select_size
Definition: ftdriver.h:214
#define FT_BEGIN_HEADER
Definition: ftheader.h:36
FT_Long size_object_size
Definition: ftdriver.h:187
FT_Slot_InitFunc init_slot
Definition: ftdriver.h:196
FT_Long slot_object_size
Definition: ftdriver.h:188
#define FT_BASE(x)
Definition: ftconfig.h:247
void(* FT_Slot_DoneFunc)(FT_GlyphSlot slot)
Definition: ftdriver.h:52
GLbitfield flags
FT_Face_GetKerningFunc get_kerning
Definition: ftdriver.h:208
FT_BEGIN_HEADER typedef FT_Error(* FT_Face_InitFunc)(FT_Stream stream, FT_Face face, FT_Int typeface_index, FT_Int num_params, FT_Parameter *parameters)
Definition: ftdriver.h:31
FT_Size_DoneFunc done_size
Definition: ftdriver.h:194
signed int FT_Int32
Definition: ftconfig.h:132
const GLint * first
FT_Slot_LoadFunc load_glyph
Definition: ftdriver.h:206
FT_Error(* FT_Face_AttachFunc)(FT_Face face, FT_Stream stream)
Definition: ftdriver.h:103
FT_Size_RequestFunc request_size
Definition: ftdriver.h:213
FT_Long(* FT_CharMap_CharNextFunc)(FT_CharMap charmap, FT_Long charcode)
Definition: ftdriver.h:91
FT_Error(* FT_Face_GetAdvancesFunc)(FT_Face face, FT_UInt first, FT_UInt count, FT_Int32 flags, FT_Fixed *advances)
Definition: ftdriver.h:108
FT_Face_DoneFunc done_face
Definition: ftdriver.h:191
signed long FT_F26Dot6
Definition: fttypes.h:272
signed long FT_Fixed
Definition: fttypes.h:284
FT_Face_AttachFunc attach_file
Definition: ftdriver.h:209
FT_Face_GetAdvancesFunc get_advances
Definition: ftdriver.h:210
unsigned int FT_UInt
Definition: fttypes.h:227
FT_Error(* FT_Face_GetKerningFunc)(FT_Face face, FT_UInt left_glyph, FT_UInt right_glyph, FT_Vector *kerning)
Definition: ftdriver.h:96
struct FT_Driver_ClassRec_ * FT_Driver_Class
FT_Long face_object_size
Definition: ftdriver.h:186
FT_Face_InitFunc init_face
Definition: ftdriver.h:190
FT_Error(* FT_Slot_LoadFunc)(FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags)
Definition: ftdriver.h:80
GLuint GLuint GLsizei count
struct FT_Driver_ClassRec_ FT_Driver_ClassRec
GLsizeiptr size
FT_Error(* FT_Size_SelectFunc)(FT_Size size, FT_ULong size_index)
Definition: ftdriver.h:60