ftobjs.h 40.7 KB
Newer Older
David Turner's avatar
David Turner committed
1
2
3
4
/***************************************************************************/
/*                                                                         */
/*  ftobjs.h                                                               */
/*                                                                         */
Werner Lemberg's avatar
   
Werner Lemberg committed
5
/*    The FreeType private base classes (specification).                   */
David Turner's avatar
David Turner committed
6
/*                                                                         */
Werner Lemberg's avatar
Werner Lemberg committed
7
/*  Copyright 1996-2001, 2002, 2003 by                                     */
Werner Lemberg's avatar
   
Werner Lemberg committed
8
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
David Turner's avatar
David Turner committed
9
/*                                                                         */
Werner Lemberg's avatar
   
Werner Lemberg committed
10
11
/*  This file is part of the FreeType project, and may only be used,       */
/*  modified, and distributed under the terms of the FreeType project      */
David Turner's avatar
David Turner committed
12
13
14
15
16
17
18
19
20
21
22
23
24
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
/*  this file you indicate that you have read the license and              */
/*  understand and accept it fully.                                        */
/*                                                                         */
/***************************************************************************/


  /*************************************************************************/
  /*                                                                       */
  /*  This file contains the definition of all internal FreeType classes.  */
  /*                                                                       */
  /*************************************************************************/

Werner Lemberg's avatar
   
Werner Lemberg committed
25

26
27
#ifndef __FTOBJS_H__
#define __FTOBJS_H__
David Turner's avatar
David Turner committed
28

29
#include <ft2build.h>
30
#include FT_CONFIG_STANDARD_LIBRARY_H   /* for ft_setjmp and ft_longjmp */
31
#include FT_RENDER_H
32
#include FT_SIZES_H
33
#include FT_INTERNAL_MEMORY_H
34
#include FT_INTERNAL_GLYPH_LOADER_H
35
36
#include FT_INTERNAL_DRIVER_H
#include FT_INTERNAL_AUTOHINT_H
37
#include FT_INTERNAL_OBJECT_H
38

39
40
41
42
#ifdef FT_CONFIG_OPTION_INCREMENTAL
#include FT_INCREMENTAL_H
#endif

Werner Lemberg's avatar
   
Werner Lemberg committed
43

44
FT_BEGIN_HEADER
Werner Lemberg's avatar
   
Werner Lemberg committed
45

46

David Turner's avatar
David Turner committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
  /*************************************************************************/
  /*                                                                       */
  /* Some generic definitions.                                             */
  /*                                                                       */
#ifndef TRUE
#define TRUE  1
#endif

#ifndef FALSE
#define FALSE  0
#endif

#ifndef NULL
#define NULL  (void*)0
#endif


  /*************************************************************************/
  /*                                                                       */
  /* The min and max functions missing in C.  As usual, be careful not to  */
  /* write things like MIN( a++, b++ ) to avoid side effects.              */
  /*                                                                       */
#ifndef MIN
#define MIN( a, b )  ( (a) < (b) ? (a) : (b) )
#endif

#ifndef MAX
#define MAX( a, b )  ( (a) > (b) ? (a) : (b) )
#endif

#ifndef ABS
#define ABS( a )     ( (a) < 0 ? -(a) : (a) )
#endif

Werner Lemberg's avatar
   
Werner Lemberg committed
81

82
83
84
85
86
87
88
89
90
91
92
93
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /****                                                                 ****/
  /****                                                                 ****/
  /****                    V A L I D A T I O N                          ****/
  /****                                                                 ****/
  /****                                                                 ****/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/

Werner Lemberg's avatar
   
Werner Lemberg committed
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
  /* handle to a validation object */
  typedef struct FT_ValidatorRec_*  FT_Validator;


  /*************************************************************************/
  /*                                                                       */
  /* There are three distinct validation levels defined here:              */
  /*                                                                       */
  /* FT_VALIDATE_DEFAULT ::                                                */
  /*   A table that passes this validation level can be used reliably by   */
  /*   FreeType.  It generally means that all offsets have been checked to */
  /*   prevent out-of-bound reads, array counts are correct, etc.          */
  /*                                                                       */
  /* FT_VALIDATE_TIGHT ::                                                  */
  /*   A table that passes this validation level can be used reliably and  */
  /*   doesn't contain invalid data.  For example, a charmap table that    */
  /*   returns invalid glyph indices will not pass, even though it can     */
  /*   be used with FreeType in default mode (the library will simply      */
  /*   return an error later when trying to load the glyph).               */
  /*                                                                       */
  /*   It also check that fields that must be a multiple of 2, 4, or 8     */
Werner Lemberg's avatar
   
Werner Lemberg committed
115
  /*   don't have incorrect values, etc.                                   */
Werner Lemberg's avatar
   
Werner Lemberg committed
116
117
118
119
120
121
122
123
  /*                                                                       */
  /* FT_VALIDATE_PARANOID ::                                               */
  /*   Only for font debugging.  Checks that a table follows the           */
  /*   specification by 100%.  Very few fonts will be able to pass this    */
  /*   level anyway but it can be useful for certain tools like font       */
  /*   editors/converters.                                                 */
  /*                                                                       */
  typedef enum  FT_ValidationLevel_
124
125
126
127
  {
    FT_VALIDATE_DEFAULT = 0,
    FT_VALIDATE_TIGHT,
    FT_VALIDATE_PARANOID
128

129
130
131
  } FT_ValidationLevel;


Werner Lemberg's avatar
   
Werner Lemberg committed
132
133
  /* validator structure */
  typedef struct  FT_ValidatorRec_
134
  {
Werner Lemberg's avatar
   
Werner Lemberg committed
135
136
137
138
    const FT_Byte*      base;        /* address of table in memory       */
    const FT_Byte*      limit;       /* `base' + sizeof(table) in memory */
    FT_ValidationLevel  level;       /* validation level                 */
    FT_Error            error;       /* error returned. 0 means success  */
139

Werner Lemberg's avatar
   
Werner Lemberg committed
140
    ft_jmp_buf          jump_buffer; /* used for exception handling      */
141

142
143
  } FT_ValidatorRec;

Werner Lemberg's avatar
   
Werner Lemberg committed
144
145
146

#define FT_VALIDATOR( x )  ((FT_Validator)( x ))

147

148
149
  FT_BASE( void )
  ft_validator_init( FT_Validator        valid,
150
151
                     const FT_Byte*      base,
                     const FT_Byte*      limit,
152
153
                     FT_ValidationLevel  level );

154
155
156
  FT_BASE( FT_Int )
  ft_validator_run( FT_Validator  valid );

Werner Lemberg's avatar
   
Werner Lemberg committed
157
158
159
160
  /* Sets the error field in a validator, then calls `longjmp' to return */
  /* to high-level caller.  Using `setjmp/longjmp' avoids many stupid    */
  /* error checks within the validation routines.                        */
  /*                                                                     */
161
  FT_BASE( void )
162
163
  ft_validator_error( FT_Validator  valid,
                      FT_Error      error );
164
165


Werner Lemberg's avatar
   
Werner Lemberg committed
166
167
168
169
  /* Calls ft_validate_error.  Assumes that the `valid' local variable */
  /* holds a pointer to the current validator object.                  */
  /*                                                                   */
#define FT_INVALID( _error )  ft_validator_error( valid, _error )
170

Werner Lemberg's avatar
   
Werner Lemberg committed
171
172
  /* called when a broken table is detected */
#define FT_INVALID_TOO_SHORT  FT_INVALID( FT_Err_Invalid_Table )
173

Werner Lemberg's avatar
   
Werner Lemberg committed
174
175
  /* called when an invalid offset is detected */
#define FT_INVALID_OFFSET     FT_INVALID( FT_Err_Invalid_Offset )
176

Werner Lemberg's avatar
   
Werner Lemberg committed
177
178
  /* called when an invalid format/value is detected */
#define FT_INVALID_FORMAT     FT_INVALID( FT_Err_Invalid_Table )
179

Werner Lemberg's avatar
   
Werner Lemberg committed
180
181
  /* called when an invalid glyph index is detected */
#define FT_INVALID_GLYPH_ID   FT_INVALID( FT_Err_Invalid_Glyph_Index )
182

Werner Lemberg's avatar
   
Werner Lemberg committed
183
184
  /* called when an invalid field value is detected */
#define FT_INVALID_DATA       FT_INVALID( FT_Err_Invalid_Table )
185
186
187
188
189
190
191
192
193
194
195
196
197
198


  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /****                                                                 ****/
  /****                                                                 ****/
  /****                       C H A R M A P S                           ****/
  /****                                                                 ****/
  /****                                                                 ****/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/

Werner Lemberg's avatar
   
Werner Lemberg committed
199
  /* handle to internal charmap object */
200
  typedef struct FT_CMapRec_*              FT_CMap;
201

Werner Lemberg's avatar
   
Werner Lemberg committed
202
203
  /* handle to charmap class structure */
  typedef const struct FT_CMap_ClassRec_*  FT_CMap_Class;
204

Werner Lemberg's avatar
   
Werner Lemberg committed
205
206
  /* internal charmap object structure */
  typedef struct  FT_CMapRec_
207
208
209
  {
    FT_CharMapRec  charmap;
    FT_CMap_Class  clazz;
210

211
212
  } FT_CMapRec;

Werner Lemberg's avatar
   
Werner Lemberg committed
213
214
215
216
217
218
219
220
  /* typecase any pointer to a charmap handle */
#define FT_CMAP( x )              ((FT_CMap)( x ))

  /* obvious macros */
#define FT_CMAP_PLATFORM_ID( x )  FT_CMAP( x )->charmap.platform_id
#define FT_CMAP_ENCODING_ID( x )  FT_CMAP( x )->charmap.encoding_id
#define FT_CMAP_ENCODING( x )     FT_CMAP( x )->charmap.encoding
#define FT_CMAP_FACE( x )         FT_CMAP( x )->charmap.face
221
222


Werner Lemberg's avatar
   
Werner Lemberg committed
223
224
225
226
  /* class method definitions */
  typedef FT_Error
  (*FT_CMap_InitFunc)( FT_CMap     cmap,
                       FT_Pointer  init_data );
227

Werner Lemberg's avatar
   
Werner Lemberg committed
228
229
  typedef void
  (*FT_CMap_DoneFunc)( FT_CMap  cmap );
230

Werner Lemberg's avatar
   
Werner Lemberg committed
231
232
233
  typedef FT_UInt
  (*FT_CMap_CharIndexFunc)( FT_CMap    cmap,
                            FT_UInt32  char_code );
234

Werner Lemberg's avatar
   
Werner Lemberg committed
235
236
237
  typedef FT_UInt
  (*FT_CMap_CharNextFunc)( FT_CMap     cmap,
                           FT_UInt32  *achar_code );
238
239


Werner Lemberg's avatar
   
Werner Lemberg committed
240
  typedef struct  FT_CMap_ClassRec_
241
  {
Werner Lemberg's avatar
   
Werner Lemberg committed
242
    FT_ULong               size;
243
244
245
246
    FT_CMap_InitFunc       init;
    FT_CMap_DoneFunc       done;
    FT_CMap_CharIndexFunc  char_index;
    FT_CMap_CharNextFunc   char_next;
247

248
249
250
  } FT_CMap_ClassRec;


Werner Lemberg's avatar
   
Werner Lemberg committed
251
  /* create a new charmap and add it to charmap->face */
252
253
  FT_BASE( FT_Error )
  FT_CMap_New( FT_CMap_Class  clazz,
254
               FT_Pointer     init_data,
255
256
257
               FT_CharMap     charmap,
               FT_CMap       *acmap );

Werner Lemberg's avatar
   
Werner Lemberg committed
258
  /* destroy a charmap (don't remove it from face's list though) */
259
260
261
262
  FT_BASE( void )
  FT_CMap_Done( FT_CMap  cmap );


263
264
265
266
267
268
  /*************************************************************************/
  /*                                                                       */
  /* <Struct>                                                              */
  /*    FT_Face_InternalRec                                                */
  /*                                                                       */
  /* <Description>                                                         */
Werner Lemberg's avatar
   
Werner Lemberg committed
269
270
271
  /*    This structure contains the internal fields of each FT_Face        */
  /*    object.  These fields may change between different releases of     */
  /*    FreeType.                                                          */
272
273
  /*                                                                       */
  /* <Fields>                                                              */
Werner Lemberg's avatar
   
Werner Lemberg committed
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
  /*    max_points       :: The maximal number of points used to store the */
  /*                        vectorial outline of any glyph in this face.   */
  /*                        If this value cannot be known in advance, or   */
  /*                        if the face isn't scalable, this should be set */
  /*                        to 0.  Only relevant for scalable formats.     */
  /*                                                                       */
  /*    max_contours     :: The maximal number of contours used to store   */
  /*                        the vectorial outline of any glyph in this     */
  /*                        face.  If this value cannot be known in        */
  /*                        advance, or if the face isn't scalable, this   */
  /*                        should be set to 0.  Only relevant for         */
  /*                        scalable formats.                              */
  /*                                                                       */
  /*    transform_matrix :: A 2x2 matrix of 16.16 coefficients used to     */
  /*                        transform glyph outlines after they are loaded */
  /*                        from the font.  Only used by the convenience   */
  /*                        functions.                                     */
  /*                                                                       */
  /*    transform_delta  :: A translation vector used to transform glyph   */
  /*                        outlines after they are loaded from the font.  */
  /*                        Only used by the convenience functions.        */
  /*                                                                       */
  /*    transform_flags  :: Some flags used to classify the transform.     */
  /*                        Only used by the convenience functions.        */
  /*                                                                       */
299
300
  /*    postscript_name  :: Postscript font name for this face.            */
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
301
302
  /*    incremental_interface ::                                           */
  /*                        If non-null, the interface through             */
303
304
305
  /*                        which glyph data and metrics are loaded        */
  /*                        incrementally for faces that do not provide    */
  /*                        all of this data when first opened.            */
Werner Lemberg's avatar
   
Werner Lemberg committed
306
  /*                        This field exists only if                      */
307
308
  /*                        @FT_CONFIG_OPTION_INCREMENTAL is defined.      */
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
309
  typedef struct  FT_Face_InternalRec_
310
  {
311
312
313
314
315
316
    FT_UShort    max_points;
    FT_Short     max_contours;

    FT_Matrix    transform_matrix;
    FT_Vector    transform_delta;
    FT_Int       transform_flags;
317

318
    const char*  postscript_name;
Werner Lemberg's avatar
   
Werner Lemberg committed
319

320
321
322
323
#ifdef FT_CONFIG_OPTION_INCREMENTAL
    FT_Incremental_InterfaceRec*  incremental_interface;
#endif

324
325
326
327
328
329
330
331
332
  } FT_Face_InternalRec;


  /*************************************************************************/
  /*                                                                       */
  /* <Struct>                                                              */
  /*    FT_Slot_InternalRec                                                */
  /*                                                                       */
  /* <Description>                                                         */
Werner Lemberg's avatar
   
Werner Lemberg committed
333
334
335
  /*    This structure contains the internal fields of each FT_GlyphSlot   */
  /*    object.  These fields may change between different releases of     */
  /*    FreeType.                                                          */
336
337
  /*                                                                       */
  /* <Fields>                                                              */
Werner Lemberg's avatar
   
Werner Lemberg committed
338
339
  /*    loader            :: The glyph loader object used to load outlines */
  /*                         into the glyph slot.                          */
340
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
341
342
343
344
345
  /*    flags             :: Possible values are zero or                   */
  /*                         FT_GLYPH_OWN_BITMAP.  The latter indicates    */
  /*                         that the FT_GlyphSlot structure owns the      */
  /*                         bitmap buffer.                                */
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
346
  /*    glyph_transformed :: Boolean.  Set to TRUE when the loaded glyph   */
347
  /*                         must be transformed through a specific        */
Werner Lemberg's avatar
   
Werner Lemberg committed
348
349
350
  /*                         font transformation.  This is _not_ the same  */
  /*                         as the face transform set through             */
  /*                         FT_Set_Transform().                           */
351
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
352
353
  /*    glyph_matrix      :: The 2x2 matrix corresponding to the glyph     */
  /*                         transformation, if necessary.                 */
354
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
355
356
  /*    glyph_delta       :: The 2d translation vector corresponding to    */
  /*                         the glyph transformation, if necessary.       */
357
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
358
  /*    glyph_hints       :: Format-specific glyph hints management.       */
359
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
360
361
362

#define FT_GLYPH_OWN_BITMAP  0x1

Werner Lemberg's avatar
   
Werner Lemberg committed
363
  typedef struct  FT_Slot_InternalRec_
364
  {
Werner Lemberg's avatar
   
Werner Lemberg committed
365
    FT_GlyphLoader  loader;
Werner Lemberg's avatar
   
Werner Lemberg committed
366
    FT_UInt         flags;
Werner Lemberg's avatar
   
Werner Lemberg committed
367
368
369
370
    FT_Bool         glyph_transformed;
    FT_Matrix       glyph_matrix;
    FT_Vector       glyph_delta;
    void*           glyph_hints;
371

372
  } FT_GlyphSlot_InternalRec;
373

Werner Lemberg's avatar
   
Werner Lemberg committed
374

David Turner's avatar
David Turner committed
375
376
377
378
379
380
381
382
383
384
385
386
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /****                                                                 ****/
  /****                                                                 ****/
  /****                         M O D U L E S                           ****/
  /****                                                                 ****/
  /****                                                                 ****/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/

Werner Lemberg's avatar
   
Werner Lemberg committed
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405

  /*************************************************************************/
  /*                                                                       */
  /* <Struct>                                                              */
  /*    FT_ModuleRec                                                       */
  /*                                                                       */
  /* <Description>                                                         */
  /*    A module object instance.                                          */
  /*                                                                       */
  /* <Fields>                                                              */
  /*    clazz   :: A pointer to the module's class.                        */
  /*                                                                       */
  /*    library :: A handle to the parent library object.                  */
  /*                                                                       */
  /*    memory  :: A handle to the memory manager.                         */
  /*                                                                       */
  /*    generic :: A generic structure for user-level extensibility (?).   */
  /*                                                                       */
  typedef struct  FT_ModuleRec_
David Turner's avatar
David Turner committed
406
407
408
409
410
  {
    FT_Module_Class*  clazz;
    FT_Library        library;
    FT_Memory         memory;
    FT_Generic        generic;
Werner Lemberg's avatar
   
Werner Lemberg committed
411

David Turner's avatar
David Turner committed
412
413
  } FT_ModuleRec;

Werner Lemberg's avatar
   
Werner Lemberg committed
414

David Turner's avatar
David Turner committed
415
  /* typecast an object to a FT_Module */
Werner Lemberg's avatar
   
Werner Lemberg committed
416
417
418
419
420
#define FT_MODULE( x )          ((FT_Module)( x ))
#define FT_MODULE_CLASS( x )    FT_MODULE( x )->clazz
#define FT_MODULE_LIBRARY( x )  FT_MODULE( x )->library
#define FT_MODULE_MEMORY( x )   FT_MODULE( x )->memory

421

Werner Lemberg's avatar
   
Werner Lemberg committed
422
#define FT_MODULE_IS_DRIVER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
Werner Lemberg's avatar
   
Werner Lemberg committed
423
                                    FT_MODULE_FONT_DRIVER )
David Turner's avatar
David Turner committed
424

Werner Lemberg's avatar
   
Werner Lemberg committed
425
#define FT_MODULE_IS_RENDERER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
Werner Lemberg's avatar
   
Werner Lemberg committed
426
                                      FT_MODULE_RENDERER )
David Turner's avatar
David Turner committed
427

Werner Lemberg's avatar
   
Werner Lemberg committed
428
#define FT_MODULE_IS_HINTER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
Werner Lemberg's avatar
   
Werner Lemberg committed
429
                                    FT_MODULE_HINTER )
430

Werner Lemberg's avatar
   
Werner Lemberg committed
431
#define FT_MODULE_IS_STYLER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
Werner Lemberg's avatar
   
Werner Lemberg committed
432
                                    FT_MODULE_STYLER )
433

Werner Lemberg's avatar
   
Werner Lemberg committed
434
#define FT_DRIVER_IS_SCALABLE( x )  ( FT_MODULE_CLASS( x )->module_flags & \
Werner Lemberg's avatar
   
Werner Lemberg committed
435
                                      FT_MODULE_DRIVER_SCALABLE )
David Turner's avatar
David Turner committed
436

Werner Lemberg's avatar
   
Werner Lemberg committed
437
#define FT_DRIVER_USES_OUTLINES( x )  !( FT_MODULE_CLASS( x )->module_flags & \
Werner Lemberg's avatar
   
Werner Lemberg committed
438
                                         FT_MODULE_DRIVER_NO_OUTLINES )
David Turner's avatar
David Turner committed
439

Werner Lemberg's avatar
   
Werner Lemberg committed
440
#define FT_DRIVER_HAS_HINTER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
Werner Lemberg's avatar
   
Werner Lemberg committed
441
                                     FT_MODULE_DRIVER_HAS_HINTER )
David Turner's avatar
David Turner committed
442

Werner Lemberg's avatar
   
Werner Lemberg committed
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FT_Get_Module_Interface                                            */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Finds a module and returns its specific interface as a typeless    */
  /*    pointer.                                                           */
  /*                                                                       */
  /* <Input>                                                               */
  /*    library     :: A handle to the library object.                     */
  /*                                                                       */
  /*    module_name :: The module's name (as an ASCII string).             */
  /*                                                                       */
  /* <Return>                                                              */
  /*    A module-specific interface if available, 0 otherwise.             */
  /*                                                                       */
  /* <Note>                                                                */
  /*    You should better be familiar with FreeType internals to know      */
  /*    which module to look for, and what its interface is :-)            */
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
465
466
467
  FT_BASE( const void* )
  FT_Get_Module_Interface( FT_Library   library,
                           const char*  mod_name );
Werner Lemberg's avatar
   
Werner Lemberg committed
468

469
470
 /* */

Werner Lemberg's avatar
   
Werner Lemberg committed
471

David Turner's avatar
David Turner committed
472
473
474
475
476
477
478
479
480
481
482
483
484
485
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /****                                                                 ****/
  /****                                                                 ****/
  /****               FACE, SIZE & GLYPH SLOT OBJECTS                   ****/
  /****                                                                 ****/
  /****                                                                 ****/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/

  /* a few macros used to perform easy typecasts with minimal brain damage */

Werner Lemberg's avatar
   
Werner Lemberg committed
486
487
488
#define FT_FACE( x )          ((FT_Face)(x))
#define FT_SIZE( x )          ((FT_Size)(x))
#define FT_SLOT( x )          ((FT_GlyphSlot)(x))
Werner Lemberg's avatar
   
Werner Lemberg committed
489

Werner Lemberg's avatar
   
Werner Lemberg committed
490
491
492
#define FT_FACE_DRIVER( x )   FT_FACE( x )->driver
#define FT_FACE_LIBRARY( x )  FT_FACE_DRIVER( x )->root.library
#define FT_FACE_MEMORY( x )   FT_FACE( x )->memory
493
#define FT_FACE_STREAM( x )   FT_FACE( x )->stream
David Turner's avatar
David Turner committed
494

Werner Lemberg's avatar
   
Werner Lemberg committed
495
496
#define FT_SIZE_FACE( x )     FT_SIZE( x )->face
#define FT_SLOT_FACE( x )     FT_SLOT( x )->face
David Turner's avatar
David Turner committed
497

Werner Lemberg's avatar
   
Werner Lemberg committed
498
499
#define FT_FACE_SLOT( x )     FT_FACE( x )->glyph
#define FT_FACE_SIZE( x )     FT_FACE( x )->size
David Turner's avatar
David Turner committed
500

501

Werner Lemberg's avatar
   
Werner Lemberg committed
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FT_New_GlyphSlot                                                   */
  /*                                                                       */
  /* <Description>                                                         */
  /*    It is sometimes useful to have more than one glyph slot for a      */
  /*    given face object.  This function is used to create additional     */
  /*    slots.  All of them are automatically discarded when the face is   */
  /*    destroyed.                                                         */
  /*                                                                       */
  /* <Input>                                                               */
  /*    face  :: A handle to a parent face object.                         */
  /*                                                                       */
  /* <Output>                                                              */
  /*    aslot :: A handle to a new glyph slot object.                      */
  /*                                                                       */
  /* <Return>                                                              */
  /*    FreeType error code.  0 means success.                             */
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
522
523
524
  FT_BASE( FT_Error )
  FT_New_GlyphSlot( FT_Face        face,
                    FT_GlyphSlot  *aslot );
Werner Lemberg's avatar
   
Werner Lemberg committed
525

David Turner's avatar
David Turner committed
526

Werner Lemberg's avatar
   
Werner Lemberg committed
527
528
529
530
531
532
533
534
535
536
537
538
539
  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FT_Done_GlyphSlot                                                  */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Destroys a given glyph slot.  Remember however that all slots are  */
  /*    automatically destroyed with its parent.  Using this function is   */
  /*    not always mandatory.                                              */
  /*                                                                       */
  /* <Input>                                                               */
  /*    slot :: A handle to a target glyph slot.                           */
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
540
541
  FT_BASE( void )
  FT_Done_GlyphSlot( FT_GlyphSlot  slot );
David Turner's avatar
David Turner committed
542

543
 /* */
544

545
 /*
Werner Lemberg's avatar
Werner Lemberg committed
546
547
  * Free the bitmap of a given glyphslot when needed
  * (i.e., only when it was allocated with ft_glyphslot_alloc_bitmap).
548
549
550
  */
  FT_BASE( void )
  ft_glyphslot_free_bitmap( FT_GlyphSlot  slot );
551

Werner Lemberg's avatar
Werner Lemberg committed
552

553
 /*
Werner Lemberg's avatar
Werner Lemberg committed
554
  * Allocate a new bitmap buffer in a glyph slot.
555
556
557
558
559
  */
  FT_BASE( FT_Error )
  ft_glyphslot_alloc_bitmap( FT_GlyphSlot  slot,
                             FT_ULong      size );

Werner Lemberg's avatar
Werner Lemberg committed
560

561
 /*
Werner Lemberg's avatar
Werner Lemberg committed
562
563
  * Set the bitmap buffer in a glyph slot to a given pointer.
  * The buffer will not be freed by a later call to ft_glyphslot_free_bitmap.
564
565
  */
  FT_BASE( void )
Werner Lemberg's avatar
Werner Lemberg committed
566
  ft_glyphslot_set_bitmap( FT_GlyphSlot  slot,
567
                           FT_Byte*      buffer );
568

David Turner's avatar
David Turner committed
569

David Turner's avatar
David Turner committed
570
571
572
573
574
575
576
577
578
579
580
581
582
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /****                                                                 ****/
  /****                                                                 ****/
  /****                        R E N D E R E R S                        ****/
  /****                                                                 ****/
  /****                                                                 ****/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/


Werner Lemberg's avatar
   
Werner Lemberg committed
583
584
585
586
587
588
589
#define FT_RENDERER( x )      ((FT_Renderer)( x ))
#define FT_GLYPH( x )         ((FT_Glyph)( x ))
#define FT_BITMAP_GLYPH( x )  ((FT_BitmapGlyph)( x ))
#define FT_OUTLINE_GLYPH( x ) ((FT_OutlineGlyph)( x ))


  typedef struct  FT_RendererRec_
David Turner's avatar
David Turner committed
590
  {
Werner Lemberg's avatar
   
Werner Lemberg committed
591
592
593
594
595
596
597
598
    FT_ModuleRec            root;
    FT_Renderer_Class*      clazz;
    FT_Glyph_Format         glyph_format;
    FT_Glyph_Class          glyph_class;

    FT_Raster               raster;
    FT_Raster_Render_Func   raster_render;
    FT_Renderer_RenderFunc  render;
Werner Lemberg's avatar
   
Werner Lemberg committed
599

David Turner's avatar
David Turner committed
600
  } FT_RendererRec;
David Turner's avatar
David Turner committed
601

Werner Lemberg's avatar
   
Werner Lemberg committed
602

David Turner's avatar
David Turner committed
603
604
605
606
607
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /****                                                                 ****/
  /****                                                                 ****/
David Turner's avatar
David Turner committed
608
  /****                    F O N T   D R I V E R S                      ****/
David Turner's avatar
David Turner committed
609
610
611
612
613
614
  /****                                                                 ****/
  /****                                                                 ****/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/

Werner Lemberg's avatar
   
Werner Lemberg committed
615

David Turner's avatar
David Turner committed
616
  /* typecast a module into a driver easily */
Werner Lemberg's avatar
   
Werner Lemberg committed
617
#define FT_DRIVER( x )        ((FT_Driver)(x))
David Turner's avatar
David Turner committed
618
619

  /* typecast a module as a driver, and get its driver class */
Werner Lemberg's avatar
   
Werner Lemberg committed
620
621
#define FT_DRIVER_CLASS( x )  FT_DRIVER( x )->clazz

David Turner's avatar
David Turner committed
622

David Turner's avatar
David Turner committed
623
624
625
626
627
628
629
630
631
632
  /*************************************************************************/
  /*                                                                       */
  /* <Struct>                                                              */
  /*    FT_DriverRec                                                       */
  /*                                                                       */
  /* <Description>                                                         */
  /*    The root font driver class.  A font driver is responsible for      */
  /*    managing and loading font files of a given format.                 */
  /*                                                                       */
  /*  <Fields>                                                             */
Werner Lemberg's avatar
   
Werner Lemberg committed
633
  /*     root         :: Contains the fields of the root module class.     */
David Turner's avatar
David Turner committed
634
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
635
636
637
  /*     clazz        :: A pointer to the font driver's class.  Note that  */
  /*                     this is NOT root.clazz.  `class' wasn't used      */
  /*                     as it is a reserved word in C++.                  */
David Turner's avatar
David Turner committed
638
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
639
640
  /*     faces_list   :: The list of faces currently opened by this        */
  /*                     driver.                                           */
David Turner's avatar
David Turner committed
641
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
642
643
644
  /*     extensions   :: A typeless pointer to the driver's extensions     */
  /*                     registry, if they are supported through the       */
  /*                     configuration macro FT_CONFIG_OPTION_EXTENSIONS.  */
David Turner's avatar
David Turner committed
645
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
646
647
648
  /*     glyph_loader :: The glyph loader for all faces managed by this    */
  /*                     driver.  This object isn't defined for unscalable */
  /*                     formats.                                          */
David Turner's avatar
David Turner committed
649
  /*                                                                       */
David Turner's avatar
David Turner committed
650
651
  typedef struct  FT_DriverRec_
  {
Werner Lemberg's avatar
   
Werner Lemberg committed
652
653
    FT_ModuleRec     root;
    FT_Driver_Class  clazz;
Werner Lemberg's avatar
   
Werner Lemberg committed
654

Werner Lemberg's avatar
   
Werner Lemberg committed
655
656
    FT_ListRec       faces_list;
    void*            extensions;
Werner Lemberg's avatar
   
Werner Lemberg committed
657

Werner Lemberg's avatar
   
Werner Lemberg committed
658
    FT_GlyphLoader   glyph_loader;
David Turner's avatar
David Turner committed
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674

  } FT_DriverRec;


  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/
  /****                                                                 ****/
  /****                                                                 ****/
  /****                       L I B R A R I E S                         ****/
  /****                                                                 ****/
  /****                                                                 ****/
  /*************************************************************************/
  /*************************************************************************/
  /*************************************************************************/

Werner Lemberg's avatar
   
Werner Lemberg committed
675

676
677
678
679
680
681
682
683
684
685
686
687
/* this hook is used by the TrueType debugger. It must be set to an alternate
 * truetype bytecode interpreter function
 */
#define FT_DEBUG_HOOK_TRUETYPE            0


/* set this debug hook to a non-null pointer to force unpatented hinting
 * for all faces when both TT_CONFIG_OPTION_BYTECODE_INTERPRETER and
 * TT_CONFIG_OPTION_UNPATENTED_HINTING are defined. this is only used
 * during debugging
 */
#define FT_DEBUG_HOOK_UNPATENTED_HINTING  1
David Turner's avatar
David Turner committed
688

Werner Lemberg's avatar
   
Werner Lemberg committed
689

David Turner's avatar
David Turner committed
690
691
692
693
694
695
696
697
698
699
700
  /*************************************************************************/
  /*                                                                       */
  /* <Struct>                                                              */
  /*    FT_LibraryRec                                                      */
  /*                                                                       */
  /* <Description>                                                         */
  /*    The FreeType library class.  This is the root of all FreeType      */
  /*    data.  Use FT_New_Library() to create a library object, and        */
  /*    FT_Done_Library() to discard it and all child objects.             */
  /*                                                                       */
  /* <Fields>                                                              */
Werner Lemberg's avatar
   
Werner Lemberg committed
701
702
  /*    memory           :: The library's memory object.  Manages memory   */
  /*                        allocation.                                    */
David Turner's avatar
David Turner committed
703
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
704
705
  /*    generic          :: Client data variable.  Used to extend the      */
  /*                        Library class by higher levels and clients.    */
David Turner's avatar
David Turner committed
706
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
707
708
709
710
  /*    num_modules      :: The number of modules currently registered     */
  /*                        within this library.  This is set to 0 for new */
  /*                        libraries.  New modules are added through the  */
  /*                        FT_Add_Module() API function.                  */
David Turner's avatar
David Turner committed
711
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
712
713
714
  /*    modules          :: A table used to store handles to the currently */
  /*                        registered modules. Note that each font driver */
  /*                        contains a list of its opened faces.           */
David Turner's avatar
David Turner committed
715
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
716
717
  /*    renderers        :: The list of renderers currently registered     */
  /*                        within the library.                            */
David Turner's avatar
David Turner committed
718
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
719
720
721
722
  /*    cur_renderer     :: The current outline renderer.  This is a       */
  /*                        shortcut used to avoid parsing the list on     */
  /*                        each call to FT_Outline_Render().  It is a     */
  /*                        handle to the current renderer for the         */
723
  /*                        FT_GLYPH_FORMAT_OUTLINE format.                */
David Turner's avatar
David Turner committed
724
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
725
  /*    auto_hinter      :: XXX                                            */
726
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
727
728
  /*    raster_pool      :: The raster object's render pool.  This can     */
  /*                        ideally be changed dynamically at run-time.    */
David Turner's avatar
David Turner committed
729
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
730
  /*    raster_pool_size :: The size of the render pool in bytes.          */
David Turner's avatar
David Turner committed
731
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
732
  /*    debug_hooks      :: XXX                                            */
733
  /*                                                                       */
David Turner's avatar
David Turner committed
734
735
  typedef struct  FT_LibraryRec_
  {
Werner Lemberg's avatar
   
Werner Lemberg committed
736
    FT_Memory          memory;           /* library's memory manager */
David Turner's avatar
David Turner committed
737

Werner Lemberg's avatar
   
Werner Lemberg committed
738
    FT_Generic         generic;
David Turner's avatar
David Turner committed
739

740
741
742
743
    FT_Int             version_major;
    FT_Int             version_minor;
    FT_Int             version_patch;

Werner Lemberg's avatar
   
Werner Lemberg committed
744
745
    FT_UInt            num_modules;
    FT_Module          modules[FT_MAX_MODULES];  /* module objects  */
David Turner's avatar
David Turner committed
746

Werner Lemberg's avatar
   
Werner Lemberg committed
747
748
749
    FT_ListRec         renderers;        /* list of renderers        */
    FT_Renderer        cur_renderer;     /* current outline renderer */
    FT_Module          auto_hinter;
David Turner's avatar
David Turner committed
750

Werner Lemberg's avatar
   
Werner Lemberg committed
751
    FT_Byte*           raster_pool;      /* scan-line conversion */
Werner Lemberg's avatar
   
Werner Lemberg committed
752
                                         /* render pool          */
Werner Lemberg's avatar
   
Werner Lemberg committed
753
    FT_ULong           raster_pool_size; /* size of render pool in bytes */
David Turner's avatar
David Turner committed
754

Werner Lemberg's avatar
   
Werner Lemberg committed
755
    FT_DebugHook_Func  debug_hooks[4];
David Turner's avatar
David Turner committed
756

757
758
    FT_MetaClassRec    meta_class;

David Turner's avatar
David Turner committed
759
760
761
  } FT_LibraryRec;


Werner Lemberg's avatar
   
Werner Lemberg committed
762
763
764
765
  FT_BASE( FT_Renderer )
  FT_Lookup_Renderer( FT_Library       library,
                      FT_Glyph_Format  format,
                      FT_ListNode*     node );
766

Werner Lemberg's avatar
   
Werner Lemberg committed
767
  FT_BASE( FT_Error )
Werner Lemberg's avatar
   
Werner Lemberg committed
768
769
770
  FT_Render_Glyph_Internal( FT_Library      library,
                            FT_GlyphSlot    slot,
                            FT_Render_Mode  render_mode );
771

772
  typedef const char*
773
  (*FT_Face_GetPostscriptNameFunc)( FT_Face  face );
774

Werner Lemberg's avatar
   
Werner Lemberg committed
775
  typedef FT_Error
776
777
778
779
  (*FT_Face_GetGlyphNameFunc)( FT_Face     face,
                               FT_UInt     glyph_index,
                               FT_Pointer  buffer,
                               FT_UInt     buffer_max );
780

781
  typedef FT_UInt
782
783
  (*FT_Face_GetGlyphNameIndexFunc)( FT_Face     face,
                                    FT_String*  glyph_name );
784

David Turner's avatar
David Turner committed
785
786
787

#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM

Werner Lemberg's avatar
   
Werner Lemberg committed
788
789
790
791
792
793
794
795
796
797
798
  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FT_New_Memory                                                      */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Creates a new memory object.                                       */
  /*                                                                       */
  /* <Return>                                                              */
  /*    A pointer to the new memory object.  0 in case of error.           */
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
799
800
  FT_EXPORT( FT_Memory )
  FT_New_Memory( void );
David Turner's avatar
David Turner committed
801

Werner Lemberg's avatar
   
Werner Lemberg committed
802
803
804
805
806
807
808
809
810
811
812
813

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FT_Done_Memory                                                     */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Discards memory manager.                                           */
  /*                                                                       */
  /* <Input>                                                               */
  /*    memory :: A handle to the memory manager.                          */
  /*                                                                       */
Werner Lemberg's avatar
   
Werner Lemberg committed
814
815
  FT_EXPORT( void )
  FT_Done_Memory( FT_Memory  memory );
David Turner's avatar
David Turner committed
816

Werner Lemberg's avatar
   
Werner Lemberg committed
817
818
819
820
#endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */


  /* Define default raster's interface.  The default raster is located in  */
Werner Lemberg's avatar
   
Werner Lemberg committed
821
  /* `src/base/ftraster.c'.                                                */
Werner Lemberg's avatar
   
Werner Lemberg committed
822
823
824
825
  /*                                                                       */
  /* Client applications can register new rasters through the              */
  /* FT_Set_Raster() API.                                                  */

David Turner's avatar
David Turner committed
826
#ifndef FT_NO_DEFAULT_RASTER
Werner Lemberg's avatar
   
Werner Lemberg committed
827
  FT_EXPORT_VAR( FT_Raster_Funcs )  ft_default_raster;
David Turner's avatar
David Turner committed
828
829
830
#endif


831
FT_END_HEADER
Werner Lemberg's avatar
   
Werner Lemberg committed
832

833
#endif /* __FTOBJS_H__ */
David Turner's avatar
David Turner committed
834
835
836


/* END */