:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / subsys / win32k / freetype / include / freetype / internal / sfnt.h
1 /***************************************************************************/
2 /*                                                                         */
3 /*  sfnt.h                                                                 */
4 /*                                                                         */
5 /*    High-level `sfnt' driver interface (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 #ifndef SFNT_H
20 #define SFNT_H
21
22
23 #include <freetype/freetype.h>
24 #include <freetype/internal/ftdriver.h>
25 #include <freetype/internal/tttypes.h>
26
27
28   /*************************************************************************/
29   /*                                                                       */
30   /* <FuncType>                                                            */
31   /*    TT_Init_Face_Func                                                  */
32   /*                                                                       */
33   /* <Description>                                                         */
34   /*    First part of the SFNT face object initialization.  This will find */
35   /*    the face in a SFNT file or collection, and load its format tag in  */
36   /*    face->format_tag.                                                  */
37   /*                                                                       */
38   /* <Input>                                                               */
39   /*    stream     :: The input stream.                                    */
40   /*                                                                       */
41   /*    face       :: A handle to the target face object.                  */
42   /*                                                                       */
43   /*    face_index :: The index of the TrueType font, if we are opening a  */
44   /*                  collection.                                          */
45   /*                                                                       */
46   /*    num_params :: The number of additional parameters.                 */
47   /*                                                                       */
48   /*    params     :: Optional additional parameters.                      */
49   /*                                                                       */
50   /* <Return>                                                              */
51   /*    FreeType error code.  0 means success.                             */
52   /*                                                                       */
53   /* <Note>                                                                */
54   /*    The stream cursor must be at the font file's origin.               */
55   /*                                                                       */
56   /*    This function recognizes fonts embedded in a `TrueType             */
57   /*    collection'.                                                       */
58   /*                                                                       */
59   /*    Once the format tag has been validated by the font driver, it      */
60   /*    should then call the TT_Load_Face_Func() callback to read the rest */
61   /*    of the SFNT tables in the object.                                  */
62   /*                                                                       */
63   typedef
64   FT_Error  (*TT_Init_Face_Func)( FT_Stream      stream,
65                                   TT_Face        face,
66                                   FT_Int         face_index,
67                                   FT_Int         num_params,
68                                   FT_Parameter*  params );
69
70
71   /*************************************************************************/
72   /*                                                                       */
73   /* <FuncType>                                                            */
74   /*    TT_Load_Face_Func                                                  */
75   /*                                                                       */
76   /* <Description>                                                         */
77   /*    Second part of the SFNT face object initialization.  This will     */
78   /*    load the common SFNT tables (head, OS/2, maxp, metrics, etc.) in   */
79   /*    the face object.                                                   */
80   /*                                                                       */
81   /* <Input>                                                               */
82   /*    stream     :: The input stream.                                    */
83   /*                                                                       */
84   /*    face       :: A handle to the target face object.                  */
85   /*                                                                       */
86   /*    face_index :: The index of the TrueType font, if we are opening a  */
87   /*                  collection.                                          */
88   /*                                                                       */
89   /*    num_params :: The number of additional parameters.                 */
90   /*                                                                       */
91   /*    params     :: Optional additional parameters.                      */
92   /*                                                                       */
93   /* <Return>                                                              */
94   /*    FreeType error code.  0 means success.                             */
95   /*                                                                       */
96   /* <Note>                                                                */
97   /*    This function must be called after TT_Init_Face_Func().            */
98   /*                                                                       */
99   typedef
100   FT_Error  (*TT_Load_Face_Func)( FT_Stream      stream,
101                                   TT_Face        face,
102                                   FT_Int         face_index,
103                                   FT_Int         num_params,
104                                   FT_Parameter*  params );
105
106
107   /*************************************************************************/
108   /*                                                                       */
109   /* <FuncType>                                                            */
110   /*    TT_Done_Face_Func                                                  */
111   /*                                                                       */
112   /* <Description>                                                         */
113   /*    A callback used to delete the common SFNT data from a face.        */
114   /*                                                                       */
115   /* <Input>                                                               */
116   /*    face :: A handle to the target face object.                        */
117   /*                                                                       */
118   /* <Note>                                                                */
119   /*    This function does NOT destroy the face object.                    */
120   /*                                                                       */
121   typedef
122   void  (*TT_Done_Face_Func)( TT_Face  face );
123
124
125   typedef
126   FT_Module_Interface  (*SFNT_Get_Interface_Func)( FT_Module    module,
127                                                    const char*  interface );
128
129
130   /*************************************************************************/
131   /*                                                                       */
132   /* <FuncType>                                                            */
133   /*    TT_Load_SFNT_Header_Func                                           */
134   /*                                                                       */
135   /* <Description>                                                         */
136   /*    Loads the header of a SFNT font file.  Supports collections.       */
137   /*                                                                       */
138   /* <Input>                                                               */
139   /*    face       :: A handle to the target face object.                  */
140   /*                                                                       */
141   /*    stream     :: The input stream.                                    */
142   /*                                                                       */
143   /*    face_index :: The index of the TrueType font, if we are opening a  */
144   /*                  collection.                                          */
145   /*                                                                       */
146   /* <Output>                                                              */
147   /*    sfnt       :: The SFNT header.                                     */
148   /*                                                                       */
149   /* <Return>                                                              */
150   /*    FreeType error code.  0 means success.                             */
151   /*                                                                       */
152   /* <Note>                                                                */
153   /*    The stream cursor must be at the font file's origin.               */
154   /*                                                                       */
155   /*    This function recognizes fonts embedded in a `TrueType             */
156   /*    collection'.                                                       */
157   /*                                                                       */
158   /*    This function checks that the header is valid by looking at the    */
159   /*    values of `search_range', `entry_selector', and `range_shift'.     */
160   /*                                                                       */
161   typedef
162   FT_Error  (*TT_Load_SFNT_Header_Func)( TT_Face       face,
163                                          FT_Stream     stream,
164                                          FT_Long       face_index,
165                                          SFNT_Header*  sfnt );
166
167
168   /*************************************************************************/
169   /*                                                                       */
170   /* <FuncType>                                                            */
171   /*    TT_Load_Directory_Func                                             */
172   /*                                                                       */
173   /* <Description>                                                         */
174   /*    Loads the table directory into a face object.                      */
175   /*                                                                       */
176   /* <Input>                                                               */
177   /*    face      :: A handle to the target face object.                   */
178   /*                                                                       */
179   /*    stream    :: The input stream.                                     */
180   /*                                                                       */
181   /*    sfnt      :: The SFNT header.                                      */
182   /*                                                                       */
183   /* <Return>                                                              */
184   /*    FreeType error code.  0 means success.                             */
185   /*                                                                       */
186   /* <Note>                                                                */
187   /*    The stream cursor must be on the first byte after the 4-byte font  */
188   /*    format tag.  This is the case just after a call to                 */
189   /*    TT_Load_Format_Tag().                                              */
190   /*                                                                       */
191   typedef
192   FT_Error  (*TT_Load_Directory_Func)( TT_Face       face,
193                                        FT_Stream     stream,
194                                        SFNT_Header*  sfnt );
195
196
197   /*************************************************************************/
198   /*                                                                       */
199   /* <FuncType>                                                            */
200   /*    TT_Load_Any_Func                                                   */
201   /*                                                                       */
202   /* <Description>                                                         */
203   /*    Loads any font table into client memory.                           */
204   /*                                                                       */
205   /* <Input>                                                               */
206   /*    face   :: The face object to look for.                             */
207   /*                                                                       */
208   /*    tag    :: The tag of table to load.  Use the value 0 if you want   */
209   /*              to access the whole font file, else set this parameter   */
210   /*              to a valid TrueType table tag that you can forge with    */
211   /*              the MAKE_TT_TAG macro.                                   */
212   /*                                                                       */
213   /*    offset :: The starting offset in the table (or the file if         */
214   /*              tag == 0).                                               */
215   /*                                                                       */
216   /*    length :: The address of the decision variable:                    */
217   /*                                                                       */
218   /*                If length == NULL:                                     */
219   /*                  Loads the whole table.  Returns an error if          */
220   /*                  `offset' == 0!                                       */
221   /*                                                                       */
222   /*                If *length == 0:                                       */
223   /*                  Exits immediately; returning the length of the given */
224   /*                  table or of the font file, depending on the value of */
225   /*                  `tag'.                                               */
226   /*                                                                       */
227   /*                If *length != 0:                                       */
228   /*                  Loads the next `length' bytes of table or font,      */
229   /*                  starting at offset `offset' (in table or font too).  */
230   /*                                                                       */
231   /* <Output>                                                              */
232   /*    buffer :: The address of target buffer.                            */
233   /*                                                                       */
234   /* <Return>                                                              */
235   /*    TrueType error code.  0 means success.                             */
236   /*                                                                       */
237   typedef
238   FT_Error  (*TT_Load_Any_Func)( TT_Face    face,
239                                  FT_ULong   tag,
240                                  FT_Long    offset,
241                                  FT_Byte*   buffer,
242                                  FT_ULong*  length );
243
244
245   /*************************************************************************/
246   /*                                                                       */
247   /* <FuncType>                                                            */
248   /*    TT_Load_SBit_Image_Func                                            */
249   /*                                                                       */
250   /* <Description>                                                         */
251   /*    Loads a given glyph sbit image from the font resource.  This also  */
252   /*    returns its metrics.                                               */
253   /*                                                                       */
254   /* <Input>                                                               */
255   /*    face        :: The target face object.                             */
256   /*                                                                       */
257   /*    x_ppem      :: The horizontal resolution in points per EM.         */
258   /*                                                                       */
259   /*    y_ppem      :: The vertical resolution in points per EM.           */
260   /*                                                                       */
261   /*    glyph_index :: The current glyph index.                            */
262   /*                                                                       */
263   /*    stream      :: The input stream.                                   */
264   /*                                                                       */
265   /* <Output>                                                              */
266   /*    map         :: The target pixmap.                                  */
267   /*                                                                       */
268   /*    metrics     :: A big sbit metrics structure for the glyph image.   */
269   /*                                                                       */
270   /* <Return>                                                              */
271   /*    FreeType error code.  0 means success.  Returns an error if no     */
272   /*    glyph sbit exists for the index.                                   */
273   /*                                                                       */
274   /*  <Note>                                                               */
275   /*    The `map.buffer' field is always freed before the glyph is loaded. */
276   /*                                                                       */
277   typedef
278   FT_Error  (*TT_Load_SBit_Image_Func)( TT_Face           face,
279                                         FT_Int            x_ppem,
280                                         FT_Int            y_ppem,
281                                         FT_UInt           glyph_index,
282                                         FT_UInt           load_flags,
283                                         FT_Stream         stream,
284                                         FT_Bitmap*        map,
285                                         TT_SBit_Metrics*  metrics );
286
287
288   /*************************************************************************/
289   /*                                                                       */
290   /* <FuncType>                                                            */
291   /*    TT_Get_PS_Name_Func                                                */
292   /*                                                                       */
293   /* <Description>                                                         */
294   /*    Gets the PostScript glyph name of a glyph.                         */
295   /*                                                                       */
296   /* <Input>                                                               */
297   /*    index  :: The glyph index.                                         */
298   /*                                                                       */
299   /*    PSname :: The address of a string pointer.  Will be NULL in case   */
300   /*              of error, otherwise it is a pointer to the glyph name.   */
301   /*                                                                       */
302   /*              You must not modify the returned string!                 */
303   /*                                                                       */
304   /* <Output>                                                              */
305   /*    FreeType error code.  0 means success.                             */
306   /*                                                                       */
307   typedef
308   FT_Error  (*TT_Get_PS_Name_Func)( TT_Face      face,
309                                     FT_UInt      index,
310                                     FT_String**  PSname );
311
312
313   /*************************************************************************/
314   /*                                                                       */
315   /* <FuncType>                                                            */
316   /*    TT_Load_Metrics_Func                                               */
317   /*                                                                       */
318   /* <Description>                                                         */
319   /*    Loads the horizontal or vertical header in a face object.          */
320   /*                                                                       */
321   /* <Input>                                                               */
322   /*    face     :: A handle to the target face object.                    */
323   /*                                                                       */
324   /*    stream   :: The input stream.                                      */
325   /*                                                                       */
326   /*    vertical :: A boolean flag.  If set, load vertical metrics.        */
327   /*                                                                       */
328   /* <Return>                                                              */
329   /*    FreeType error code.  0 means success.                             */
330   /*                                                                       */
331   typedef
332   FT_Error  (*TT_Load_Metrics_Func)( TT_Face    face,
333                                      FT_Stream  stream,
334                                      FT_Bool    vertical );
335
336
337   /*************************************************************************/
338   /*                                                                       */
339   /* <FuncType>                                                            */
340   /*    TT_CharMap_Load_Func                                               */
341   /*                                                                       */
342   /* <Description>                                                         */
343   /*    Loads a given TrueType character map into memory.                  */
344   /*                                                                       */
345   /* <Input>                                                               */
346   /*    face   :: A handle to the parent face object.                      */
347   /*                                                                       */
348   /*    stream :: A handle to the current stream object.                   */
349   /*                                                                       */
350   /* <InOut>                                                               */
351   /*    cmap   :: A pointer to a cmap object.                              */
352   /*                                                                       */
353   /* <Return>                                                              */
354   /*    FreeType error code.  0 means success.                             */
355   /*                                                                       */
356   /* <Note>                                                                */
357   /*    The function assumes that the stream is already in use (i.e.,      */
358   /*    opened).  In case of error, all partially allocated tables are     */
359   /*    released.                                                          */
360   /*                                                                       */
361   typedef
362   FT_Error  (*TT_CharMap_Load_Func)( TT_Face        face,
363                                      TT_CMapTable*  cmap,
364                                      FT_Stream      input );
365
366
367   /*************************************************************************/
368   /*                                                                       */
369   /* <FuncType>                                                            */
370   /*    TT_CharMap_Free_Func                                               */
371   /*                                                                       */
372   /* <Description>                                                         */
373   /*    Destroys a character mapping table.                                */
374   /*                                                                       */
375   /* <Input>                                                               */
376   /*    face :: A handle to the parent face object.                        */
377   /*                                                                       */
378   /*    cmap :: A handle to a cmap object.                                 */
379   /*                                                                       */
380   /* <Return>                                                              */
381   /*    FreeType error code.  0 means success.                             */
382   /*                                                                       */
383   typedef
384   FT_Error  (*TT_CharMap_Free_Func)( TT_Face        face,
385                                      TT_CMapTable*  cmap );
386
387
388   /*************************************************************************/
389   /*                                                                       */
390   /* <FuncType>                                                            */
391   /*    TT_Load_Table_Func                                                 */
392   /*                                                                       */
393   /* <Description>                                                         */
394   /*    Loads a given TrueType table.                                      */
395   /*                                                                       */
396   /* <Input>                                                               */
397   /*    face   :: A handle to the target face object.                      */
398   /*                                                                       */
399   /*    stream :: The input stream.                                        */
400   /*                                                                       */
401   /* <Return>                                                              */
402   /*    FreeType error code.  0 means success.                             */
403   /*                                                                       */
404   /* <Note>                                                                */
405   /*    The function will use `face->goto_table' to seek the stream to     */
406   /*    the start of the table.                                            */
407   /*                                                                       */
408   typedef
409   FT_Error  (*TT_Load_Table_Func)( TT_Face    face,
410                                    FT_Stream  stream );
411
412
413   /*************************************************************************/
414   /*                                                                       */
415   /* <FuncType>                                                            */
416   /*    TT_Free_Table_Func                                                 */
417   /*                                                                       */
418   /* <Description>                                                         */
419   /*    Frees a given TrueType table.                                      */
420   /*                                                                       */
421   /* <Input>                                                               */
422   /*    face :: A handle to the target face object.                        */
423   /*                                                                       */
424   typedef
425   void  (*TT_Free_Table_Func)( TT_Face  face );
426
427
428   /*************************************************************************/
429   /*                                                                       */
430   /* <Struct>                                                              */
431   /*    SFNT_Interface                                                     */
432   /*                                                                       */
433   /* <Description>                                                         */
434   /*    This structure holds pointers to the functions used to load and    */
435   /*    free the basic tables that are required in a `sfnt' font file.     */
436   /*                                                                       */
437   /* <Fields>                                                              */
438   /*    Check the various xxx_Func() descriptions for details.             */
439   /*                                                                       */
440   typedef struct  SFNT_Interface_
441   {
442     TT_Goto_Table_Func        goto_table;
443
444     TT_Init_Face_Func         init_face;
445     TT_Load_Face_Func         load_face;
446     TT_Done_Face_Func         done_face;
447     SFNT_Get_Interface_Func   get_interface;
448     
449     TT_Load_Any_Func          load_any;
450     TT_Load_SFNT_Header_Func  load_sfnt_header;
451     TT_Load_Directory_Func    load_directory;
452
453     /* these functions are called by `load_face' but they can also  */
454     /* be called from external modules, if there is a need to do so */
455     TT_Load_Table_Func        load_header;
456     TT_Load_Metrics_Func      load_metrics;
457     TT_Load_Table_Func        load_charmaps;
458     TT_Load_Table_Func        load_max_profile;
459     TT_Load_Table_Func        load_os2;
460     TT_Load_Table_Func        load_psnames;
461
462     TT_Load_Table_Func        load_names;
463     TT_Free_Table_Func        free_names;
464
465     /* optional tables */
466     TT_Load_Table_Func        load_hdmx;
467     TT_Free_Table_Func        free_hdmx;
468
469     TT_Load_Table_Func        load_kerning;
470     TT_Load_Table_Func        load_gasp;
471         TT_Load_Table_Func        load_pclt;
472
473     /* see `ttsbit.h' */
474     TT_Load_Table_Func        load_sbits;
475     TT_Load_SBit_Image_Func   load_sbit_image;
476     TT_Free_Table_Func        free_sbits;
477
478     /* see `ttpost.h' */
479     TT_Get_PS_Name_Func       get_psname;
480     TT_Free_Table_Func        free_psnames;
481
482     /* see `ttcmap.h' */
483     TT_CharMap_Load_Func      load_charmap;
484     TT_CharMap_Free_Func      free_charmap;
485
486   } SFNT_Interface;
487
488
489 #endif /* SFNT_H */
490
491
492 /* END */