1 /***************************************************************************/
5 /* Basic SFNT/TrueType type definitions and interface (specification */
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 /***************************************************************************/
25 #include FT_TRUETYPE_TABLES_H
26 #include FT_INTERNAL_OBJECTS_H
32 /*************************************************************************/
33 /*************************************************************************/
34 /*************************************************************************/
37 /*** REQUIRED TRUETYPE/OPENTYPE TABLES DEFINITIONS ***/
40 /*************************************************************************/
41 /*************************************************************************/
42 /*************************************************************************/
45 /*************************************************************************/
51 /* TrueType collection header. This table contains the offsets of */
52 /* the font headers of each distinct TrueType face in the file. */
55 /* tag :: Must be `ttc ' to indicate a TrueType collection. */
57 /* version :: The version number. */
59 /* count :: The number of faces in the collection. The */
60 /* specification says this should be an unsigned long, but */
61 /* we use a signed long since we need the value -1 for */
62 /* specific purposes. */
64 /* offsets :: The offsets of the font headers, one per face. */
66 typedef struct TTC_Header_
76 /*************************************************************************/
82 /* SFNT file format header. */
85 /* format_tag :: The font format tag. */
87 /* num_tables :: The number of tables in file. */
89 /* search_range :: Must be 16*(max power of 2 <= num_tables). */
91 /* entry_selector :: Must be log2 of search_range/16. */
93 /* range_shift :: Must be num_tables*16 - search_range. */
95 typedef struct SFNT_Header_
99 FT_UShort search_range;
100 FT_UShort entry_selector;
101 FT_UShort range_shift;
106 /*************************************************************************/
112 /* This structure models a TrueType table directory. It is used to */
113 /* access the various tables of the font face. */
116 /* version :: The version number; starts with 0x00010000. */
118 /* numTables :: The number of tables. */
120 /* searchRange :: Unused. */
122 /* entrySelector :: Unused. */
124 /* rangeShift :: Unused. */
127 /* This structure is only used during font opening. */
129 typedef struct TT_TableDir_
131 FT_Fixed version; /* should be 0x10000 */
132 FT_UShort numTables; /* number of tables */
134 FT_UShort searchRange; /* These parameters are only used */
135 FT_UShort entrySelector; /* for a dichotomy search in the */
136 FT_UShort rangeShift; /* directory. We ignore them. */
141 /*************************************************************************/
147 /* This structure describes a given table of a TrueType font. */
150 /* Tag :: A four-bytes tag describing the table. */
152 /* CheckSum :: The table checksum. This value can be ignored. */
154 /* Offset :: The offset of the table from the start of the TrueType */
155 /* font in its resource. */
157 /* Length :: The table length (in bytes). */
159 typedef struct TT_Table_
161 FT_ULong Tag; /* table type */
162 FT_ULong CheckSum; /* table checksum */
163 FT_ULong Offset; /* table file offset */
164 FT_ULong Length; /* table length */
169 /*************************************************************************/
175 /* This structure describes the directory of the `cmap' table, */
176 /* containing the font's character mappings table. */
179 /* tableVersionNumber :: The version number. */
181 /* numCMaps :: The number of charmaps in the font. */
184 /* This structure is only used during font loading. */
186 typedef struct TT_CMapDir_
188 FT_UShort tableVersionNumber;
194 /*************************************************************************/
197 /* TT_CMapDirEntry */
200 /* This structure describes a charmap in a TrueType font. */
203 /* platformID :: An ID used to specify for which platform this */
204 /* charmap is defined (FreeType manages all platforms). */
206 /* encodingID :: A platform-specific ID used to indicate which source */
207 /* encoding is used in this charmap. */
209 /* offset :: The offset of the charmap relative to the start of */
210 /* the `cmap' table. */
213 /* This structure is only used during font loading. */
215 typedef struct TT_CMapDirEntry_
217 FT_UShort platformID;
218 FT_UShort platformEncodingID;
224 /*************************************************************************/
230 /* A structure modeling the long metrics of the `hmtx' and `vmtx' */
231 /* TrueType tables. The values are expressed in font units. */
234 /* advance :: The advance width or height for the glyph. */
236 /* bearing :: The left-side or top-side bearing for the glyph. */
238 typedef struct TT_LongMetrics_
246 /*************************************************************************/
248 /* <Type> TT_ShortMetrics */
251 /* A simple type to model the short metrics of the `hmtx' and `vmtx' */
254 typedef FT_Short TT_ShortMetrics;
257 /*************************************************************************/
263 /* A structure modeling TrueType name records. Name records are used */
264 /* to store important strings like family name, style name, */
265 /* copyright, etc. in _localized_ versions (i.e., language, encoding, */
269 /* platformID :: The ID of the name's encoding platform. */
271 /* encodingID :: The platform-specific ID for the name's encoding. */
273 /* languageID :: The platform-specific ID for the name's language. */
275 /* nameID :: The ID specifying what kind of name this is. */
277 /* stringLength :: The length of the string in bytes. */
279 /* stringOffset :: The offset to the string in the `name' table. */
281 /* string :: A pointer to the string's bytes. Note that these */
282 /* are usually UTF-16 encoded characters. */
284 typedef struct TT_NameRec_
286 FT_UShort platformID;
287 FT_UShort encodingID;
288 FT_UShort languageID;
290 FT_UShort stringLength;
291 FT_UShort stringOffset;
293 /* this last field is not defined in the spec */
294 /* but used by the FreeType engine */
301 /*************************************************************************/
307 /* A structure modeling the TrueType name table. */
310 /* format :: The format of the name table. */
312 /* numNameRecords :: The number of names in table. */
314 /* storageOffset :: The offset of the name table in the `name' */
315 /* TrueType table. */
317 /* names :: An array of name records. */
319 /* storage :: The names storage area. */
321 typedef struct TT_NameTable_
324 FT_UShort numNameRecords;
325 FT_UShort storageOffset;
332 /*************************************************************************/
333 /*************************************************************************/
334 /*************************************************************************/
337 /*** OPTIONAL TRUETYPE/OPENTYPE TABLES DEFINITIONS ***/
340 /*************************************************************************/
341 /*************************************************************************/
342 /*************************************************************************/
345 /*************************************************************************/
351 /* A tiny structure used to model a gasp range according to the */
352 /* TrueType specification. */
355 /* maxPPEM :: The maximum ppem value to which `gaspFlag' applies. */
357 /* gaspFlag :: A flag describing the grid-fitting and anti-aliasing */
358 /* modes to be used. */
360 typedef struct TT_GaspRange_
368 #define TT_GASP_GRIDFIT 0x01
369 #define TT_GASP_DOGRAY 0x02
372 /*************************************************************************/
378 /* A structure modeling the TrueType `gasp' table used to specify */
379 /* grid-fitting and anti-aliasing behaviour. */
382 /* version :: The version number. */
384 /* numRanges :: The number of gasp ranges in table. */
386 /* gaspRanges :: An array of gasp ranges. */
388 typedef struct TT_Gasp_
392 TT_GaspRange* gaspRanges;
397 /*************************************************************************/
403 /* A small structure used to model the pre-computed widths of a given */
404 /* size. They are found in the `hdmx' table. */
407 /* ppem :: The pixels per EM value at which these metrics apply. */
409 /* max_width :: The maximum advance width for this metric. */
411 /* widths :: An array of widths. Note: These are 8-bit bytes. */
413 typedef struct TT_HdmxRec_
422 /*************************************************************************/
428 /* A structure used to model the `hdmx' table, which contains */
429 /* pre-computed widths for a set of given sizes/dimensions. */
432 /* version :: The version number. */
434 /* num_records :: The number of hdmx records. */
436 /* records :: An array of hdmx records. */
438 typedef struct TT_Hdmx_
441 FT_Short num_records;
447 /*************************************************************************/
453 /* A structure used to model a kerning pair for the kerning table */
454 /* format 0. The engine now loads this table if it finds one in the */
458 /* left :: The index of the left glyph in pair. */
460 /* right :: The index of the right glyph in pair. */
462 /* value :: The kerning distance. A positive value spaces the */
463 /* glyphs, a negative one makes them closer. */
465 typedef struct TT_Kern_0_Pair_
467 FT_UShort left; /* index of left glyph in pair */
468 FT_UShort right; /* index of right glyph in pair */
469 FT_FWord value; /* kerning value */
474 /*************************************************************************/
475 /*************************************************************************/
476 /*************************************************************************/
479 /*** EMBEDDED BITMAPS SUPPORT ***/
482 /*************************************************************************/
483 /*************************************************************************/
484 /*************************************************************************/
487 /*************************************************************************/
490 /* TT_SBit_Metrics */
493 /* A structure used to hold the big metrics of a given glyph bitmap */
494 /* in a TrueType or OpenType font. These are usually found in the */
495 /* `EBDT' (Microsoft) or `bloc' (Apple) table. */
498 /* height :: The glyph height in pixels. */
500 /* width :: The glyph width in pixels. */
502 /* horiBearingX :: The horizontal left bearing. */
504 /* horiBearingY :: The horizontal top bearing. */
506 /* horiAdvance :: The horizontal advance. */
508 /* vertBearingX :: The vertical left bearing. */
510 /* vertBearingY :: The vertical top bearing. */
512 /* vertAdvance :: The vertical advance. */
514 typedef struct TT_SBit_Metrics_
519 FT_Char horiBearingX;
520 FT_Char horiBearingY;
523 FT_Char vertBearingX;
524 FT_Char vertBearingY;
530 /*************************************************************************/
533 /* TT_SBit_Small_Metrics */
536 /* A structure used to hold the small metrics of a given glyph bitmap */
537 /* in a TrueType or OpenType font. These are usually found in the */
538 /* `EBDT' (Microsoft) or the `bdat' (Apple) table. */
541 /* height :: The glyph height in pixels. */
543 /* width :: The glyph width in pixels. */
545 /* bearingX :: The left-side bearing. */
547 /* bearingY :: The top-side bearing. */
549 /* advance :: The advance width or height. */
551 typedef struct TT_SBit_Small_Metrics_
560 } TT_SBit_Small_Metrics;
563 /*************************************************************************/
566 /* TT_SBit_Line_Metrics */
569 /* A structure used to describe the text line metrics of a given */
570 /* bitmap strike, for either a horizontal or vertical layout. */
573 /* ascender :: The ascender in pixels. */
575 /* descender :: The descender in pixels. */
577 /* max_width :: The maximum glyph width in pixels. */
579 /* caret_slope_enumerator :: Rise of the caret slope, typically set */
580 /* to 1 for non-italic fonts. */
582 /* caret_slope_denominator :: Rise of the caret slope, typically set */
583 /* to 0 for non-italic fonts. */
585 /* caret_offset :: Offset in pixels to move the caret for */
586 /* proper positioning. */
588 /* min_origin_SB :: Minimum of horiBearingX (resp. */
590 /* min_advance_SB :: Minimum of */
592 /* horizontal advance - */
593 /* ( horiBearingX + width ) */
597 /* vertical advance - */
598 /* ( vertBearingY + height ) */
600 /* max_before_BL :: Maximum of horiBearingY (resp. */
603 /* min_after_BL :: Minimum of */
605 /* horiBearingY - height */
609 /* vertBearingX - width */
611 /* pads :: Unused (to make the size of the record */
612 /* a multiple of 32 bits. */
614 typedef struct TT_SBit_Line_Metrics_
619 FT_Char caret_slope_numerator;
620 FT_Char caret_slope_denominator;
621 FT_Char caret_offset;
622 FT_Char min_origin_SB;
623 FT_Char min_advance_SB;
624 FT_Char max_before_BL;
625 FT_Char min_after_BL;
628 } TT_SBit_Line_Metrics;
631 /*************************************************************************/
637 /* A TrueType/OpenType subIndexTable as defined in the `EBLC' */
638 /* (Microsoft) or `bloc' (Apple) tables. */
641 /* first_glyph :: The first glyph index in the range. */
643 /* last_glyph :: The last glyph index in the range. */
645 /* index_format :: The format of index table. Valid values are 1 */
648 /* image_format :: The format of `EBDT' image data. */
650 /* image_offset :: The offset to image data in `EBDT'. */
652 /* image_size :: For index formats 2 and 5. This is the size in */
653 /* bytes of each glyph bitmap. */
655 /* big_metrics :: For index formats 2 and 5. This is the big */
656 /* metrics for each glyph bitmap. */
658 /* num_glyphs :: For index formats 4 and 5. This is the number of */
659 /* glyphs in the code array. */
661 /* glyph_offsets :: For index formats 1 and 3. */
663 /* glyph_codes :: For index formats 4 and 5. */
665 /* table_offset :: The offset of the index table in the `EBLC' */
666 /* table. Only used during strike loading. */
668 typedef struct TT_SBit_Range
670 FT_UShort first_glyph;
671 FT_UShort last_glyph;
673 FT_UShort index_format;
674 FT_UShort image_format;
675 FT_ULong image_offset;
678 TT_SBit_Metrics metrics;
681 FT_ULong* glyph_offsets;
682 FT_UShort* glyph_codes;
684 FT_ULong table_offset;
689 /*************************************************************************/
695 /* A structure used describe a given bitmap strike in the `EBLC' */
696 /* (Microsoft) or `bloc' (Apple) tables. */
699 /* num_index_ranges :: The number of index ranges. */
701 /* index_ranges :: An array of glyph index ranges. */
703 /* color_ref :: Unused. `color_ref' is put in for future */
704 /* enhancements, but these fields are already */
705 /* in use by other platforms (e.g. Newton). */
706 /* For details, please see */
708 /* http://fonts.apple.com/ */
709 /* TTRefMan/RM06/Chap6bloc.html */
711 /* hori :: The line metrics for horizontal layouts. */
713 /* vert :: The line metrics for vertical layouts. */
715 /* start_glyph :: The lowest glyph index for this strike. */
717 /* end_glyph :: The highest glyph index for this strike. */
719 /* x_ppem :: The number of horizontal pixels per EM. */
721 /* y_ppem :: The number of vertical pixels per EM. */
723 /* bit_depth :: The bit depth. Valid values are 1, 2, 4, */
726 /* flags :: Is this a vertical or horizontal strike? For */
727 /* details, please see */
729 /* http://fonts.apple.com/ */
730 /* TTRefMan/RM06/Chap6bloc.html */
732 typedef struct TT_SBit_Strike_
735 TT_SBit_Range* sbit_ranges;
736 FT_ULong ranges_offset;
740 TT_SBit_Line_Metrics hori;
741 TT_SBit_Line_Metrics vert;
743 FT_UShort start_glyph;
755 /*************************************************************************/
758 /* TT_SBit_Component */
761 /* A simple structure to describe a compound sbit element. */
764 /* glyph_code :: The element's glyph index. */
766 /* x_offset :: The element's left bearing. */
768 /* y_offset :: The element's top bearing. */
770 typedef struct TT_SBit_Component_
772 FT_UShort glyph_code;
779 /*************************************************************************/
785 /* A structure used describe a given bitmap scaling table, as defined */
786 /* in the `EBSC' table. */
789 /* hori :: The horizontal line metrics. */
791 /* vert :: The vertical line metrics. */
793 /* x_ppem :: The number of horizontal pixels per EM. */
795 /* y_ppem :: The number of vertical pixels per EM. */
797 /* x_ppem_substitute :: Substitution x_ppem value. */
799 /* y_ppem_substitute :: Substitution y_ppem value. */
801 typedef struct TT_SBit_Scale_
803 TT_SBit_Line_Metrics hori;
804 TT_SBit_Line_Metrics vert;
809 FT_Byte x_ppem_substitute;
810 FT_Byte y_ppem_substitute;
815 /*************************************************************************/
816 /*************************************************************************/
817 /*************************************************************************/
820 /*** POSTSCRIPT GLYPH NAMES SUPPORT ***/
823 /*************************************************************************/
824 /*************************************************************************/
825 /*************************************************************************/
828 /*************************************************************************/
834 /* Postscript names sub-table, format 2.0. Stores the PS name of */
835 /* each glyph in the font face. */
838 /* num_glyphs :: The number of named glyphs in the table. */
840 /* num_names :: The number of PS names stored in the table. */
842 /* glyph_indices :: The indices of the glyphs in the names arrays. */
844 /* glyph_names :: The PS names not in Mac Encoding. */
846 typedef struct TT_Post_20_
848 FT_UShort num_glyphs;
850 FT_UShort* glyph_indices;
851 FT_Char** glyph_names;
856 /*************************************************************************/
862 /* Postscript names sub-table, format 2.5. Stores the PS name of */
863 /* each glyph in the font face. */
866 /* num_glyphs :: The number of glyphs in the table. */
868 /* offsets :: An array of signed offsets in a normal Mac */
869 /* Postscript name encoding. */
871 typedef struct TT_Post_25_
873 FT_UShort num_glyphs;
879 /*************************************************************************/
885 /* Postscript names table, either format 2.0 or 2.5. */
888 /* loaded :: A flag to indicate whether the PS names are loaded. */
890 /* format_20 :: The sub-table used for format 2.0. */
892 /* format_25 :: The sub-table used for format 2.5. */
894 typedef struct TT_Post_Names_
900 TT_Post_20 format_20;
901 TT_Post_25 format_25;
908 /*************************************************************************/
909 /*************************************************************************/
910 /*************************************************************************/
913 /*** TRUETYPE CHARMAPS SUPPORT ***/
916 /*************************************************************************/
917 /*************************************************************************/
918 /*************************************************************************/
923 typedef struct TT_CMap0_
925 FT_ULong language; /* for Mac fonts (originally ushort) */
927 FT_Byte* glyphIdArray;
934 typedef struct TT_CMap2SubHeader_
936 FT_UShort firstCode; /* first valid low byte */
937 FT_UShort entryCount; /* number of valid low bytes */
938 FT_Short idDelta; /* delta value to glyphIndex */
939 FT_UShort idRangeOffset; /* offset from here to 1st code */
944 typedef struct TT_CMap2_
946 FT_ULong language; /* for Mac fonts (originally ushort) */
948 FT_UShort* subHeaderKeys;
949 /* high byte mapping table */
950 /* value = subHeader index * 8 */
952 TT_CMap2SubHeader* subHeaders;
953 FT_UShort* glyphIdArray;
954 FT_UShort numGlyphId; /* control value */
961 typedef struct TT_CMap4Segment_
964 FT_UShort startCount;
966 FT_UShort idRangeOffset;
971 typedef struct TT_CMap4_
973 FT_ULong language; /* for Mac fonts (originally ushort) */
975 FT_UShort segCountX2; /* number of segments * 2 */
976 FT_UShort searchRange; /* these parameters can be used */
977 FT_UShort entrySelector; /* for a binary search */
978 FT_UShort rangeShift;
980 TT_CMap4Segment* segments;
981 FT_UShort* glyphIdArray;
982 FT_UShort numGlyphId; /* control value */
984 TT_CMap4Segment* last_segment; /* last used segment; this is a small */
985 /* cache to potentially increase speed */
991 typedef struct TT_CMap6_
993 FT_ULong language; /* for Mac fonts (originally ushort) */
995 FT_UShort firstCode; /* first character code of subrange */
996 FT_UShort entryCount; /* number of character codes in subrange */
998 FT_UShort* glyphIdArray;
1003 /* auxiliary table for format 8 and 12 */
1005 typedef struct TT_CMapGroup_
1007 FT_ULong startCharCode;
1008 FT_ULong endCharCode;
1009 FT_ULong startGlyphID;
1014 /* FreeType handles format 8 and 12 identically. It is not necessary to
1015 cover mixed 16bit and 32bit codes since FreeType always uses FT_ULong
1016 for input character codes -- converting Unicode surrogates to 32bit
1017 character codes must be done by the application. */
1019 typedef struct TT_CMap8_12_
1021 FT_ULong language; /* for Mac fonts */
1024 TT_CMapGroup* groups;
1026 TT_CMapGroup* last_group; /* last used group; this is a small */
1027 /* cache to potentially increase speed */
1033 typedef struct TT_CMap10_
1035 FT_ULong language; /* for Mac fonts */
1037 FT_ULong startCharCode; /* first character covered */
1038 FT_ULong numChars; /* number of characters covered */
1045 typedef struct TT_CMapTable_ TT_CMapTable;
1049 (*TT_CharMap_Func)( TT_CMapTable* charmap,
1050 FT_ULong char_code );
1054 struct TT_CMapTable_
1056 FT_UShort platformID;
1057 FT_UShort platformEncodingID;
1059 FT_ULong length; /* must be ulong for formats 8, 10, and 12 */
1070 TT_CMap8_12 cmap8_12;
1074 TT_CharMap_Func get_index;
1078 /*************************************************************************/
1084 /* The TrueType character map object type. */
1087 /* root :: The parent character map structure. */
1089 /* cmap :: The used character map. */
1091 typedef struct TT_CharMapRec_
1099 /*************************************************************************/
1100 /*************************************************************************/
1101 /*************************************************************************/
1104 /*** ORIGINAL TT_FACE CLASS DEFINITION ***/
1107 /*************************************************************************/
1108 /*************************************************************************/
1109 /*************************************************************************/
1112 /*************************************************************************/
1114 /* This structure/class is defined here because it is common to the */
1115 /* following formats: TTF, OpenType-TT, and OpenType-CFF. */
1117 /* Note, however, that the classes TT_Size, TT_GlyphSlot, and TT_CharMap */
1118 /* are not shared between font drivers, and are thus defined normally in */
1121 /*************************************************************************/
1124 /*************************************************************************/
1130 /* A handle to a TrueType face/font object. A TT_Face encapsulates */
1131 /* the resolution and scaling independent parts of a TrueType font */
1135 /* The TT_Face structure is also used as a `parent class' for the */
1136 /* OpenType-CFF class (T2_Face). */
1138 typedef struct TT_FaceRec_* TT_Face;
1141 /*************************************************************************/
1147 /* A handle to a TrueType character mapping object. */
1149 typedef struct TT_CharMapRec_* TT_CharMap;
1152 /* a function type used for the truetype bytecode interpreter hooks */
1154 (*TT_Interpreter)( void* exec_context );
1156 /* forward declaration */
1157 typedef struct TT_Loader_ TT_Loader;
1160 /*************************************************************************/
1163 /* TT_Goto_Table_Func */
1166 /* Seeks a stream to the start of a given TrueType table. */
1169 /* face :: A handle to the target face object. */
1171 /* tag :: A 4-byte tag used to name the table. */
1173 /* stream :: The input stream. */
1176 /* length :: The length of the table in bytes. Set to 0 if not */
1180 /* FreeType error code. 0 means success. */
1183 /* The stream cursor must be at the font file's origin. */
1186 (*TT_Goto_Table_Func)( TT_Face face,
1192 /*************************************************************************/
1195 /* TT_Access_Glyph_Frame_Func */
1198 /* Seeks a stream to the start of a given glyph element, and opens a */
1202 /* loader :: The current TrueType glyph loader object. */
1204 /* glyph index :: The index of the glyph to access. */
1206 /* offset :: The offset of the glyph according to the */
1207 /* `locations' table. */
1209 /* byte_count :: The size of the frame in bytes. */
1212 /* FreeType error code. 0 means success. */
1215 /* This function is normally equivalent to FILE_Seek(offset) */
1216 /* followed by ACCESS_Frame(byte_count) with the loader's stream, but */
1217 /* alternative formats (e.g. compressed ones) might use something */
1221 (*TT_Access_Glyph_Frame_Func)( TT_Loader* loader,
1222 FT_UInt glyph_index,
1224 FT_UInt byte_count );
1227 /*************************************************************************/
1230 /* TT_Load_Glyph_Element_Func */
1233 /* Reads one glyph element (its header, a simple glyph, or a */
1234 /* composite) from the loader's current stream frame. */
1237 /* loader :: The current TrueType glyph loader object. */
1240 /* FreeType error code. 0 means success. */
1243 (*TT_Load_Glyph_Element_Func)( TT_Loader* loader );
1246 /*************************************************************************/
1249 /* TT_Forget_Glyph_Frame_Func */
1252 /* Closes the current loader stream frame for the glyph. */
1255 /* loader :: The current TrueType glyph loader object. */
1258 (*TT_Forget_Glyph_Frame_Func)( TT_Loader* loader );
1262 /*************************************************************************/
1264 /* TrueType Face Type */
1270 /* The TrueType face class. These objects model the resolution and */
1271 /* point-size independent data found in a TrueType font file. */
1274 /* root :: The base FT_Face structure, managed by the */
1277 /* ttc_header :: The TrueType collection header, used when */
1278 /* the file is a `ttc' rather than a `ttf'. */
1279 /* For ordinary font files, the field */
1280 /* `ttc_header.count' is set to 0. */
1282 /* format_tag :: The font format tag. */
1284 /* num_tables :: The number of TrueType tables in this font */
1287 /* dir_tables :: The directory of TrueType tables for this */
1290 /* header :: The font's font header (`head' table). */
1291 /* Read on font opening. */
1293 /* horizontal :: The font's horizontal header (`hhea' */
1294 /* table). This field also contains the */
1295 /* associated horizontal metrics table */
1298 /* max_profile :: The font's maximum profile table. Read on */
1299 /* font opening. Note that some maximum */
1300 /* values cannot be taken directly from this */
1301 /* table. We thus define additional fields */
1302 /* below to hold the computed maxima. */
1304 /* max_components :: The maximum number of glyph components */
1305 /* required to load any composite glyph from */
1306 /* this font. Used to size the load stack. */
1308 /* vertical_info :: A boolean which is set when the font file */
1309 /* contains vertical metrics. If not, the */
1310 /* value of the `vertical' field is */
1313 /* vertical :: The font's vertical header (`vhea' table). */
1314 /* This field also contains the associated */
1315 /* vertical metrics table (`vmtx'), if found. */
1316 /* IMPORTANT: The contents of this field is */
1317 /* undefined if the `verticalInfo' field is */
1320 /* num_names :: The number of name records within this */
1321 /* TrueType font. */
1323 /* name_table :: The table of name records (`name'). */
1325 /* os2 :: The font's OS/2 table (`OS/2'). */
1327 /* postscript :: The font's PostScript table (`post' */
1328 /* table). The PostScript glyph names are */
1329 /* not loaded by the driver on face opening. */
1330 /* See the `ttpost' module for more details. */
1332 /* num_charmaps :: The number of character mappings in the */
1335 /* charmaps :: The array of charmap objects for this font */
1336 /* file. Note that this field is a typeless */
1337 /* pointer. The Reason is that the format of */
1338 /* charmaps varies with the underlying font */
1339 /* format and cannot be determined here. */
1341 /* goto_table :: A function called by each TrueType table */
1342 /* loader to position a stream's cursor to */
1343 /* the start of a given table according to */
1344 /* its tag. It defaults to TT_Goto_Face but */
1345 /* can be different for strange formats (e.g. */
1348 /* access_glyph_frame :: XXX */
1350 /* read_glyph_header :: XXX */
1352 /* read_simple_glyph :: XXX */
1354 /* read_composite_glyph :: XXX */
1356 /* forget_glyph_frame :: XXX */
1358 /* sfnt :: A pointer to the SFNT `driver' interface. */
1360 /* psnames :: A pointer to the `PSNames' module */
1363 /* hdmx :: The face's horizontal device metrics */
1364 /* (`hdmx' table). This table is optional in */
1365 /* TrueType/OpenType fonts. */
1367 /* gasp :: The grid-fitting and scaling properties */
1368 /* table (`gasp'). This table is optional in */
1369 /* TrueType/OpenType fonts. */
1373 /* num_sbit_strikes :: The number of sbit strikes, i.e., bitmap */
1374 /* sizes, embedded in this font. */
1376 /* sbit_strikes :: An array of sbit strikes embedded in this */
1377 /* font. This table is optional in a */
1378 /* TrueType/OpenType font. */
1380 /* num_sbit_scales :: The number of sbit scales for this font. */
1382 /* sbit_scales :: Array of sbit scales embedded in this */
1383 /* font. This table is optional in a */
1384 /* TrueType/OpenType font. */
1386 /* postscript_names :: A table used to store the Postscript names */
1387 /* of the glyphs for this font. See the */
1388 /* file `ttconfig.h' for comments on the */
1389 /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES option. */
1391 /* num_locations :: The number of glyph locations in this */
1392 /* TrueType file. This should be */
1393 /* identical to the number of glyphs. */
1394 /* Ignored for Type 2 fonts. */
1396 /* glyph_locations :: An array of longs. These are offsets to */
1397 /* glyph data within the `glyf' table. */
1398 /* Ignored for Type 2 font faces. */
1400 /* font_program_size :: Size in bytecodes of the face's font */
1401 /* program. 0 if none defined. Ignored for */
1404 /* font_program :: The face's font program (bytecode stream) */
1405 /* executed at load time, also used during */
1406 /* glyph rendering. Comes from the `fpgm' */
1407 /* table. Ignored for Type 2 font fonts. */
1409 /* cvt_program_size :: The size in bytecodes of the face's cvt */
1410 /* program. Ignored for Type 2 fonts. */
1412 /* cvt_program :: The face's cvt program (bytecode stream) */
1413 /* executed each time an instance/size is */
1414 /* changed/reset. Comes from the `prep' */
1415 /* table. Ignored for Type 2 fonts. */
1417 /* cvt_size :: Size of the control value table (in */
1418 /* entries). Ignored for Type 2 fonts. */
1420 /* cvt :: The face's original control value table. */
1421 /* Coordinates are expressed in unscaled font */
1422 /* units. Comes from the `cvt ' table. */
1423 /* Ignored for Type 2 fonts. */
1425 /* num_kern_pairs :: The number of kerning pairs present in the */
1426 /* font file. The engine only loads the */
1427 /* first horizontal format 0 kern table it */
1428 /* finds in the font file. You should use */
1429 /* the `ttxkern' structures if you want to */
1430 /* access other kerning tables. Ignored */
1431 /* for Type 2 fonts. */
1433 /* kern_table_index :: The index of the kerning table in the font */
1434 /* kerning directory. Only used by the */
1435 /* ttxkern extension to avoid data */
1436 /* duplication. Ignored for Type 2 fonts. */
1438 /* interpreter :: A pointer to the TrueType bytecode */
1439 /* interpreters field is also used to hook */
1440 /* the debugger in `ttdebug'. */
1444 typedef struct TT_FaceRec_
1448 TTC_Header ttc_header;
1450 FT_ULong format_tag;
1451 FT_UShort num_tables;
1452 TT_Table* dir_tables;
1454 TT_Header header; /* TrueType header table */
1455 TT_HoriHeader horizontal; /* TrueType horizontal header */
1457 TT_MaxProfile max_profile;
1458 FT_ULong max_components;
1460 FT_Bool vertical_info;
1461 TT_VertHeader vertical; /* TT Vertical header, if present */
1463 FT_UShort num_names; /* number of name records */
1464 TT_NameTable name_table; /* name table */
1466 TT_OS2 os2; /* TrueType OS/2 table */
1467 TT_Postscript postscript; /* TrueType Postscript table */
1469 FT_Int num_charmaps;
1470 TT_CharMap charmaps; /* array of TT_CharMapRec */
1472 TT_Goto_Table_Func goto_table;
1474 TT_Access_Glyph_Frame_Func access_glyph_frame;
1475 TT_Load_Glyph_Element_Func read_glyph_header;
1476 TT_Load_Glyph_Element_Func read_simple_glyph;
1477 TT_Load_Glyph_Element_Func read_composite_glyph;
1478 TT_Forget_Glyph_Frame_Func forget_glyph_frame;
1480 /* a typeless pointer to the SFNT_Interface table used to load */
1481 /* the basic TrueType tables in the face object */
1484 /* a typeless pointer to the PSNames_Interface table used to */
1485 /* handle glyph names <-> unicode & Mac values */
1488 /***********************************************************************/
1490 /* Optional TrueType/OpenType tables */
1492 /***********************************************************************/
1494 /* horizontal device metrics */
1497 /* grid-fitting and scaling table */
1498 TT_Gasp gasp; /* the `gasp' table */
1503 /* embedded bitmaps support */
1504 FT_Int num_sbit_strikes;
1505 TT_SBit_Strike* sbit_strikes;
1507 FT_Int num_sbit_scales;
1508 TT_SBit_Scale* sbit_scales;
1510 /* postscript names table */
1511 TT_Post_Names postscript_names;
1514 /***********************************************************************/
1516 /* TrueType-specific fields (ignored by the OTF-Type2 driver) */
1518 /***********************************************************************/
1520 /* the glyph locations */
1521 FT_UShort num_locations;
1522 FT_Long* glyph_locations;
1524 /* the font program, if any */
1525 FT_ULong font_program_size;
1526 FT_Byte* font_program;
1528 /* the cvt program, if any */
1529 FT_ULong cvt_program_size;
1530 FT_Byte* cvt_program;
1532 /* the original, unscaled, control value table */
1536 /* the format 0 kerning table, if any */
1537 FT_Int num_kern_pairs;
1538 FT_Int kern_table_index;
1539 TT_Kern_0_Pair* kern_pairs;
1541 /* A pointer to the bytecode interpreter to use. This is also */
1542 /* used to hook the debugger for the `ttdebug' utility. */
1543 TT_Interpreter interpreter;
1546 /***********************************************************************/
1548 /* Other tables or fields. This is used by derivative formats like */
1551 /***********************************************************************/
1558 /*************************************************************************/
1564 /* A glyph zone is used to load, scale and hint glyph outline */
1568 /* memory :: A handle to the memory manager. */
1570 /* max_points :: The maximal size in points of the zone. */
1572 /* max_contours :: Max size in links contours of thez one. */
1574 /* n_points :: The current number of points in the zone. */
1576 /* n_contours :: The current number of contours in the zone. */
1578 /* org :: The original glyph coordinates (font */
1579 /* units/scaled). */
1581 /* cur :: The current glyph coordinates (scaled/hinted). */
1583 /* tags :: The point control tags. */
1585 /* contours :: The contours end points. */
1587 typedef struct TT_GlyphZone_
1590 FT_UShort max_points;
1591 FT_UShort max_contours;
1592 FT_UShort n_points; /* number of points in zone */
1593 FT_Short n_contours; /* number of contours */
1595 FT_Vector* org; /* original point coordinates */
1596 FT_Vector* cur; /* current point coordinates */
1598 FT_Byte* tags; /* current touch flags */
1599 FT_UShort* contours; /* contour end points */
1604 /* handle to execution context */
1605 typedef struct TT_ExecContextRec_* TT_ExecContext;
1607 /* glyph loader structure */
1613 FT_GlyphLoader* gloader;
1615 FT_ULong load_flags;
1616 FT_UInt glyph_index;
1621 FT_Short n_contours;
1623 FT_Int left_bearing;
1627 FT_Bool preserve_pps;
1631 FT_ULong glyf_offset;
1633 /* the zone where we load our glyphs */
1637 TT_ExecContext exec;
1638 FT_Byte* instructions;
1641 /* for possible extensibility in other formats */
1649 #endif /* __TTTYPES_H__ */