source: OGRE/trunk/ogrenew/Dependencies/include/freetype/internal/sfnt.h @ 657

Revision 657, 35.2 KB checked in by mattausch, 18 years ago (diff)

added ogre dependencies and patched ogre sources

Line 
1/***************************************************************************/
2/*                                                                         */
3/*  sfnt.h                                                                 */
4/*                                                                         */
5/*    High-level `sfnt' driver interface (specification).                  */
6/*                                                                         */
7/*  Copyright 1996-2001, 2002, 2003, 2004, 2005 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 <ft2build.h>
24#include FT_INTERNAL_DRIVER_H
25#include FT_INTERNAL_TRUETYPE_TYPES_H
26
27
28FT_BEGIN_HEADER
29
30
31  /*************************************************************************/
32  /*                                                                       */
33  /* <FuncType>                                                            */
34  /*    TT_Init_Face_Func                                                  */
35  /*                                                                       */
36  /* <Description>                                                         */
37  /*    First part of the SFNT face object initialization.  This will find */
38  /*    the face in a SFNT file or collection, and load its format tag in  */
39  /*    face->format_tag.                                                  */
40  /*                                                                       */
41  /* <Input>                                                               */
42  /*    stream     :: The input stream.                                    */
43  /*                                                                       */
44  /*    face       :: A handle to the target face object.                  */
45  /*                                                                       */
46  /*    face_index :: The index of the TrueType font, if we are opening a  */
47  /*                  collection.                                          */
48  /*                                                                       */
49  /*    num_params :: The number of additional parameters.                 */
50  /*                                                                       */
51  /*    params     :: Optional additional parameters.                      */
52  /*                                                                       */
53  /* <Return>                                                              */
54  /*    FreeType error code.  0 means success.                             */
55  /*                                                                       */
56  /* <Note>                                                                */
57  /*    The stream cursor must be at the font file's origin.               */
58  /*                                                                       */
59  /*    This function recognizes fonts embedded in a `TrueType             */
60  /*    collection'.                                                       */
61  /*                                                                       */
62  /*    Once the format tag has been validated by the font driver, it      */
63  /*    should then call the TT_Load_Face_Func() callback to read the rest */
64  /*    of the SFNT tables in the object.                                  */
65  /*                                                                       */
66  typedef FT_Error
67  (*TT_Init_Face_Func)( FT_Stream      stream,
68                        TT_Face        face,
69                        FT_Int         face_index,
70                        FT_Int         num_params,
71                        FT_Parameter*  params );
72
73
74  /*************************************************************************/
75  /*                                                                       */
76  /* <FuncType>                                                            */
77  /*    TT_Load_Face_Func                                                  */
78  /*                                                                       */
79  /* <Description>                                                         */
80  /*    Second part of the SFNT face object initialization.  This will     */
81  /*    load the common SFNT tables (head, OS/2, maxp, metrics, etc.) in   */
82  /*    the face object.                                                   */
83  /*                                                                       */
84  /* <Input>                                                               */
85  /*    stream     :: The input stream.                                    */
86  /*                                                                       */
87  /*    face       :: A handle to the target face object.                  */
88  /*                                                                       */
89  /*    face_index :: The index of the TrueType font, if we are opening a  */
90  /*                  collection.                                          */
91  /*                                                                       */
92  /*    num_params :: The number of additional parameters.                 */
93  /*                                                                       */
94  /*    params     :: Optional additional parameters.                      */
95  /*                                                                       */
96  /* <Return>                                                              */
97  /*    FreeType error code.  0 means success.                             */
98  /*                                                                       */
99  /* <Note>                                                                */
100  /*    This function must be called after TT_Init_Face_Func().            */
101  /*                                                                       */
102  typedef FT_Error
103  (*TT_Load_Face_Func)( FT_Stream      stream,
104                        TT_Face        face,
105                        FT_Int         face_index,
106                        FT_Int         num_params,
107                        FT_Parameter*  params );
108
109
110  /*************************************************************************/
111  /*                                                                       */
112  /* <FuncType>                                                            */
113  /*    TT_Done_Face_Func                                                  */
114  /*                                                                       */
115  /* <Description>                                                         */
116  /*    A callback used to delete the common SFNT data from a face.        */
117  /*                                                                       */
118  /* <Input>                                                               */
119  /*    face :: A handle to the target face object.                        */
120  /*                                                                       */
121  /* <Note>                                                                */
122  /*    This function does NOT destroy the face object.                    */
123  /*                                                                       */
124  typedef void
125  (*TT_Done_Face_Func)( TT_Face  face );
126
127
128  /*************************************************************************/
129  /*                                                                       */
130  /* <FuncType>                                                            */
131  /*    TT_Load_SFNT_HeaderRec_Func                                        */
132  /*                                                                       */
133  /* <Description>                                                         */
134  /*    Loads the header of a SFNT font file.  Supports collections.       */
135  /*                                                                       */
136  /* <Input>                                                               */
137  /*    face       :: A handle to the target face object.                  */
138  /*                                                                       */
139  /*    stream     :: The input stream.                                    */
140  /*                                                                       */
141  /*    face_index :: The index of the TrueType font, if we are opening a  */
142  /*                  collection.                                          */
143  /*                                                                       */
144  /* <Output>                                                              */
145  /*    sfnt       :: The SFNT header.                                     */
146  /*                                                                       */
147  /* <Return>                                                              */
148  /*    FreeType error code.  0 means success.                             */
149  /*                                                                       */
150  /* <Note>                                                                */
151  /*    The stream cursor must be at the font file's origin.               */
152  /*                                                                       */
153  /*    This function recognizes fonts embedded in a `TrueType             */
154  /*    collection'.                                                       */
155  /*                                                                       */
156  /*    This function checks that the header is valid by looking at the    */
157  /*    values of `search_range', `entry_selector', and `range_shift'.     */
158  /*                                                                       */
159  typedef FT_Error
160  (*TT_Load_SFNT_HeaderRec_Func)( TT_Face      face,
161                                  FT_Stream    stream,
162                                  FT_Long      face_index,
163                                  SFNT_Header  sfnt );
164
165
166  /*************************************************************************/
167  /*                                                                       */
168  /* <FuncType>                                                            */
169  /*    TT_Load_Directory_Func                                             */
170  /*                                                                       */
171  /* <Description>                                                         */
172  /*    Loads the table directory into a face object.                      */
173  /*                                                                       */
174  /* <Input>                                                               */
175  /*    face      :: A handle to the target face object.                   */
176  /*                                                                       */
177  /*    stream    :: The input stream.                                     */
178  /*                                                                       */
179  /*    sfnt      :: The SFNT header.                                      */
180  /*                                                                       */
181  /* <Return>                                                              */
182  /*    FreeType error code.  0 means success.                             */
183  /*                                                                       */
184  /* <Note>                                                                */
185  /*    The stream cursor must be on the first byte after the 4-byte font  */
186  /*    format tag.  This is the case just after a call to                 */
187  /*    TT_Load_Format_Tag().                                              */
188  /*                                                                       */
189  typedef FT_Error
190  (*TT_Load_Directory_Func)( TT_Face      face,
191                             FT_Stream    stream,
192                             SFNT_Header  sfnt );
193
194
195  /*************************************************************************/
196  /*                                                                       */
197  /* <FuncType>                                                            */
198  /*    TT_Load_Any_Func                                                   */
199  /*                                                                       */
200  /* <Description>                                                         */
201  /*    Loads any font table into client memory.                           */
202  /*                                                                       */
203  /* <Input>                                                               */
204  /*    face   :: The face object to look for.                             */
205  /*                                                                       */
206  /*    tag    :: The tag of table to load.  Use the value 0 if you want   */
207  /*              to access the whole font file, else set this parameter   */
208  /*              to a valid TrueType table tag that you can forge with    */
209  /*              the MAKE_TT_TAG macro.                                   */
210  /*                                                                       */
211  /*    offset :: The starting offset in the table (or the file if         */
212  /*              tag == 0).                                               */
213  /*                                                                       */
214  /*    length :: The address of the decision variable:                    */
215  /*                                                                       */
216  /*                If length == NULL:                                     */
217  /*                  Loads the whole table.  Returns an error if          */
218  /*                  `offset' == 0!                                       */
219  /*                                                                       */
220  /*                If *length == 0:                                       */
221  /*                  Exits immediately; returning the length of the given */
222  /*                  table or of the font file, depending on the value of */
223  /*                  `tag'.                                               */
224  /*                                                                       */
225  /*                If *length != 0:                                       */
226  /*                  Loads the next `length' bytes of table or font,      */
227  /*                  starting at offset `offset' (in table or font too).  */
228  /*                                                                       */
229  /* <Output>                                                              */
230  /*    buffer :: The address of target buffer.                            */
231  /*                                                                       */
232  /* <Return>                                                              */
233  /*    TrueType error code.  0 means success.                             */
234  /*                                                                       */
235  typedef FT_Error
236  (*TT_Load_Any_Func)( TT_Face    face,
237                       FT_ULong   tag,
238                       FT_Long    offset,
239                       FT_Byte   *buffer,
240                       FT_ULong*  length );
241
242
243  /*************************************************************************/
244  /*                                                                       */
245  /* <FuncType>                                                            */
246  /*    TT_Find_SBit_Image_Func                                            */
247  /*                                                                       */
248  /* <Description>                                                         */
249  /*    Checks whether an embedded bitmap (an `sbit') exists for a given   */
250  /*    glyph, at a given strike.                                          */
251  /*                                                                       */
252  /* <Input>                                                               */
253  /*    face          :: The target face object.                           */
254  /*                                                                       */
255  /*    glyph_index   :: The glyph index.                                  */
256  /*                                                                       */
257  /*    strike_index  :: The current strike index.                         */
258  /*                                                                       */
259  /* <Output>                                                              */
260  /*    arange        :: The SBit range containing the glyph index.        */
261  /*                                                                       */
262  /*    astrike       :: The SBit strike containing the glyph index.       */
263  /*                                                                       */
264  /*    aglyph_offset :: The offset of the glyph data in `EBDT' table.     */
265  /*                                                                       */
266  /* <Return>                                                              */
267  /*    FreeType error code.  0 means success.  Returns                    */
268  /*    SFNT_Err_Invalid_Argument if no sbit exists for the requested      */
269  /*    glyph.                                                             */
270  /*                                                                       */
271  typedef FT_Error
272  (*TT_Find_SBit_Image_Func)( TT_Face          face,
273                              FT_UInt          glyph_index,
274                              FT_ULong         strike_index,
275                              TT_SBit_Range   *arange,
276                              TT_SBit_Strike  *astrike,
277                              FT_ULong        *aglyph_offset );
278
279
280  /*************************************************************************/
281  /*                                                                       */
282  /* <FuncType>                                                            */
283  /*    TT_Load_SBit_Metrics_Func                                          */
284  /*                                                                       */
285  /* <Description>                                                         */
286  /*    Gets the big metrics for a given embedded bitmap.                  */
287  /*                                                                       */
288  /* <Input>                                                               */
289  /*    stream      :: The input stream.                                   */
290  /*                                                                       */
291  /*    range       :: The SBit range containing the glyph.                */
292  /*                                                                       */
293  /* <Output>                                                              */
294  /*    big_metrics :: A big SBit metrics structure for the glyph.         */
295  /*                                                                       */
296  /* <Return>                                                              */
297  /*    FreeType error code.  0 means success.                             */
298  /*                                                                       */
299  /* <Note>                                                                */
300  /*    The stream cursor must be positioned at the glyph's offset within  */
301  /*    the `EBDT' table before the call.                                  */
302  /*                                                                       */
303  /*    If the image format uses variable metrics, the stream cursor is    */
304  /*    positioned just after the metrics header in the `EBDT' table on    */
305  /*    function exit.                                                     */
306  /*                                                                       */
307  typedef FT_Error
308  (*TT_Load_SBit_Metrics_Func)( FT_Stream        stream,
309                                TT_SBit_Range    range,
310                                TT_SBit_Metrics  metrics );
311
312
313  /*************************************************************************/
314  /*                                                                       */
315  /* <FuncType>                                                            */
316  /*    TT_Load_SBit_Image_Func                                            */
317  /*                                                                       */
318  /* <Description>                                                         */
319  /*    Loads a given glyph sbit image from the font resource.  This also  */
320  /*    returns its metrics.                                               */
321  /*                                                                       */
322  /* <Input>                                                               */
323  /*    face ::                                                            */
324  /*      The target face object.                                          */
325  /*                                                                       */
326  /*    strike_index ::                                                    */
327  /*      The strike index.                                                */
328  /*                                                                       */
329  /*    glyph_index ::                                                     */
330  /*      The current glyph index.                                         */
331  /*                                                                       */
332  /*    load_flags ::                                                      */
333  /*      The current load flags.                                          */
334  /*                                                                       */
335  /*    stream ::                                                          */
336  /*      The input stream.                                                */
337  /*                                                                       */
338  /* <Output>                                                              */
339  /*    amap ::                                                            */
340  /*      The target pixmap.                                               */
341  /*                                                                       */
342  /*    ametrics ::                                                        */
343  /*      A big sbit metrics structure for the glyph image.                */
344  /*                                                                       */
345  /* <Return>                                                              */
346  /*    FreeType error code.  0 means success.  Returns an error if no     */
347  /*    glyph sbit exists for the index.                                   */
348  /*                                                                       */
349  /*  <Note>                                                               */
350  /*    The `map.buffer' field is always freed before the glyph is loaded. */
351  /*                                                                       */
352  typedef FT_Error
353  (*TT_Load_SBit_Image_Func)( TT_Face              face,
354                              FT_ULong             strike_index,
355                              FT_UInt              glyph_index,
356                              FT_UInt              load_flags,
357                              FT_Stream            stream,
358                              FT_Bitmap           *amap,
359                              TT_SBit_MetricsRec  *ametrics );
360
361
362  /*************************************************************************/
363  /*                                                                       */
364  /* <FuncType>                                                            */
365  /*    TT_Set_SBit_Strike_Func                                            */
366  /*                                                                       */
367  /* <Description>                                                         */
368  /*    Selects an sbit strike for given horizontal and vertical ppem      */
369  /*    values.                                                            */
370  /*                                                                       */
371  /* <Input>                                                               */
372  /*    face          :: The target face object.                           */
373  /*                                                                       */
374  /*    x_ppem        :: The horizontal resolution in points per EM.       */
375  /*                                                                       */
376  /*    y_ppem        :: The vertical resolution in points per EM.         */
377  /*                                                                       */
378  /* <Output>                                                              */
379  /*    astrike_index :: The index of the sbit strike.                     */
380  /*                                                                       */
381  /* <Return>                                                              */
382  /*    FreeType error code.  0 means success.  Returns an error if no     */
383  /*    sbit strike exists for the selected ppem values.                   */
384  /*                                                                       */
385  typedef FT_Error
386  (*TT_Set_SBit_Strike_Func)( TT_Face    face,
387                              FT_UInt    x_ppem,
388                              FT_UInt    y_ppem,
389                              FT_ULong  *astrike_index );
390
391
392  /*************************************************************************/
393  /*                                                                       */
394  /* <FuncType>                                                            */
395  /*    TT_Get_PS_Name_Func                                                */
396  /*                                                                       */
397  /* <Description>                                                         */
398  /*    Gets the PostScript glyph name of a glyph.                         */
399  /*                                                                       */
400  /* <Input>                                                               */
401  /*    idx  :: The glyph index.                                           */
402  /*                                                                       */
403  /*    PSname :: The address of a string pointer.  Will be NULL in case   */
404  /*              of error, otherwise it is a pointer to the glyph name.   */
405  /*                                                                       */
406  /*              You must not modify the returned string!                 */
407  /*                                                                       */
408  /* <Output>                                                              */
409  /*    FreeType error code.  0 means success.                             */
410  /*                                                                       */
411  typedef FT_Error
412  (*TT_Get_PS_Name_Func)( TT_Face      face,
413                          FT_UInt      idx,
414                          FT_String**  PSname );
415
416
417  /*************************************************************************/
418  /*                                                                       */
419  /* <FuncType>                                                            */
420  /*    TT_Load_Metrics_Func                                               */
421  /*                                                                       */
422  /* <Description>                                                         */
423  /*    Loads the horizontal or vertical header in a face object.          */
424  /*                                                                       */
425  /* <Input>                                                               */
426  /*    face     :: A handle to the target face object.                    */
427  /*                                                                       */
428  /*    stream   :: The input stream.                                      */
429  /*                                                                       */
430  /*    vertical :: A boolean flag.  If set, load vertical metrics.        */
431  /*                                                                       */
432  /* <Return>                                                              */
433  /*    FreeType error code.  0 means success.                             */
434  /*                                                                       */
435  typedef FT_Error
436  (*TT_Load_Metrics_Func)( TT_Face    face,
437                           FT_Stream  stream,
438                           FT_Bool    vertical );
439
440
441  /*************************************************************************/
442  /*                                                                       */
443  /* <FuncType>                                                            */
444  /*    TT_Load_Table_Func                                                 */
445  /*                                                                       */
446  /* <Description>                                                         */
447  /*    Loads a given TrueType table.                                      */
448  /*                                                                       */
449  /* <Input>                                                               */
450  /*    face   :: A handle to the target face object.                      */
451  /*                                                                       */
452  /*    stream :: The input stream.                                        */
453  /*                                                                       */
454  /* <Return>                                                              */
455  /*    FreeType error code.  0 means success.                             */
456  /*                                                                       */
457  /* <Note>                                                                */
458  /*    The function will use `face->goto_table' to seek the stream to     */
459  /*    the start of the table.                                            */
460  /*                                                                       */
461  typedef FT_Error
462  (*TT_Load_Table_Func)( TT_Face    face,
463                         FT_Stream  stream );
464
465
466  /*************************************************************************/
467  /*                                                                       */
468  /* <FuncType>                                                            */
469  /*    TT_Free_Table_Func                                                 */
470  /*                                                                       */
471  /* <Description>                                                         */
472  /*    Frees a given TrueType table.                                      */
473  /*                                                                       */
474  /* <Input>                                                               */
475  /*    face :: A handle to the target face object.                        */
476  /*                                                                       */
477  typedef void
478  (*TT_Free_Table_Func)( TT_Face  face );
479
480
481  /*
482   * @functype:
483   *    TT_Face_GetKerningFunc
484   *
485   * @description:
486   *    Return the horizontal kerning value between two glyphs.
487   *
488   * @input:
489   *    face        :: A handle to the source face object.
490   *    left_glyph  :: The left glyph index.
491   *    right_glyph :: The right glyph index.
492   *
493   * @return:
494   *    The kerning value in font units.
495   */
496  typedef FT_Int
497  (*TT_Face_GetKerningFunc)( TT_Face  face,
498                             FT_UInt  left_glyph,
499                             FT_UInt  right_glyph );
500
501
502  /*************************************************************************/
503  /*                                                                       */
504  /* <Struct>                                                              */
505  /*    SFNT_Interface                                                     */
506  /*                                                                       */
507  /* <Description>                                                         */
508  /*    This structure holds pointers to the functions used to load and    */
509  /*    free the basic tables that are required in a `sfnt' font file.     */
510  /*                                                                       */
511  /* <Fields>                                                              */
512  /*    Check the various xxx_Func() descriptions for details.             */
513  /*                                                                       */
514  typedef struct  SFNT_Interface_
515  {
516    TT_Loader_GotoTableFunc      goto_table;
517
518    TT_Init_Face_Func            init_face;
519    TT_Load_Face_Func            load_face;
520    TT_Done_Face_Func            done_face;
521    FT_Module_Requester          get_interface;
522
523    TT_Load_Any_Func             load_any;
524    TT_Load_SFNT_HeaderRec_Func  load_sfnt_header;
525    TT_Load_Directory_Func       load_directory;
526
527    /* these functions are called by `load_face' but they can also  */
528    /* be called from external modules, if there is a need to do so */
529    TT_Load_Table_Func           load_header;
530    TT_Load_Metrics_Func         load_metrics;
531    TT_Load_Table_Func           load_charmaps;
532    TT_Load_Table_Func           load_max_profile;
533    TT_Load_Table_Func           load_os2;
534    TT_Load_Table_Func           load_psnames;
535
536    TT_Load_Table_Func           load_names;
537    TT_Free_Table_Func           free_names;
538
539    /* optional tables */
540    TT_Load_Table_Func           load_hdmx;
541    TT_Free_Table_Func           free_hdmx;
542
543    TT_Load_Table_Func           load_kerning;
544    TT_Load_Table_Func           load_gasp;
545    TT_Load_Table_Func           load_pclt;
546
547    /* see `ttload.h' */
548    TT_Load_Table_Func           load_bitmap_header;
549
550    /* see `ttsbit.h' */
551    TT_Set_SBit_Strike_Func      set_sbit_strike;
552    TT_Load_Table_Func           load_sbits;
553    TT_Find_SBit_Image_Func      find_sbit_image;
554    TT_Load_SBit_Metrics_Func    load_sbit_metrics;
555    TT_Load_SBit_Image_Func      load_sbit_image;
556    TT_Free_Table_Func           free_sbits;
557
558    /* see `ttkern.h' */
559    TT_Face_GetKerningFunc       get_kerning;
560   
561    /* see `ttpost.h' */
562    TT_Get_PS_Name_Func          get_psname;
563    TT_Free_Table_Func           free_psnames;
564
565  } SFNT_Interface;
566
567
568  /* transitional */
569  typedef SFNT_Interface*   SFNT_Service;
570
571
572FT_END_HEADER
573
574#endif /* __SFNT_H__ */
575
576
577/* END */
Note: See TracBrowser for help on using the repository browser.