:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / subsys / win32k / freetype / include / freetype / internal / ftobjs.h
1 /***************************************************************************/
2 /*                                                                         */
3 /*  ftobjs.h                                                               */
4 /*                                                                         */
5 /*    The FreeType private base classes (specification).                   */
6 /*                                                                         */
7 /*  Copyright 1996-2000 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   /*************************************************************************/
20   /*                                                                       */
21   /*  This file contains the definition of all internal FreeType classes.  */
22   /*                                                                       */
23   /*************************************************************************/
24
25
26 #ifndef FTOBJS_H
27 #define FTOBJS_H
28
29 #include <freetype/internal/ftmemory.h>
30 #include <freetype/ftrender.h>
31 #include <freetype/internal/ftdriver.h>
32 #include <freetype/internal/autohint.h>
33
34
35 #ifdef __cplusplus
36   extern "C" {
37 #endif
38
39
40   /*************************************************************************/
41   /*                                                                       */
42   /* Some generic definitions.                                             */
43   /*                                                                       */
44 #ifndef TRUE
45 #define TRUE  1
46 #endif
47
48 #ifndef FALSE
49 #define FALSE  0
50 #endif
51
52 #ifndef NULL
53 #define NULL  (void*)0
54 #endif
55
56 #ifndef UNUSED
57 #define UNUSED( arg )  ( (arg)=(arg) )
58 #endif
59
60
61   /*************************************************************************/
62   /*                                                                       */
63   /* The min and max functions missing in C.  As usual, be careful not to  */
64   /* write things like MIN( a++, b++ ) to avoid side effects.              */
65   /*                                                                       */
66 #ifndef MIN
67 #define MIN( a, b )  ( (a) < (b) ? (a) : (b) )
68 #endif
69
70 #ifndef MAX
71 #define MAX( a, b )  ( (a) > (b) ? (a) : (b) )
72 #endif
73
74 #ifndef ABS
75 #define ABS( a )     ( (a) < 0 ? -(a) : (a) )
76 #endif
77
78
79   /*************************************************************************/
80   /*************************************************************************/
81   /*************************************************************************/
82   /****                                                                 ****/
83   /****                                                                 ****/
84   /****                         M O D U L E S                           ****/
85   /****                                                                 ****/
86   /****                                                                 ****/
87   /*************************************************************************/
88   /*************************************************************************/
89   /*************************************************************************/
90
91
92   /*************************************************************************/
93   /*                                                                       */
94   /* <Struct>                                                              */
95   /*    FT_ModuleRec                                                       */
96   /*                                                                       */
97   /* <Description>                                                         */
98   /*    A module object instance.                                          */
99   /*                                                                       */
100   /* <Fields>                                                              */
101   /*    clazz   :: A pointer to the module's class.                        */
102   /*                                                                       */
103   /*    library :: A handle to the parent library object.                  */
104   /*                                                                       */
105   /*    memory  :: A handle to the memory manager.                         */
106   /*                                                                       */
107   /*    generic :: A generic structure for user-level extensibility (?).   */
108   /*                                                                       */
109   typedef struct  FT_ModuleRec_
110   {
111     FT_Module_Class*  clazz;
112     FT_Library        library;
113     FT_Memory         memory;
114     FT_Generic        generic;
115     
116   } FT_ModuleRec;
117
118
119   /* typecast an object to a FT_Module */
120 #define FT_MODULE( x )          ((FT_Module)(x))
121 #define FT_MODULE_CLASS( x )    FT_MODULE(x)->clazz
122 #define FT_MODULE_LIBRARY( x )  FT_MODULE(x)->library
123 #define FT_MODULE_MEMORY( x )   FT_MODULE(x)->memory
124
125 #define FT_MODULE_IS_DRIVER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
126                                     ft_module_font_driver )
127
128 #define FT_MODULE_IS_RENDERER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
129                                       ft_module_renderer )
130
131 #define FT_MODULE_IS_HINTER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
132                                     ft_module_hinter )
133
134 #define FT_MODULE_IS_STYLER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
135                                     ft_module_styler )
136
137 #define FT_DRIVER_IS_SCALABLE( x )  ( FT_MODULE_CLASS(x)->module_flags & \
138                                       ft_module_driver_scalable )
139
140 #define FT_DRIVER_USES_OUTLINES( x )  !( FT_MODULE_CLASS(x)->module_flags & \
141                                          ft_module_driver_no_outlines )
142
143 #define FT_DRIVER_HAS_HINTER( x )  ( FT_MODULE_CLASS(x)->module_flags & \
144                                      ft_module_driver_has_hinter )
145
146
147   /*************************************************************************/
148   /*                                                                       */
149   /* <Function>                                                            */
150   /*    FT_Get_Module_Interface                                            */
151   /*                                                                       */
152   /* <Description>                                                         */
153   /*    Finds a module and returns its specific interface as a typeless    */
154   /*    pointer.                                                           */
155   /*                                                                       */
156   /* <Input>                                                               */
157   /*    library     :: A handle to the library object.                     */
158   /*                                                                       */
159   /*    module_name :: The module's name (as an ASCII string).             */
160   /*                                                                       */
161   /* <Return>                                                              */
162   /*    A module-specific interface if available, 0 otherwise.             */
163   /*                                                                       */
164   /* <Note>                                                                */
165   /*    You should better be familiar with FreeType internals to know      */
166   /*    which module to look for, and what its interface is :-)            */
167   /*                                                                       */
168   BASE_DEF( const void* )  FT_Get_Module_Interface( FT_Library   library,
169                                                     const char*  mod_name );
170
171
172   /*************************************************************************/
173   /*************************************************************************/
174   /*************************************************************************/
175   /****                                                                 ****/
176   /****                                                                 ****/
177   /****               FACE, SIZE & GLYPH SLOT OBJECTS                   ****/
178   /****                                                                 ****/
179   /****                                                                 ****/
180   /*************************************************************************/
181   /*************************************************************************/
182   /*************************************************************************/
183
184   /* a few macros used to perform easy typecasts with minimal brain damage */
185
186 #define FT_FACE( x )          ((FT_Face)(x))
187 #define FT_SIZE( x )          ((FT_Size)(x))
188 #define FT_SLOT( x )          ((FT_GlyphSlot)(x))
189   
190 #define FT_FACE_DRIVER( x )   FT_FACE( x )->driver
191 #define FT_FACE_LIBRARY( x )  FT_FACE_DRIVER( x )->root.library
192 #define FT_FACE_MEMORY( x )   FT_FACE( x )->memory
193
194 #define FT_SIZE_FACE( x )     FT_SIZE( x )->face
195 #define FT_SLOT_FACE( x )     FT_SLOT( x )->face
196
197 #define FT_FACE_SLOT( x )     FT_FACE( x )->glyph
198 #define FT_FACE_SIZE( x )     FT_FACE( x )->size
199
200
201   /* this must be kept exported -- tt will be used later in our own */
202   /* high-level caching font manager called SemTex (way after the   */
203   /* 2.0 release though                                             */
204   FT_EXPORT_DEF( FT_Error )  FT_New_Size( FT_Face   face,
205                                           FT_Size*  size );
206
207   FT_EXPORT_DEF( FT_Error )  FT_Done_Size( FT_Size  size );
208
209
210   FT_EXPORT_DEF( FT_Error )  FT_New_GlyphSlot( FT_Face        face,
211                                                FT_GlyphSlot*  aslot );
212
213   FT_EXPORT_DEF( void )      FT_Done_GlyphSlot( FT_GlyphSlot  slot );
214
215
216   /*************************************************************************/
217   /*************************************************************************/
218   /*************************************************************************/
219   /****                                                                 ****/
220   /****                                                                 ****/
221   /****                   G L Y P H   L O A D E R                       ****/
222   /****                                                                 ****/
223   /****                                                                 ****/
224   /*************************************************************************/
225   /*************************************************************************/
226   /*************************************************************************/
227
228
229 #define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS          1
230 #define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES      2
231 #define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID        4
232 #define FT_SUBGLYPH_FLAG_SCALE                   8
233 #define FT_SUBGLYPH_FLAG_XY_SCALE             0x40
234 #define FT_SUBGLYPH_FLAG_2X2                  0x80
235 #define FT_SUBGLYPH_FLAG_USE_MY_METRICS      0x200
236
237
238   enum
239   {
240     ft_glyph_own_bitmap = 1
241   };
242
243
244   struct  FT_SubGlyph_
245   {
246     FT_Int     index;
247     FT_UShort  flags;
248     FT_Int     arg1;
249     FT_Int     arg2;
250     FT_Matrix  transform;
251   };
252
253
254   typedef struct  FT_GlyphLoad_
255   {
256     FT_Outline    outline;       /* outline             */
257     FT_UInt       num_subglyphs; /* number of subglyphs */
258     FT_SubGlyph*  subglyphs;     /* subglyphs           */
259     FT_Vector*    extra_points;  /* extra points table  */
260   
261   } FT_GlyphLoad;
262
263
264   struct  FT_GlyphLoader_
265   {
266     FT_Memory     memory;
267     FT_UInt       max_points;
268     FT_UInt       max_contours;
269     FT_UInt       max_subglyphs;
270     FT_Bool       use_extra;
271
272     FT_GlyphLoad  base;
273     FT_GlyphLoad  current;
274
275     void*         other;            /* for possible future extension? */
276     
277   };
278
279
280   BASE_DEF( FT_Error )  FT_GlyphLoader_New( FT_Memory         memory,
281                                             FT_GlyphLoader**  aloader );
282                                           
283   BASE_DEF( FT_Error )  FT_GlyphLoader_Create_Extra(
284                           FT_GlyphLoader*  loader );                                        
285   
286   BASE_DEF( void )  FT_GlyphLoader_Done( FT_GlyphLoader*  loader );
287   
288   BASE_DEF( void )  FT_GlyphLoader_Reset( FT_GlyphLoader*  loader );
289   
290   BASE_DEF( void )  FT_GlyphLoader_Rewind( FT_GlyphLoader*  loader );
291   
292   BASE_DEF( FT_Error )  FT_GlyphLoader_Check_Points(
293                           FT_GlyphLoader*  loader,
294                           FT_UInt          n_points,
295                           FT_UInt          n_contours );
296                                
297   BASE_DEF( FT_Error )  FT_GlyphLoader_Check_Subglyphs(
298                           FT_GlyphLoader*  loader,
299                           FT_UInt          n_subs );
300
301   BASE_DEF( void )  FT_GlyphLoader_Prepare( FT_GlyphLoader*  loader );
302
303   BASE_DEF( void )  FT_GlyphLoader_Add( FT_GlyphLoader*  loader );
304
305   BASE_DEF( FT_Error )  FT_GlyphLoader_Copy_Points( FT_GlyphLoader*  target,
306                                                     FT_GlyphLoader*  source );
307
308
309   /*************************************************************************/
310   /*************************************************************************/
311   /*************************************************************************/
312   /****                                                                 ****/
313   /****                                                                 ****/
314   /****                        R E N D E R E R S                        ****/
315   /****                                                                 ****/
316   /****                                                                 ****/
317   /*************************************************************************/
318   /*************************************************************************/
319   /*************************************************************************/
320
321
322 #define FT_RENDERER( x )      ((FT_Renderer)( x ))
323 #define FT_GLYPH( x )         ((FT_Glyph)( x ))
324 #define FT_BITMAP_GLYPH( x )  ((FT_BitmapGlyph)( x ))
325 #define FT_OUTLINE_GLYPH( x ) ((FT_OutlineGlyph)( x ))
326
327
328   typedef struct  FT_RendererRec_
329   {
330     FT_ModuleRec           root;
331     FT_Renderer_Class*     clazz;
332     FT_Glyph_Format        glyph_format;
333     const FT_Glyph_Class   glyph_class;
334
335     FT_Raster              raster;
336     FT_Raster_Render_Func  raster_render;
337     FTRenderer_render      render;
338   
339   } FT_RendererRec;
340
341
342   /*************************************************************************/
343   /*************************************************************************/
344   /*************************************************************************/
345   /****                                                                 ****/
346   /****                                                                 ****/
347   /****                    F O N T   D R I V E R S                      ****/
348   /****                                                                 ****/
349   /****                                                                 ****/
350   /*************************************************************************/
351   /*************************************************************************/
352   /*************************************************************************/
353
354
355   /* typecast a module into a driver easily */
356 #define FT_DRIVER( x )        ((FT_Driver)(x))
357
358   /* typecast a module as a driver, and get its driver class */
359 #define FT_DRIVER_CLASS( x )  FT_DRIVER( x )->clazz
360
361
362   /*************************************************************************/
363   /*                                                                       */
364   /* <Struct>                                                              */
365   /*    FT_DriverRec                                                       */
366   /*                                                                       */
367   /* <Description>                                                         */
368   /*    The root font driver class.  A font driver is responsible for      */
369   /*    managing and loading font files of a given format.                 */
370   /*                                                                       */
371   /*  <Fields>                                                             */
372   /*     root         :: Contains the fields of the root module class.     */
373   /*                                                                       */
374   /*     clazz        :: A pointer to the font driver's class.  Note that  */
375   /*                     this is NOT root.clazz.  `class' wasn't used      */
376   /*                     as it is a reserved word in C++.                  */
377   /*                                                                       */
378   /*     faces_list   :: The list of faces currently opened by this        */
379   /*                     driver.                                           */
380   /*                                                                       */
381   /*     extensions   :: A typeless pointer to the driver's extensions     */
382   /*                     registry, if they are supported through the       */
383   /*                     configuration macro FT_CONFIG_OPTION_EXTENSIONS.  */
384   /*                                                                       */
385   /*     glyph_loader :: The glyph loader for all faces managed by this    */
386   /*                     driver.  This object isn't defined for unscalable */
387   /*                     formats.                                          */
388   /*                                                                       */
389   typedef struct  FT_DriverRec_
390   {
391     FT_ModuleRec      root;
392     FT_Driver_Class*  clazz;
393     
394     FT_ListRec        faces_list;
395     void*             extensions;
396     
397     FT_GlyphLoader*   glyph_loader;
398
399   } FT_DriverRec;
400
401
402   /*************************************************************************/
403   /*************************************************************************/
404   /*************************************************************************/
405   /****                                                                 ****/
406   /****                                                                 ****/
407   /****                       L I B R A R I E S                         ****/
408   /****                                                                 ****/
409   /****                                                                 ****/
410   /*************************************************************************/
411   /*************************************************************************/
412   /*************************************************************************/
413
414
415 #define FT_DEBUG_HOOK_TRUETYPE   0
416 #define FT_DEBUG_HOOK_TYPE1      1
417
418
419   /*************************************************************************/
420   /*                                                                       */
421   /* <Struct>                                                              */
422   /*    FT_LibraryRec                                                      */
423   /*                                                                       */
424   /* <Description>                                                         */
425   /*    The FreeType library class.  This is the root of all FreeType      */
426   /*    data.  Use FT_New_Library() to create a library object, and        */
427   /*    FT_Done_Library() to discard it and all child objects.             */
428   /*                                                                       */
429   /* <Fields>                                                              */
430   /*    memory           :: The library's memory object.  Manages memory   */
431   /*                        allocation.                                    */
432   /*                                                                       */
433   /*    generic          :: Client data variable.  Used to extend the      */
434   /*                        Library class by higher levels and clients.    */
435   /*                                                                       */
436   /*    num_modules      :: The number of modules currently registered     */
437   /*                        within this library.  This is set to 0 for new */
438   /*                        libraries.  New modules are added through the  */
439   /*                        FT_Add_Module() API function.                  */
440   /*                                                                       */
441   /*    modules          :: A table used to store handles to the currently */
442   /*                        registered modules. Note that each font driver */
443   /*                        contains a list of its opened faces.           */
444   /*                                                                       */
445   /*    renderers        :: The list of renderers currently registered     */
446   /*                        within the library.                            */
447   /*                                                                       */
448   /*    cur_renderer     :: The current outline renderer.  This is a       */
449   /*                        shortcut used to avoid parsing the list on     */
450   /*                        each call to FT_Outline_Render().  It is a     */
451   /*                        handle to the current renderer for the         */
452   /*                        ft_glyph_format_outline format.                */
453   /*                                                                       */
454   /*    auto_hinter      :: XXX                                            */
455   /*                                                                       */
456   /*    raster_pool      :: The raster object's render pool.  This can     */
457   /*                        ideally be changed dynamically at run-time.    */
458   /*                                                                       */
459   /*    raster_pool_size :: The size of the render pool in bytes.          */
460   /*                                                                       */
461   /*    debug_hooks      :: XXX                                            */
462   /*                                                                       */
463   typedef struct  FT_LibraryRec_
464   {
465     FT_Memory           memory;           /* library's memory manager */
466
467     FT_Generic          generic;
468
469     FT_UInt             num_modules;
470     FT_Module           modules[FT_MAX_MODULES];  /* module objects  */
471
472     FT_ListRec          renderers;        /* list of renderers        */
473     FT_Renderer         cur_renderer;     /* current outline renderer */
474     FT_Module           auto_hinter;
475
476     FT_Byte*            raster_pool;      /* scan-line conversion */
477                                           /* render pool          */
478     FT_ULong            raster_pool_size; /* size of render pool in bytes */
479
480     FT_DebugHook_Func   debug_hooks[4];
481
482   } FT_LibraryRec;
483
484
485   BASE_DEF( FT_Renderer )  FT_Lookup_Renderer( FT_Library       library,
486                                                FT_Glyph_Format  format,
487                                                FT_ListNode*     node );
488
489   BASE_DEF( FT_Error )  FT_Render_Glyph_Internal( FT_Library    library,
490                                                   FT_GlyphSlot  slot,
491                                                   FT_UInt       render_mode );
492
493   typedef FT_Error  (*FT_Glyph_Name_Requester)( FT_Face     face,
494                                                 FT_UInt     glyph_index,
495                                                 FT_Pointer  buffer,
496                                                 FT_UInt     buffer_max );
497
498
499 #ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
500
501
502   FT_EXPORT_DEF( FT_Error )   FT_New_Stream( const char*  filepathname,
503                                              FT_Stream    astream );
504
505   FT_EXPORT_DEF( void )       FT_Done_Stream( FT_Stream  stream );
506
507   FT_EXPORT_DEF( FT_Memory )  FT_New_Memory( void );
508
509
510 #endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */
511
512
513   /* Define default raster's interface.  The default raster is located in  */
514   /* `src/base/ftraster.c'                                                 */
515   /*                                                                       */
516   /* Client applications can register new rasters through the              */
517   /* FT_Set_Raster() API.                                                  */
518
519 #ifndef FT_NO_DEFAULT_RASTER
520   FT_EXPORT_VAR( FT_Raster_Funcs )  ft_default_raster;
521 #endif
522
523
524 #ifdef __cplusplus
525   }
526 #endif
527
528
529 #endif /* FTOBJS_H */
530
531
532 /* END */