1 /***************************************************************************/
5 /* Basic SFNT/TrueType tables definitions and interface */
6 /* (specification only). */
8 /* Copyright 1996-2001 by */
9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
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. */
17 /***************************************************************************/
20 #ifndef __TTTABLES_H__
21 #define __TTTABLES_H__
25 #include FT_FREETYPE_H
30 /*************************************************************************/
39 /* TrueType-specific table types and functions. */
42 /* This section contains the definition of TrueType-specific tables */
43 /* as well as some routines used to access and process them. */
45 /*************************************************************************/
48 /*************************************************************************/
54 /* A structure used to model a TrueType font header table. All */
55 /* fields follow the TrueType specification. */
57 typedef struct TT_Header_
59 FT_Fixed Table_Version;
60 FT_Fixed Font_Revision;
62 FT_Long CheckSum_Adjust;
66 FT_UShort Units_Per_EM;
77 FT_UShort Lowest_Rec_PPEM;
79 FT_Short Font_Direction;
80 FT_Short Index_To_Loc_Format;
81 FT_Short Glyph_Data_Format;
86 /*************************************************************************/
92 /* A structure used to model a TrueType horizontal header, the `hhea' */
93 /* table, as well as the corresponding horizontal metrics table, */
94 /* i.e., the `hmtx' table. */
97 /* Version :: The table version. */
99 /* Ascender :: The font's ascender, i.e., the distance */
100 /* from the baseline to the top-most of all */
101 /* glyph points found in the font. */
103 /* This value is invalid in many fonts, as */
104 /* it is usually set by the font designer, */
105 /* and often reflects only a portion of the */
106 /* glyphs found in the font (maybe ASCII). */
108 /* You should use the `sTypoAscender' field */
109 /* of the OS/2 table instead if you want */
110 /* the correct one. */
112 /* Descender :: The font's descender, i.e., the distance */
113 /* from the baseline to the bottom-most of */
114 /* all glyph points found in the font. It */
117 /* This value is invalid in many fonts, as */
118 /* it is usually set by the font designer, */
119 /* and often reflects only a portion of the */
120 /* glyphs found in the font (maybe ASCII). */
122 /* You should use the `sTypoDescender' */
123 /* field of the OS/2 table instead if you */
124 /* want the correct one. */
126 /* Line_Gap :: The font's line gap, i.e., the distance */
127 /* to add to the ascender and descender to */
128 /* get the BTB, i.e., the */
129 /* baseline-to-baseline distance for the */
132 /* advance_Width_Max :: This field is the maximum of all advance */
133 /* widths found in the font. It can be */
134 /* used to compute the maximum width of an */
135 /* arbitrary string of text. */
137 /* min_Left_Side_Bearing :: The minimum left side bearing of all */
138 /* glyphs within the font. */
140 /* min_Right_Side_Bearing :: The minimum right side bearing of all */
141 /* glyphs within the font. */
143 /* xMax_Extent :: The maximum horizontal extent (i.e., the */
144 /* `width' of a glyph's bounding box) for */
145 /* all glyphs in the font. */
147 /* caret_Slope_Rise :: The rise coefficient of the cursor's */
148 /* slope of the cursor (slope=rise/run). */
150 /* caret_Slope_Run :: The run coefficient of the cursor's */
153 /* Reserved :: 10 reserved bytes. */
155 /* metric_Data_Format :: Always 0. */
157 /* number_Of_HMetrics :: Number of HMetrics entries in the `hmtx' */
158 /* table -- this value can be smaller than */
159 /* the total number of glyphs in the font. */
161 /* long_metrics :: A pointer into the `hmtx' table. */
163 /* short_metrics :: A pointer into the `hmtx' table. */
166 /* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */
167 /* be identical except for the names of their fields which */
170 /* This ensures that a single function in the `ttload' */
171 /* module is able to read both the horizontal and vertical */
174 typedef struct TT_HoriHeader_
181 FT_UShort advance_Width_Max; /* advance width maximum */
183 FT_Short min_Left_Side_Bearing; /* minimum left-sb */
184 FT_Short min_Right_Side_Bearing; /* minimum right-sb */
185 FT_Short xMax_Extent; /* xmax extents */
186 FT_Short caret_Slope_Rise;
187 FT_Short caret_Slope_Run;
188 FT_Short caret_Offset;
190 FT_Short Reserved[4];
192 FT_Short metric_Data_Format;
193 FT_UShort number_Of_HMetrics;
195 /* The following fields are not defined by the TrueType specification */
196 /* but they are used to connect the metrics header to the relevant */
205 /*************************************************************************/
211 /* A structure used to model a TrueType vertical header, the `vhea' */
212 /* table, as well as the corresponding vertical metrics table, i.e., */
213 /* the `vmtx' table. */
216 /* Version :: The table version. */
218 /* Ascender :: The font's ascender, i.e., the distance */
219 /* from the baseline to the top-most of */
220 /* all glyph points found in the font. */
222 /* This value is invalid in many fonts, as */
223 /* it is usually set by the font designer, */
224 /* and often reflects only a portion of */
225 /* the glyphs found in the font (maybe */
228 /* You should use the `sTypoAscender' */
229 /* field of the OS/2 table instead if you */
230 /* want the correct one. */
232 /* Descender :: The font's descender, i.e., the */
233 /* distance from the baseline to the */
234 /* bottom-most of all glyph points found */
235 /* in the font. It is negative. */
237 /* This value is invalid in many fonts, as */
238 /* it is usually set by the font designer, */
239 /* and often reflects only a portion of */
240 /* the glyphs found in the font (maybe */
243 /* You should use the `sTypoDescender' */
244 /* field of the OS/2 table instead if you */
245 /* want the correct one. */
247 /* Line_Gap :: The font's line gap, i.e., the distance */
248 /* to add to the ascender and descender to */
249 /* get the BTB, i.e., the */
250 /* baseline-to-baseline distance for the */
253 /* advance_Height_Max :: This field is the maximum of all */
254 /* advance heights found in the font. It */
255 /* can be used to compute the maximum */
256 /* height of an arbitrary string of text. */
258 /* min_Top_Side_Bearing :: The minimum top side bearing of all */
259 /* glyphs within the font. */
261 /* min_Bottom_Side_Bearing :: The minimum bottom side bearing of all */
262 /* glyphs within the font. */
264 /* yMax_Extent :: The maximum vertical extent (i.e., the */
265 /* `height' of a glyph's bounding box) for */
266 /* all glyphs in the font. */
268 /* caret_Slope_Rise :: The rise coefficient of the cursor's */
269 /* slope of the cursor (slope=rise/run). */
271 /* caret_Slope_Run :: The run coefficient of the cursor's */
274 /* caret_Offset :: The cursor's offset for slanted fonts. */
275 /* This value is `reserved' in vmtx */
278 /* Reserved :: 8 reserved bytes. */
280 /* metric_Data_Format :: Always 0. */
282 /* number_Of_HMetrics :: Number of VMetrics entries in the */
283 /* `vmtx' table -- this value can be */
284 /* smaller than the total number of glyphs */
287 /* long_metrics :: A pointer into the `vmtx' table. */
289 /* short_metrics :: A pointer into the `vmtx' table. */
292 /* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */
293 /* be identical except for the names of their fields which */
296 /* This ensures that a single function in the `ttload' */
297 /* module is able to read both the horizontal and vertical */
300 typedef struct TT_VertHeader_
307 FT_UShort advance_Height_Max; /* advance height maximum */
309 FT_Short min_Top_Side_Bearing; /* minimum left-sb or top-sb */
310 FT_Short min_Bottom_Side_Bearing; /* minimum right-sb or bottom-sb */
311 FT_Short yMax_Extent; /* xmax or ymax extents */
312 FT_Short caret_Slope_Rise;
313 FT_Short caret_Slope_Run;
314 FT_Short caret_Offset;
316 FT_Short Reserved[4];
318 FT_Short metric_Data_Format;
319 FT_UShort number_Of_VMetrics;
321 /* The following fields are not defined by the TrueType specification */
322 /* but they're used to connect the metrics header to the relevant */
323 /* `HMTX' or `VMTX' table. */
331 /*************************************************************************/
337 /* A structure used to model a TrueType OS/2 table. This is the long */
338 /* table version. All fields comply to the TrueType specification. */
340 /* Note that we now support old Mac fonts which do not include an */
341 /* OS/2 table. In this case, the `version' field is always set to */
344 typedef struct TT_OS2_
346 FT_UShort version; /* 0x0001 - more or 0xFFFF */
347 FT_Short xAvgCharWidth;
348 FT_UShort usWeightClass;
349 FT_UShort usWidthClass;
351 FT_Short ySubscriptXSize;
352 FT_Short ySubscriptYSize;
353 FT_Short ySubscriptXOffset;
354 FT_Short ySubscriptYOffset;
355 FT_Short ySuperscriptXSize;
356 FT_Short ySuperscriptYSize;
357 FT_Short ySuperscriptXOffset;
358 FT_Short ySuperscriptYOffset;
359 FT_Short yStrikeoutSize;
360 FT_Short yStrikeoutPosition;
361 FT_Short sFamilyClass;
365 FT_ULong ulUnicodeRange1; /* Bits 0-31 */
366 FT_ULong ulUnicodeRange2; /* Bits 32-63 */
367 FT_ULong ulUnicodeRange3; /* Bits 64-95 */
368 FT_ULong ulUnicodeRange4; /* Bits 96-127 */
370 FT_Char achVendID[4];
372 FT_UShort fsSelection;
373 FT_UShort usFirstCharIndex;
374 FT_UShort usLastCharIndex;
375 FT_Short sTypoAscender;
376 FT_Short sTypoDescender;
377 FT_Short sTypoLineGap;
378 FT_UShort usWinAscent;
379 FT_UShort usWinDescent;
381 /* only version 1 tables: */
383 FT_ULong ulCodePageRange1; /* Bits 0-31 */
384 FT_ULong ulCodePageRange2; /* Bits 32-63 */
386 /* only version 2 tables: */
390 FT_UShort usDefaultChar;
391 FT_UShort usBreakChar;
392 FT_UShort usMaxContext;
397 /*************************************************************************/
403 /* A structure used to model a TrueType Postscript table. All fields */
404 /* comply to the TrueType table. This structure does not reference */
405 /* the Postscript glyph names, which can be nevertheless accessed */
406 /* with the `ttpost' module. */
408 typedef struct TT_Postscript_
411 FT_Fixed italicAngle;
412 FT_Short underlinePosition;
413 FT_Short underlineThickness;
414 FT_ULong isFixedPitch;
415 FT_ULong minMemType42;
416 FT_ULong maxMemType42;
417 FT_ULong minMemType1;
418 FT_ULong maxMemType1;
420 /* Glyph names follow in the file, but we don't */
421 /* load them by default. See the ttpost.c file. */
426 /*************************************************************************/
432 /* A structure used to model a TrueType PCLT table. All fields */
433 /* comply to the TrueType table. */
435 typedef struct TT_PCLT_
442 FT_UShort TypeFamily;
445 FT_Char TypeFace[16];
446 FT_Char CharacterComplement[8];
448 FT_Char StrokeWeight;
456 /*************************************************************************/
462 /* The maximum profile is a table containing many max values which */
463 /* can be used to pre-allocate arrays. This ensures that no memory */
464 /* allocation occurs during a glyph load. */
467 /* version :: The version number. */
469 /* numGlyphs :: The number of glyphs in this TrueType */
472 /* maxPoints :: The maximum number of points in a */
473 /* non-composite TrueType glyph. See also */
474 /* the structure element */
475 /* `maxCompositePoints'. */
477 /* maxContours :: The maximum number of contours in a */
478 /* non-composite TrueType glyph. See also */
479 /* the structure element */
480 /* `maxCompositeContours'. */
482 /* maxCompositePoints :: The maximum number of points in a */
483 /* composite TrueType glyph. See also the */
484 /* structure element `maxPoints'. */
486 /* maxCompositeContours :: The maximum number of contours in a */
487 /* composite TrueType glyph. See also the */
488 /* structure element `maxContours'. */
490 /* maxZones :: The maximum number of zones used for */
493 /* maxTwilightPoints :: The maximum number of points in the */
494 /* twilight zone used for glyph hinting. */
496 /* maxStorage :: The maximum number of elements in the */
497 /* storage area used for glyph hinting. */
499 /* maxFunctionDefs :: The maximum number of function */
500 /* definitions in the TrueType bytecode for */
503 /* maxInstructionDefs :: The maximum number of instruction */
504 /* definitions in the TrueType bytecode for */
507 /* maxStackElements :: The maximum number of stack elements used */
508 /* during bytecode interpretation. */
510 /* maxSizeOfInstructions :: The maximum number of TrueType opcodes */
511 /* used for glyph hinting. */
513 /* maxComponentElements :: An obscure value related to composite */
514 /* glyphs definitions. */
516 /* maxComponentDepth :: An obscure value related to composite */
517 /* glyphs definitions. Probably the maximum */
518 /* number of simple glyphs in a composite. */
521 /* This structure is only used during font loading. */
523 typedef struct TT_MaxProfile_
528 FT_UShort maxContours;
529 FT_UShort maxCompositePoints;
530 FT_UShort maxCompositeContours;
532 FT_UShort maxTwilightPoints;
533 FT_UShort maxStorage;
534 FT_UShort maxFunctionDefs;
535 FT_UShort maxInstructionDefs;
536 FT_UShort maxStackElements;
537 FT_UShort maxSizeOfInstructions;
538 FT_UShort maxComponentElements;
539 FT_UShort maxComponentDepth;
556 sfnt_max /* don't remove */
561 /* internal use only */
563 (*FT_Get_Sfnt_Table_Func)( FT_Face face,
567 /*************************************************************************/
570 /* FT_Get_Sfnt_Table */
573 /* Returns a pointer to a given SFNT table within a face. */
576 /* face :: A handle to the source. */
578 /* tag :: The index of the SFNT table. */
581 /* A type-less pointer to the table. This will be 0 in case of */
582 /* error, or if the corresponding table was not found *OR* loaded */
586 /* The table is owned by the face object and disappears with it. */
588 /* This function is only useful to access SFNT tables that are loaded */
589 /* by the sfnt/truetype/opentype drivers. See FT_Sfnt_Tag for a */
593 FT_Get_Sfnt_Table( FT_Face face,
602 #endif /* __TTTABLES_H__ */