1 /***************************************************************************/
5 /* Basic SFNT/TrueType tables definitions and interface */
6 /* (specification only). */
8 /* Copyright 1996-2000 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 /***************************************************************************/
24 #include <freetype/freetype.h>
32 /*************************************************************************/
38 /* A structure used to model a TrueType font header table. All */
39 /* fields follow the TrueType specification. */
41 typedef struct TT_Header_
43 FT_Fixed Table_Version
;
44 FT_Fixed Font_Revision
;
46 FT_Long CheckSum_Adjust
;
50 FT_UShort Units_Per_EM
;
61 FT_UShort Lowest_Rec_PPEM
;
63 FT_Short Font_Direction
;
64 FT_Short Index_To_Loc_Format
;
65 FT_Short Glyph_Data_Format
;
70 /*************************************************************************/
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. */
81 /* Version :: The table version. */
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. */
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). */
92 /* You should use the `sTypoAscender' field */
93 /* of the OS/2 table instead if you want */
94 /* the correct one. */
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 */
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). */
106 /* You should use the `sTypoDescender' */
107 /* field of the OS/2 table instead if you */
108 /* want the correct one. */
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 */
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. */
121 /* min_Left_Side_Bearing :: The minimum left side bearing of all */
122 /* glyphs within the font. */
124 /* min_Right_Side_Bearing :: The minimum right side bearing of all */
125 /* glyphs within the font. */
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. */
131 /* caret_Slope_Rise :: The rise coefficient of the cursor's */
132 /* slope of the cursor (slope=rise/run). */
134 /* caret_Slope_Run :: The run coefficient of the cursor's */
137 /* Reserved :: 10 reserved bytes. */
139 /* metric_Data_Format :: Always 0. */
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. */
145 /* long_metrics :: A pointer into the `hmtx' table. */
147 /* short_metrics :: A pointer into the `hmtx' table. */
150 /* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */
151 /* be identical except for the names of their fields which */
154 /* This ensures that a single function in the `ttload' */
155 /* module is able to read both the horizontal and vertical */
158 typedef struct TT_HoriHeader_
165 FT_UShort advance_Width_Max
; /* advance width maximum */
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
;
174 FT_Short Reserved
[4];
176 FT_Short metric_Data_Format
;
177 FT_UShort number_Of_HMetrics
;
179 /* The following fields are not defined by the TrueType specification */
180 /* but they're used to connect the metrics header to the relevant */
189 /*************************************************************************/
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. */
200 /* Version :: The table version. */
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. */
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 */
212 /* You should use the `sTypoAscender' */
213 /* field of the OS/2 table instead if you */
214 /* want the correct one. */
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. */
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 */
227 /* You should use the `sTypoDescender' */
228 /* field of the OS/2 table instead if you */
229 /* want the correct one. */
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 */
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. */
242 /* min_Top_Side_Bearing :: The minimum top side bearing of all */
243 /* glyphs within the font. */
245 /* min_Bottom_Side_Bearing :: The minimum bottom side bearing of all */
246 /* glyphs within the font. */
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. */
252 /* caret_Slope_Rise :: The rise coefficient of the cursor's */
253 /* slope of the cursor (slope=rise/run). */
255 /* caret_Slope_Run :: The run coefficient of the cursor's */
258 /* Reserved :: 10 reserved bytes. */
260 /* metric_Data_Format :: Always 0. */
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 */
267 /* long_metrics :: A pointer into the `vmtx' table. */
269 /* short_metrics :: A pointer into the `vmtx' table. */
272 /* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */
273 /* be identical except for the names of their fields which */
276 /* This ensures that a single function in the `ttload' */
277 /* module is able to read both the horizontal and vertical */
280 typedef struct TT_VertHeader_
287 FT_UShort advance_Height_Max
; /* advance height maximum */
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
;
296 FT_Short Reserved
[4];
298 FT_Short metric_Data_Format
;
299 FT_UShort number_Of_VMetrics
;
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. */
311 /*************************************************************************/
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. */
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 */
324 typedef struct TT_OS2_
326 FT_UShort version
; /* 0x0001 - more or 0xFFFF */
327 FT_Short xAvgCharWidth
;
328 FT_UShort usWeightClass
;
329 FT_UShort usWidthClass
;
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
;
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 */
350 FT_Char achVendID
[4];
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
;
361 /* only version 1 tables: */
363 FT_ULong ulCodePageRange1
; /* Bits 0-31 */
364 FT_ULong ulCodePageRange2
; /* Bits 32-63 */
366 /* only version 2 tables: */
370 FT_UShort usDefaultChar
;
371 FT_UShort usBreakChar
;
372 FT_UShort usMaxContext
;
377 /*************************************************************************/
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. */
388 typedef struct TT_Postscript_
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
;
400 /* Glyph names follow in the file, but we don't */
401 /* load them by default. See the ttpost.c file. */
406 /*************************************************************************/
412 /* A structure used to model a TrueType PCLT table. All fields */
413 /* comply to the TrueType table. */
415 typedef struct TT_PCLT_
422 FT_UShort TypeFamily
;
425 FT_Char TypeFace
[16];
426 FT_Char CharacterComplement
[8];
428 FT_Char StrokeWeight
;
436 /*************************************************************************/
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. */
447 /* version :: The version number. */
449 /* numGlyphs :: The number of glyphs in this TrueType */
452 /* maxPoints :: The maximum number of points in a */
453 /* non-composite TrueType glyph. See also */
454 /* the structure element */
455 /* `maxCompositePoints'. */
457 /* maxContours :: The maximum number of contours in a */
458 /* non-composite TrueType glyph. See also */
459 /* the structure element */
460 /* `maxCompositeContours'. */
462 /* maxCompositePoints :: The maximum number of points in a */
463 /* composite TrueType glyph. See also the */
464 /* structure element `maxPoints'. */
466 /* maxCompositeContours :: The maximum number of contours in a */
467 /* composite TrueType glyph. See also the */
468 /* structure element `maxContours'. */
470 /* maxZones :: The maximum number of zones used for */
473 /* maxTwilightPoints :: The maximum number of points in the */
474 /* twilight zone used for glyph hinting. */
476 /* maxStorage :: The maximum number of elements in the */
477 /* storage area used for glyph hinting. */
479 /* maxFunctionDefs :: The maximum number of function */
480 /* definitions in the TrueType bytecode for */
483 /* maxInstructionDefs :: The maximum number of instruction */
484 /* definitions in the TrueType bytecode for */
487 /* maxStackElements :: The maximum number of stack elements used */
488 /* during bytecode interpretation. */
490 /* maxSizeOfInstructions :: The maximum number of TrueType opcodes */
491 /* used for glyph hinting. */
493 /* maxComponentElements :: An obscure value related to composite */
494 /* glyphs definitions. */
496 /* maxComponentDepth :: An obscure value related to composite */
497 /* glyphs definitions. Probably the maximum */
498 /* number of simple glyphs in a composite. */
501 /* This structure is only used during font loading. */
503 typedef struct TT_MaxProfile_
508 FT_UShort maxContours
;
509 FT_UShort maxCompositePoints
;
510 FT_UShort maxCompositeContours
;
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
;
534 sfnt_max
/* don't remove */
539 /* internal use only */
540 typedef void* (*FT_Get_Sfnt_Table_Func
)( FT_Face face
,
544 /*************************************************************************/
547 /* FT_Get_Sfnt_Table */
550 /* Returns a pointer to a given SFNT table within a face. */
553 /* face :: A handle to the source. */
555 /* tag :: The index of the SFNT table. */
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 */
563 /* The table is owned by the face object and disappears with it. */
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 */
569 /* You can load any table using the (internal) SFNT_Interface */
570 /* structure -- this is available via FT_Get_Module_Interface(). */
572 FT_EXPORT_DEF( void* ) FT_Get_Sfnt_Table( FT_Face face
,
580 #endif /* TTTABLES_H */