This commit was manufactured by cvs2svn to create branch 'captive'.
[reactos.git] / include / freetype / tttables.h
1 /***************************************************************************/
2 /*                                                                         */
3 /*  tttables.h                                                             */
4 /*                                                                         */
5 /*    Basic SFNT/TrueType tables definitions and interface                 */
6 /*    (specification only).                                                */
7 /*                                                                         */
8 /*  Copyright 1996-2000 by                                                 */
9 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
10 /*                                                                         */
11 /*  This file is part of the FreeType project, and may only be used,       */
12 /*  modified, and distributed under the terms of the FreeType project      */
13 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
14 /*  this file you indicate that you have read the license and              */
15 /*  understand and accept it fully.                                        */
16 /*                                                                         */
17 /***************************************************************************/
18
19
20 #ifndef TTTABLES_H
21 #define TTTABLES_H
22
23
24 #include <freetype/freetype.h>
25
26
27 #ifdef __cplusplus
28   extern "C" {
29 #endif
30
31
32   /*************************************************************************/
33   /*                                                                       */
34   /* <Struct>                                                              */
35   /*    TT_Header                                                          */
36   /*                                                                       */
37   /* <Description>                                                         */
38   /*    A structure used to model a TrueType font header table.  All       */
39   /*    fields follow the TrueType specification.                          */
40   /*                                                                       */
41   typedef struct  TT_Header_
42   {
43     FT_Fixed   Table_Version;
44     FT_Fixed   Font_Revision;
45
46     FT_Long    CheckSum_Adjust;
47     FT_Long    Magic_Number;
48
49     FT_UShort  Flags;
50     FT_UShort  Units_Per_EM;
51
52     FT_Long    Created [2];
53     FT_Long    Modified[2];
54
55     FT_Short   xMin;
56     FT_Short   yMin;
57     FT_Short   xMax;
58     FT_Short   yMax;
59
60     FT_UShort  Mac_Style;
61     FT_UShort  Lowest_Rec_PPEM;
62
63     FT_Short   Font_Direction;
64     FT_Short   Index_To_Loc_Format;
65     FT_Short   Glyph_Data_Format;
66
67   } TT_Header;
68
69
70   /*************************************************************************/
71   /*                                                                       */
72   /* <Struct>                                                              */
73   /*    TT_HoriHeader                                                      */
74   /*                                                                       */
75   /* <Description>                                                         */
76   /*    A structure used to model a TrueType horizontal header, the `hhea' */
77   /*    table, as well as the corresponding horizontal metrics table,      */
78   /*    i.e., the `hmtx' table.                                            */
79   /*                                                                       */
80   /* <Fields>                                                              */
81   /*    Version                :: The table version.                       */
82   /*                                                                       */
83   /*    Ascender               :: The font's ascender, i.e., the distance  */
84   /*                              from the baseline to the top-most of all */
85   /*                              glyph points found in the font.          */
86   /*                                                                       */
87   /*                              This value is invalid in many fonts, as  */
88   /*                              it is usually set by the font designer,  */
89   /*                              and often reflects only a portion of the */
90   /*                              glyphs found in the font (maybe ASCII).  */
91   /*                                                                       */
92   /*                              You should use the `sTypoAscender' field */
93   /*                              of the OS/2 table instead if you want    */
94   /*                              the correct one.                         */
95   /*                                                                       */
96   /*    Descender              :: The font's descender, i.e., the distance */
97   /*                              from the baseline to the bottom-most of  */
98   /*                              all glyph points found in the font.  It  */
99   /*                              is negative.                             */
100   /*                                                                       */
101   /*                              This value is invalid in many fonts, as  */
102   /*                              it is usually set by the font designer,  */
103   /*                              and often reflects only a portion of the */
104   /*                              glyphs found in the font (maybe ASCII).  */
105   /*                                                                       */
106   /*                              You should use the `sTypoDescender'      */
107   /*                              field of the OS/2 table instead if you   */
108   /*                              want the correct one.                    */
109   /*                                                                       */
110   /*    Line_Gap               :: The font's line gap, i.e., the distance  */
111   /*                              to add to the ascender and descender to  */
112   /*                              get the BTB, i.e., the                   */
113   /*                              baseline-to-baseline distance for the    */
114   /*                              font.                                    */
115   /*                                                                       */
116   /*    advance_Width_Max      :: This field is the maximum of all advance */
117   /*                              widths found in the font.  It can be     */
118   /*                              used to compute the maximum width of an  */
119   /*                              arbitrary string of text.                */
120   /*                                                                       */
121   /*    min_Left_Side_Bearing  :: The minimum left side bearing of all     */
122   /*                              glyphs within the font.                  */
123   /*                                                                       */
124   /*    min_Right_Side_Bearing :: The minimum right side bearing of all    */
125   /*                              glyphs within the font.                  */
126   /*                                                                       */
127   /*    xMax_Extent            :: The maximum horizontal extent (i.e., the */
128   /*                              `width' of a glyph's bounding box) for   */
129   /*                              all glyphs in the font.                  */
130   /*                                                                       */
131   /*    caret_Slope_Rise       :: The rise coefficient of the cursor's     */
132   /*                              slope of the cursor (slope=rise/run).    */
133   /*                                                                       */
134   /*    caret_Slope_Run        :: The run coefficient of the cursor's      */
135   /*                              slope.                                   */
136   /*                                                                       */
137   /*    Reserved               :: 10 reserved bytes.                       */
138   /*                                                                       */
139   /*    metric_Data_Format     :: Always 0.                                */
140   /*                                                                       */
141   /*    number_Of_HMetrics     :: Number of HMetrics entries in the `hmtx' */
142   /*                              table -- this value can be smaller than  */
143   /*                              the total number of glyphs in the font.  */
144   /*                                                                       */
145   /*    long_metrics           :: A pointer into the `hmtx' table.         */
146   /*                                                                       */
147   /*    short_metrics          :: A pointer into the `hmtx' table.         */
148   /*                                                                       */
149   /* <Note>                                                                */
150   /*    IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should   */
151   /*               be identical except for the names of their fields which */
152   /*               are different.                                          */
153   /*                                                                       */
154   /*               This ensures that a single function in the `ttload'     */
155   /*               module is able to read both the horizontal and vertical */
156   /*               headers.                                                */
157   /*                                                                       */
158   typedef struct  TT_HoriHeader_
159   {
160     FT_Fixed   Version;
161     FT_Short   Ascender;
162     FT_Short   Descender;
163     FT_Short   Line_Gap;
164
165     FT_UShort  advance_Width_Max;      /* advance width maximum */
166
167     FT_Short   min_Left_Side_Bearing;  /* minimum left-sb       */
168     FT_Short   min_Right_Side_Bearing; /* minimum right-sb      */
169     FT_Short   xMax_Extent;            /* xmax extents          */
170     FT_Short   caret_Slope_Rise;
171     FT_Short   caret_Slope_Run;
172     FT_Short   caret_Offset;
173
174     FT_Short   Reserved[4];
175
176     FT_Short   metric_Data_Format;
177     FT_UShort  number_Of_HMetrics;
178
179     /* The following fields are not defined by the TrueType specification */
180     /* but they're used to connect the metrics header to the relevant     */
181     /* `HMTX' table.                                                      */
182
183     void*      long_metrics;
184     void*      short_metrics;
185
186   } TT_HoriHeader;
187
188
189   /*************************************************************************/
190   /*                                                                       */
191   /* <Struct>                                                              */
192   /*    TT_VertHeader                                                      */
193   /*                                                                       */
194   /* <Description>                                                         */
195   /*    A structure used to model a TrueType vertical header, the `vhea'   */
196   /*    table, as well as the corresponding vertical metrics table, i.e.,  */
197   /*    the `vmtx' table.                                                  */
198   /*                                                                       */
199   /* <Fields>                                                              */
200   /*    Version                 :: The table version.                      */
201   /*                                                                       */
202   /*    Ascender                :: The font's ascender, i.e., the distance */
203   /*                               from the baseline to the top-most of    */
204   /*                               all glyph points found in the font.     */
205   /*                                                                       */
206   /*                               This value is invalid in many fonts, as */
207   /*                               it is usually set by the font designer, */
208   /*                               and often reflects only a portion of    */
209   /*                               the glyphs found in the font (maybe     */
210   /*                               ASCII).                                 */
211   /*                                                                       */
212   /*                               You should use the `sTypoAscender'      */
213   /*                               field of the OS/2 table instead if you  */
214   /*                               want the correct one.                   */
215   /*                                                                       */
216   /*    Descender               :: The font's descender, i.e., the         */
217   /*                               distance from the baseline to the       */
218   /*                               bottom-most of all glyph points found   */
219   /*                               in the font.  It is negative.           */
220   /*                                                                       */
221   /*                               This value is invalid in many fonts, as */
222   /*                               it is usually set by the font designer, */
223   /*                               and often reflects only a portion of    */
224   /*                               the glyphs found in the font (maybe     */
225   /*                               ASCII).                                 */
226   /*                                                                       */
227   /*                               You should use the `sTypoDescender'     */
228   /*                               field of the OS/2 table instead if you  */
229   /*                               want the correct one.                   */
230   /*                                                                       */
231   /*    Line_Gap                :: The font's line gap, i.e., the distance */
232   /*                               to add to the ascender and descender to */
233   /*                               get the BTB, i.e., the                  */
234   /*                               baseline-to-baseline distance for the   */
235   /*                               font.                                   */
236   /*                                                                       */
237   /*    advance_Height_Max      :: This field is the maximum of all        */
238   /*                               advance heights found in the font.  It  */
239   /*                               can be used to compute the maximum      */
240   /*                               height of an arbitrary string of text.  */
241   /*                                                                       */
242   /*    min_Top_Side_Bearing    :: The minimum top side bearing of all     */
243   /*                               glyphs within the font.                 */
244   /*                                                                       */
245   /*    min_Bottom_Side_Bearing :: The minimum bottom side bearing of all  */
246   /*                               glyphs within the font.                 */
247   /*                                                                       */
248   /*    yMax_Extent             :: The maximum vertical extent (i.e., the  */
249   /*                               `height' of a glyph's bounding box) for */
250   /*                               all glyphs in the font.                 */
251   /*                                                                       */
252   /*    caret_Slope_Rise        :: The rise coefficient of the cursor's    */
253   /*                               slope of the cursor (slope=rise/run).   */
254   /*                                                                       */
255   /*    caret_Slope_Run         :: The run coefficient of the cursor's     */
256   /*                               slope.                                  */
257   /*                                                                       */
258   /*    Reserved                :: 10 reserved bytes.                      */
259   /*                                                                       */
260   /*    metric_Data_Format      :: Always 0.                               */
261   /*                                                                       */
262   /*    number_Of_HMetrics      :: Number of VMetrics entries in the       */
263   /*                               `vmtx' table -- this value can be       */
264   /*                               smaller than the total number of glyphs */
265   /*                               in the font.                            */
266   /*                                                                       */
267   /*    long_metrics           :: A pointer into the `vmtx' table.         */
268   /*                                                                       */
269   /*    short_metrics          :: A pointer into the `vmtx' table.         */
270   /*                                                                       */
271   /* <Note>                                                                */
272   /*    IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should   */
273   /*               be identical except for the names of their fields which */
274   /*               are different.                                          */
275   /*                                                                       */
276   /*               This ensures that a single function in the `ttload'     */
277   /*               module is able to read both the horizontal and vertical */
278   /*               headers.                                                */
279   /*                                                                       */
280   typedef struct TT_VertHeader_
281   {
282     FT_Fixed   Version;
283     FT_Short   Ascender;
284     FT_Short   Descender;
285     FT_Short   Line_Gap;
286
287     FT_UShort  advance_Height_Max;      /* advance height maximum */
288
289     FT_Short   min_Top_Side_Bearing;    /* minimum left-sb or top-sb       */
290     FT_Short   min_Bottom_Side_Bearing; /* minimum right-sb or bottom-sb   */
291     FT_Short   yMax_Extent;             /* xmax or ymax extents            */
292     FT_Short   caret_Slope_Rise;
293     FT_Short   caret_Slope_Run;
294     FT_Short   caret_Offset;
295
296     FT_Short   Reserved[4];
297
298     FT_Short   metric_Data_Format;
299     FT_UShort  number_Of_VMetrics;
300
301     /* The following fields are not defined by the TrueType specification */
302     /* but they're used to connect the metrics header to the relevant     */
303     /* `HMTX' or `VMTX' table.                                            */
304
305     void*      long_metrics;
306     void*      short_metrics;
307
308   } TT_VertHeader;
309
310
311   /*************************************************************************/
312   /*                                                                       */
313   /* <Struct>                                                              */
314   /*    TT_OS2                                                             */
315   /*                                                                       */
316   /* <Description>                                                         */
317   /*    A structure used to model a TrueType OS/2 table. This is the long  */
318   /*    table version.  All fields comply to the TrueType specification.   */
319   /*                                                                       */
320   /*    Note that we now support old Mac fonts which do not include an     */
321   /*    OS/2 table.  In this case, the `version' field is always set to    */
322   /*    0xFFFF.                                                            */
323   /*                                                                       */
324   typedef struct  TT_OS2_
325   {
326     FT_UShort  version;                /* 0x0001 - more or 0xFFFF */
327     FT_Short   xAvgCharWidth;
328     FT_UShort  usWeightClass;
329     FT_UShort  usWidthClass;
330     FT_Short   fsType;
331     FT_Short   ySubscriptXSize;
332     FT_Short   ySubscriptYSize;
333     FT_Short   ySubscriptXOffset;
334     FT_Short   ySubscriptYOffset;
335     FT_Short   ySuperscriptXSize;
336     FT_Short   ySuperscriptYSize;
337     FT_Short   ySuperscriptXOffset;
338     FT_Short   ySuperscriptYOffset;
339     FT_Short   yStrikeoutSize;
340     FT_Short   yStrikeoutPosition;
341     FT_Short   sFamilyClass;
342
343     FT_Byte    panose[10];
344
345     FT_ULong   ulUnicodeRange1;        /* Bits 0-31   */
346     FT_ULong   ulUnicodeRange2;        /* Bits 32-63  */
347     FT_ULong   ulUnicodeRange3;        /* Bits 64-95  */
348     FT_ULong   ulUnicodeRange4;        /* Bits 96-127 */
349
350     FT_Char    achVendID[4];
351
352     FT_UShort  fsSelection;
353     FT_UShort  usFirstCharIndex;
354     FT_UShort  usLastCharIndex;
355     FT_Short   sTypoAscender;
356     FT_Short   sTypoDescender;
357     FT_Short   sTypoLineGap;
358     FT_UShort  usWinAscent;
359     FT_UShort  usWinDescent;
360
361     /* only version 1 tables: */
362
363     FT_ULong   ulCodePageRange1;       /* Bits 0-31   */
364     FT_ULong   ulCodePageRange2;       /* Bits 32-63  */
365
366     /* only version 2 tables: */
367
368     FT_Short   sxHeight;
369     FT_Short   sCapHeight;
370     FT_UShort  usDefaultChar;
371     FT_UShort  usBreakChar;
372     FT_UShort  usMaxContext;
373
374   } TT_OS2;
375
376
377   /*************************************************************************/
378   /*                                                                       */
379   /* <Struct>                                                              */
380   /*    TT_Postscript                                                      */
381   /*                                                                       */
382   /* <Description>                                                         */
383   /*    A structure used to model a TrueType Postscript table.  All fields */
384   /*    comply to the TrueType table.  This structure does not reference   */
385   /*    the Postscript glyph names, which can be nevertheless accessed     */
386   /*    with the `ttpost' module.                                          */
387   /*                                                                       */
388   typedef struct  TT_Postscript_
389   {
390     FT_Fixed  FormatType;
391     FT_Fixed  italicAngle;
392     FT_Short  underlinePosition;
393     FT_Short  underlineThickness;
394     FT_ULong  isFixedPitch;
395     FT_ULong  minMemType42;
396     FT_ULong  maxMemType42;
397     FT_ULong  minMemType1;
398     FT_ULong  maxMemType1;
399
400     /* Glyph names follow in the file, but we don't   */
401     /* load them by default.  See the ttpost.c file.  */
402
403   } TT_Postscript;
404
405
406   /*************************************************************************/
407   /*                                                                       */
408   /* <Struct>                                                              */
409   /*    TT_PCLT                                                            */
410   /*                                                                       */
411   /* <Description>                                                         */
412   /*    A structure used to model a TrueType PCLT table.  All fields       */
413   /*    comply to the TrueType table.                                      */
414   /*                                                                       */
415   typedef struct TT_PCLT_
416   {
417     FT_Fixed   Version;
418     FT_ULong   FontNumber;
419     FT_UShort  Pitch;
420     FT_UShort  xHeight;
421     FT_UShort  Style;
422     FT_UShort  TypeFamily;
423     FT_UShort  CapHeight;
424     FT_UShort  SymbolSet;
425     FT_Char    TypeFace[16];
426     FT_Char    CharacterComplement[8];
427     FT_Char    FileName[6];
428     FT_Char    StrokeWeight;
429     FT_Char    WidthType;
430     FT_Byte    SerifStyle;
431     FT_Byte    Reserved;
432
433   } TT_PCLT;
434
435
436   /*************************************************************************/
437   /*                                                                       */
438   /* <Struct>                                                              */
439   /*    TT_MaxProfile                                                      */
440   /*                                                                       */
441   /* <Description>                                                         */
442   /*    The maximum profile is a table containing many max values which    */
443   /*    can be used to pre-allocate arrays.  This ensures that no memory   */
444   /*    allocation occurs during a glyph load.                             */
445   /*                                                                       */
446   /* <Fields>                                                              */
447   /*    version               :: The version number.                       */
448   /*                                                                       */
449   /*    numGlyphs             :: The number of glyphs in this TrueType     */
450   /*                             font.                                     */
451   /*                                                                       */
452   /*    maxPoints             :: The maximum number of points in a         */
453   /*                             non-composite TrueType glyph.  See also   */
454   /*                             the structure element                     */
455   /*                             `maxCompositePoints'.                     */
456   /*                                                                       */
457   /*    maxContours           :: The maximum number of contours in a       */
458   /*                             non-composite TrueType glyph.  See also   */
459   /*                             the structure element                     */
460   /*                             `maxCompositeContours'.                   */
461   /*                                                                       */
462   /*    maxCompositePoints    :: The maximum number of points in a         */
463   /*                             composite TrueType glyph.  See also the   */
464   /*                             structure element `maxPoints'.            */
465   /*                                                                       */
466   /*    maxCompositeContours  :: The maximum number of contours in a       */
467   /*                             composite TrueType glyph.  See also the   */
468   /*                             structure element `maxContours'.          */
469   /*                                                                       */
470   /*    maxZones              :: The maximum number of zones used for      */
471   /*                             glyph hinting.                            */
472   /*                                                                       */
473   /*    maxTwilightPoints     :: The maximum number of points in the       */
474   /*                             twilight zone used for glyph hinting.     */
475   /*                                                                       */
476   /*    maxStorage            :: The maximum number of elements in the     */
477   /*                             storage area used for glyph hinting.      */
478   /*                                                                       */
479   /*    maxFunctionDefs       :: The maximum number of function            */
480   /*                             definitions in the TrueType bytecode for  */
481   /*                             this font.                                */
482   /*                                                                       */
483   /*    maxInstructionDefs    :: The maximum number of instruction         */
484   /*                             definitions in the TrueType bytecode for  */
485   /*                             this font.                                */
486   /*                                                                       */
487   /*    maxStackElements      :: The maximum number of stack elements used */
488   /*                             during bytecode interpretation.           */
489   /*                                                                       */
490   /*    maxSizeOfInstructions :: The maximum number of TrueType opcodes    */
491   /*                             used for glyph hinting.                   */
492   /*                                                                       */
493   /*    maxComponentElements  :: An obscure value related to composite     */
494   /*                             glyphs definitions.                       */
495   /*                                                                       */
496   /*    maxComponentDepth     :: An obscure value related to composite     */
497   /*                             glyphs definitions.  Probably the maximum */
498   /*                             number of simple glyphs in a composite.   */
499   /*                                                                       */
500   /* <Note>                                                                */
501   /*    This structure is only used during font loading.                   */
502   /*                                                                       */
503   typedef struct  TT_MaxProfile_
504   {
505     FT_Fixed   version;
506     FT_UShort  numGlyphs;
507     FT_UShort  maxPoints;
508     FT_UShort  maxContours;
509     FT_UShort  maxCompositePoints;
510     FT_UShort  maxCompositeContours;
511     FT_UShort  maxZones;
512     FT_UShort  maxTwilightPoints;
513     FT_UShort  maxStorage;
514     FT_UShort  maxFunctionDefs;
515     FT_UShort  maxInstructionDefs;
516     FT_UShort  maxStackElements;
517     FT_UShort  maxSizeOfInstructions;
518     FT_UShort  maxComponentElements;
519     FT_UShort  maxComponentDepth;
520
521   } TT_MaxProfile;
522
523
524   typedef enum
525   {
526     ft_sfnt_head = 0,
527     ft_sfnt_maxp = 1,
528     ft_sfnt_os2  = 2,
529     ft_sfnt_hhea = 3,
530     ft_sfnt_vhea = 4,
531     ft_sfnt_post = 5,
532     ft_sfnt_pclt = 6,
533
534     sfnt_max   /* don't remove */
535
536   } FT_Sfnt_Tag;
537
538
539   /* internal use only */
540   typedef void*  (*FT_Get_Sfnt_Table_Func)( FT_Face      face,
541                                             FT_Sfnt_Tag  tag );
542
543
544   /*************************************************************************/
545   /*                                                                       */
546   /* <Function>                                                            */
547   /*    FT_Get_Sfnt_Table                                                  */
548   /*                                                                       */
549   /* <Description>                                                         */
550   /*    Returns a pointer to a given SFNT table within a face.             */
551   /*                                                                       */
552   /* <Input>                                                               */
553   /*    face :: A handle to the source.                                    */
554   /*                                                                       */
555   /*    tag  :: The index of the SFNT table.                               */
556   /*                                                                       */
557   /* <Return>                                                              */
558   /*    A type-less pointer to the table.  This will be 0 in case of       */
559   /*    error, or if the corresponding table was not found *OR* loaded     */
560   /*    from the file.                                                     */
561   /*                                                                       */
562   /* <Note>                                                                */
563   /*    The table is owned by the face object and disappears with it.      */
564   /*                                                                       */
565   /*    This function is only useful to access SFNT tables that are loaded */
566   /*    by the sfnt/truetype/opentype drivers.  See FT_Sfnt_tag for a      */
567   /*    list.                                                              */
568   /*                                                                       */
569   /*    You can load any table using the (internal) SFNT_Interface         */
570   /*    structure -- this is available via FT_Get_Module_Interface().      */
571   /*                                                                       */
572   FT_EXPORT_DEF( void* )  FT_Get_Sfnt_Table( FT_Face      face,
573                                              FT_Sfnt_Tag  tag );
574
575 #ifdef __cplusplus
576   }
577 #endif
578
579
580 #endif /* TTTABLES_H */
581
582
583 /* END */