1 /***************************************************************************/
5 /* Basic SFNT/TrueType type definitions and interface (specification */
8 /* Copyright 1996-2001, 2002 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_HeaderRec_
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_HeaderRec_
99 FT_UShort search_range;
100 FT_UShort entry_selector;
101 FT_UShort range_shift;
103 FT_ULong offset; /* not in file */
105 } SFNT_HeaderRec, *SFNT_Header;
108 /*************************************************************************/
114 /* This structure models a TrueType table directory. It is used to */
115 /* access the various tables of the font face. */
118 /* version :: The version number; starts with 0x00010000. */
120 /* numTables :: The number of tables. */
122 /* searchRange :: Unused. */
124 /* entrySelector :: Unused. */
126 /* rangeShift :: Unused. */
129 /* This structure is only used during font opening. */
131 typedef struct TT_TableDirRec_
133 FT_Fixed version; /* should be 0x10000 */
134 FT_UShort numTables; /* number of tables */
136 FT_UShort searchRange; /* These parameters are only used */
137 FT_UShort entrySelector; /* for a dichotomy search in the */
138 FT_UShort rangeShift; /* directory. We ignore them. */
143 /*************************************************************************/
149 /* This structure describes a given table of a TrueType font. */
152 /* Tag :: A four-bytes tag describing the table. */
154 /* CheckSum :: The table checksum. This value can be ignored. */
156 /* Offset :: The offset of the table from the start of the TrueType */
157 /* font in its resource. */
159 /* Length :: The table length (in bytes). */
161 typedef struct TT_TableRec_
163 FT_ULong Tag; /* table type */
164 FT_ULong CheckSum; /* table checksum */
165 FT_ULong Offset; /* table file offset */
166 FT_ULong Length; /* table length */
168 } TT_TableRec, *TT_Table;
171 /*************************************************************************/
177 /* This structure describes the directory of the `cmap' table, */
178 /* containing the font's character mappings table. */
181 /* tableVersionNumber :: The version number. */
183 /* numCMaps :: The number of charmaps in the font. */
186 /* This structure is only used during font loading. */
188 typedef struct TT_CMapDirRec_
190 FT_UShort tableVersionNumber;
193 } TT_CMapDirRec, *TT_CMapDir;
196 /*************************************************************************/
199 /* TT_CMapDirEntryRec */
202 /* This structure describes a charmap in a TrueType font. */
205 /* platformID :: An ID used to specify for which platform this */
206 /* charmap is defined (FreeType manages all platforms). */
208 /* encodingID :: A platform-specific ID used to indicate which source */
209 /* encoding is used in this charmap. */
211 /* offset :: The offset of the charmap relative to the start of */
212 /* the `cmap' table. */
215 /* This structure is only used during font loading. */
217 typedef struct TT_CMapDirEntryRec_
219 FT_UShort platformID;
220 FT_UShort platformEncodingID;
223 } TT_CMapDirEntryRec, *TT_CMapDirEntry;
226 /*************************************************************************/
229 /* TT_LongMetricsRec */
232 /* A structure modeling the long metrics of the `hmtx' and `vmtx' */
233 /* TrueType tables. The values are expressed in font units. */
236 /* advance :: The advance width or height for the glyph. */
238 /* bearing :: The left-side or top-side bearing for the glyph. */
240 typedef struct TT_LongMetricsRec_
245 } TT_LongMetricsRec, *TT_LongMetrics;
248 /*************************************************************************/
251 /* TT_ShortMetrics */
254 /* A simple type to model the short metrics of the `hmtx' and `vmtx' */
257 typedef FT_Short TT_ShortMetrics;
260 /*************************************************************************/
263 /* TT_NameEntryRec */
266 /* A structure modeling TrueType name records. Name records are used */
267 /* to store important strings like family name, style name, */
268 /* copyright, etc. in _localized_ versions (i.e., language, encoding, */
272 /* platformID :: The ID of the name's encoding platform. */
274 /* encodingID :: The platform-specific ID for the name's encoding. */
276 /* languageID :: The platform-specific ID for the name's language. */
278 /* nameID :: The ID specifying what kind of name this is. */
280 /* stringLength :: The length of the string in bytes. */
282 /* stringOffset :: The offset to the string in the `name' table. */
284 /* string :: A pointer to the string's bytes. Note that these */
285 /* are usually UTF-16 encoded characters. */
287 typedef struct TT_NameEntryRec_
289 FT_UShort platformID;
290 FT_UShort encodingID;
291 FT_UShort languageID;
293 FT_UShort stringLength;
294 FT_ULong stringOffset;
296 /* this last field is not defined in the spec */
297 /* but used by the FreeType engine */
301 } TT_NameEntryRec, *TT_NameEntry;
304 /*************************************************************************/
307 /* TT_NameTableRec */
310 /* A structure modeling the TrueType name table. */
313 /* format :: The format of the name table. */
315 /* numNameRecords :: The number of names in table. */
317 /* storageOffset :: The offset of the name table in the `name' */
318 /* TrueType table. */
320 /* names :: An array of name records. */
322 /* stream :: the file's input stream. */
324 typedef struct TT_NameTableRec_
327 FT_UInt numNameRecords;
328 FT_UInt storageOffset;
329 TT_NameEntryRec* names;
332 } TT_NameTableRec, *TT_NameTable;
335 /*************************************************************************/
336 /*************************************************************************/
337 /*************************************************************************/
340 /*** OPTIONAL TRUETYPE/OPENTYPE TABLES DEFINITIONS ***/
343 /*************************************************************************/
344 /*************************************************************************/
345 /*************************************************************************/
348 /*************************************************************************/
351 /* TT_GaspRangeRec */
354 /* A tiny structure used to model a gasp range according to the */
355 /* TrueType specification. */
358 /* maxPPEM :: The maximum ppem value to which `gaspFlag' applies. */
360 /* gaspFlag :: A flag describing the grid-fitting and anti-aliasing */
361 /* modes to be used. */
363 typedef struct TT_GaspRangeRec_
368 } TT_GaspRangeRec, *TT_GaspRange;
371 #define TT_GASP_GRIDFIT 0x01
372 #define TT_GASP_DOGRAY 0x02
375 /*************************************************************************/
381 /* A structure modeling the TrueType `gasp' table used to specify */
382 /* grid-fitting and anti-aliasing behaviour. */
385 /* version :: The version number. */
387 /* numRanges :: The number of gasp ranges in table. */
389 /* gaspRanges :: An array of gasp ranges. */
391 typedef struct TT_Gasp_
395 TT_GaspRange gaspRanges;
400 /*************************************************************************/
403 /* TT_HdmxEntryRec */
406 /* A small structure used to model the pre-computed widths of a given */
407 /* size. They are found in the `hdmx' table. */
410 /* ppem :: The pixels per EM value at which these metrics apply. */
412 /* max_width :: The maximum advance width for this metric. */
414 /* widths :: An array of widths. Note: These are 8-bit bytes. */
416 typedef struct TT_HdmxEntryRec_
422 } TT_HdmxEntryRec, *TT_HdmxEntry;
425 /*************************************************************************/
431 /* A structure used to model the `hdmx' table, which contains */
432 /* pre-computed widths for a set of given sizes/dimensions. */
435 /* version :: The version number. */
437 /* num_records :: The number of hdmx records. */
439 /* records :: An array of hdmx records. */
441 typedef struct TT_HdmxRec_
444 FT_Short num_records;
445 TT_HdmxEntry records;
447 } TT_HdmxRec, *TT_Hdmx;
450 /*************************************************************************/
453 /* TT_Kern0_PairRec */
456 /* A structure used to model a kerning pair for the kerning table */
457 /* format 0. The engine now loads this table if it finds one in the */
461 /* left :: The index of the left glyph in pair. */
463 /* right :: The index of the right glyph in pair. */
465 /* value :: The kerning distance. A positive value spaces the */
466 /* glyphs, a negative one makes them closer. */
468 typedef struct TT_Kern0_PairRec_
470 FT_UShort left; /* index of left glyph in pair */
471 FT_UShort right; /* index of right glyph in pair */
472 FT_FWord value; /* kerning value */
474 } TT_Kern0_PairRec, *TT_Kern0_Pair;
477 /*************************************************************************/
478 /*************************************************************************/
479 /*************************************************************************/
482 /*** EMBEDDED BITMAPS SUPPORT ***/
485 /*************************************************************************/
486 /*************************************************************************/
487 /*************************************************************************/
490 /*************************************************************************/
493 /* TT_SBit_MetricsRec */
496 /* A structure used to hold the big metrics of a given glyph bitmap */
497 /* in a TrueType or OpenType font. These are usually found in the */
498 /* `EBDT' (Microsoft) or `bloc' (Apple) table. */
501 /* height :: The glyph height in pixels. */
503 /* width :: The glyph width in pixels. */
505 /* horiBearingX :: The horizontal left bearing. */
507 /* horiBearingY :: The horizontal top bearing. */
509 /* horiAdvance :: The horizontal advance. */
511 /* vertBearingX :: The vertical left bearing. */
513 /* vertBearingY :: The vertical top bearing. */
515 /* vertAdvance :: The vertical advance. */
517 typedef struct TT_SBit_MetricsRec_
522 FT_Char horiBearingX;
523 FT_Char horiBearingY;
526 FT_Char vertBearingX;
527 FT_Char vertBearingY;
530 } TT_SBit_MetricsRec, *TT_SBit_Metrics;
533 /*************************************************************************/
536 /* TT_SBit_SmallMetricsRec */
539 /* A structure used to hold the small metrics of a given glyph bitmap */
540 /* in a TrueType or OpenType font. These are usually found in the */
541 /* `EBDT' (Microsoft) or the `bdat' (Apple) table. */
544 /* height :: The glyph height in pixels. */
546 /* width :: The glyph width in pixels. */
548 /* bearingX :: The left-side bearing. */
550 /* bearingY :: The top-side bearing. */
552 /* advance :: The advance width or height. */
554 typedef struct TT_SBit_Small_Metrics_
563 } TT_SBit_SmallMetricsRec, *TT_SBit_SmallMetrics;
566 /*************************************************************************/
569 /* TT_SBit_LineMetricsRec */
572 /* A structure used to describe the text line metrics of a given */
573 /* bitmap strike, for either a horizontal or vertical layout. */
576 /* ascender :: The ascender in pixels. */
578 /* descender :: The descender in pixels. */
580 /* max_width :: The maximum glyph width in pixels. */
582 /* caret_slope_enumerator :: Rise of the caret slope, typically set */
583 /* to 1 for non-italic fonts. */
585 /* caret_slope_denominator :: Rise of the caret slope, typically set */
586 /* to 0 for non-italic fonts. */
588 /* caret_offset :: Offset in pixels to move the caret for */
589 /* proper positioning. */
591 /* min_origin_SB :: Minimum of horiBearingX (resp. */
593 /* min_advance_SB :: Minimum of */
595 /* horizontal advance - */
596 /* ( horiBearingX + width ) */
600 /* vertical advance - */
601 /* ( vertBearingY + height ) */
603 /* max_before_BL :: Maximum of horiBearingY (resp. */
606 /* min_after_BL :: Minimum of */
608 /* horiBearingY - height */
612 /* vertBearingX - width */
614 /* pads :: Unused (to make the size of the record */
615 /* a multiple of 32 bits. */
617 typedef struct TT_SBit_LineMetricsRec_
622 FT_Char caret_slope_numerator;
623 FT_Char caret_slope_denominator;
624 FT_Char caret_offset;
625 FT_Char min_origin_SB;
626 FT_Char min_advance_SB;
627 FT_Char max_before_BL;
628 FT_Char min_after_BL;
631 } TT_SBit_LineMetricsRec, *TT_SBit_LineMetrics;
634 /*************************************************************************/
637 /* TT_SBit_RangeRec */
640 /* A TrueType/OpenType subIndexTable as defined in the `EBLC' */
641 /* (Microsoft) or `bloc' (Apple) tables. */
644 /* first_glyph :: The first glyph index in the range. */
646 /* last_glyph :: The last glyph index in the range. */
648 /* index_format :: The format of index table. Valid values are 1 */
651 /* image_format :: The format of `EBDT' image data. */
653 /* image_offset :: The offset to image data in `EBDT'. */
655 /* image_size :: For index formats 2 and 5. This is the size in */
656 /* bytes of each glyph bitmap. */
658 /* big_metrics :: For index formats 2 and 5. This is the big */
659 /* metrics for each glyph bitmap. */
661 /* num_glyphs :: For index formats 4 and 5. This is the number of */
662 /* glyphs in the code array. */
664 /* glyph_offsets :: For index formats 1 and 3. */
666 /* glyph_codes :: For index formats 4 and 5. */
668 /* table_offset :: The offset of the index table in the `EBLC' */
669 /* table. Only used during strike loading. */
671 typedef struct TT_SBit_RangeRec
673 FT_UShort first_glyph;
674 FT_UShort last_glyph;
676 FT_UShort index_format;
677 FT_UShort image_format;
678 FT_ULong image_offset;
681 TT_SBit_MetricsRec metrics;
684 FT_ULong* glyph_offsets;
685 FT_UShort* glyph_codes;
687 FT_ULong table_offset;
689 } TT_SBit_RangeRec, *TT_SBit_Range;
692 /*************************************************************************/
695 /* TT_SBit_StrikeRec */
698 /* A structure used describe a given bitmap strike in the `EBLC' */
699 /* (Microsoft) or `bloc' (Apple) tables. */
702 /* num_index_ranges :: The number of index ranges. */
704 /* index_ranges :: An array of glyph index ranges. */
706 /* color_ref :: Unused. `color_ref' is put in for future */
707 /* enhancements, but these fields are already */
708 /* in use by other platforms (e.g. Newton). */
709 /* For details, please see */
711 /* http://fonts.apple.com/ */
712 /* TTRefMan/RM06/Chap6bloc.html */
714 /* hori :: The line metrics for horizontal layouts. */
716 /* vert :: The line metrics for vertical layouts. */
718 /* start_glyph :: The lowest glyph index for this strike. */
720 /* end_glyph :: The highest glyph index for this strike. */
722 /* x_ppem :: The number of horizontal pixels per EM. */
724 /* y_ppem :: The number of vertical pixels per EM. */
726 /* bit_depth :: The bit depth. Valid values are 1, 2, 4, */
729 /* flags :: Is this a vertical or horizontal strike? For */
730 /* details, please see */
732 /* http://fonts.apple.com/ */
733 /* TTRefMan/RM06/Chap6bloc.html */
735 typedef struct TT_SBit_StrikeRec_
738 TT_SBit_Range sbit_ranges;
739 FT_ULong ranges_offset;
743 TT_SBit_LineMetricsRec hori;
744 TT_SBit_LineMetricsRec vert;
746 FT_UShort start_glyph;
755 } TT_SBit_StrikeRec, *TT_SBit_Strike;
758 /*************************************************************************/
761 /* TT_SBit_ComponentRec */
764 /* A simple structure to describe a compound sbit element. */
767 /* glyph_code :: The element's glyph index. */
769 /* x_offset :: The element's left bearing. */
771 /* y_offset :: The element's top bearing. */
773 typedef struct TT_SBit_ComponentRec_
775 FT_UShort glyph_code;
779 } TT_SBit_ComponentRec, *TT_SBit_Component;
782 /*************************************************************************/
785 /* TT_SBit_ScaleRec */
788 /* A structure used describe a given bitmap scaling table, as defined */
789 /* in the `EBSC' table. */
792 /* hori :: The horizontal line metrics. */
794 /* vert :: The vertical line metrics. */
796 /* x_ppem :: The number of horizontal pixels per EM. */
798 /* y_ppem :: The number of vertical pixels per EM. */
800 /* x_ppem_substitute :: Substitution x_ppem value. */
802 /* y_ppem_substitute :: Substitution y_ppem value. */
804 typedef struct TT_SBit_ScaleRec_
806 TT_SBit_LineMetricsRec hori;
807 TT_SBit_LineMetricsRec vert;
812 FT_Byte x_ppem_substitute;
813 FT_Byte y_ppem_substitute;
815 } TT_SBit_ScaleRec, *TT_SBit_Scale;
818 /*************************************************************************/
819 /*************************************************************************/
820 /*************************************************************************/
823 /*** POSTSCRIPT GLYPH NAMES SUPPORT ***/
826 /*************************************************************************/
827 /*************************************************************************/
828 /*************************************************************************/
831 /*************************************************************************/
837 /* Postscript names sub-table, format 2.0. Stores the PS name of */
838 /* each glyph in the font face. */
841 /* num_glyphs :: The number of named glyphs in the table. */
843 /* num_names :: The number of PS names stored in the table. */
845 /* glyph_indices :: The indices of the glyphs in the names arrays. */
847 /* glyph_names :: The PS names not in Mac Encoding. */
849 typedef struct TT_Post_20Rec_
851 FT_UShort num_glyphs;
853 FT_UShort* glyph_indices;
854 FT_Char** glyph_names;
856 } TT_Post_20Rec, *TT_Post_20;
859 /*************************************************************************/
865 /* Postscript names sub-table, format 2.5. Stores the PS name of */
866 /* each glyph in the font face. */
869 /* num_glyphs :: The number of glyphs in the table. */
871 /* offsets :: An array of signed offsets in a normal Mac */
872 /* Postscript name encoding. */
874 typedef struct TT_Post_25_
876 FT_UShort num_glyphs;
879 } TT_Post_25Rec, *TT_Post_25;
882 /*************************************************************************/
885 /* TT_Post_NamesRec */
888 /* Postscript names table, either format 2.0 or 2.5. */
891 /* loaded :: A flag to indicate whether the PS names are loaded. */
893 /* format_20 :: The sub-table used for format 2.0. */
895 /* format_25 :: The sub-table used for format 2.5. */
897 typedef struct TT_Post_NamesRec_
903 TT_Post_20Rec format_20;
904 TT_Post_25Rec format_25;
908 } TT_Post_NamesRec, *TT_Post_Names;
911 /*************************************************************************/
912 /*************************************************************************/
913 /*************************************************************************/
916 /*** TRUETYPE CHARMAPS SUPPORT ***/
919 /*************************************************************************/
920 /*************************************************************************/
921 /*************************************************************************/
926 typedef struct TT_CMap0_
928 FT_ULong language; /* for Mac fonts (originally ushort) */
930 FT_Byte* glyphIdArray;
932 } TT_CMap0Rec, *TT_CMap0;
937 typedef struct TT_CMap2SubHeaderRec_
939 FT_UShort firstCode; /* first valid low byte */
940 FT_UShort entryCount; /* number of valid low bytes */
941 FT_Short idDelta; /* delta value to glyphIndex */
942 FT_UShort idRangeOffset; /* offset from here to 1st code */
944 } TT_CMap2SubHeaderRec, *TT_CMap2SubHeader;
947 typedef struct TT_CMap2Rec_
949 FT_ULong language; /* for Mac fonts (originally ushort) */
951 FT_UShort* subHeaderKeys; /* high byte mapping table */
952 /* value = subHeader index * 8 */
953 TT_CMap2SubHeader subHeaders;
954 FT_UShort* glyphIdArray;
955 FT_UShort numGlyphId; /* control value */
957 } TT_CMap2Rec, *TT_CMap2;
962 typedef struct TT_CMap4Segment_
965 FT_UShort startCount;
967 FT_UShort idRangeOffset;
969 } TT_CMap4SegmentRec, *TT_CMap4Segment;
972 typedef struct TT_CMap4Rec_
974 FT_ULong language; /* for Mac fonts (originally ushort) */
976 FT_UShort segCountX2; /* number of segments * 2 */
977 FT_UShort searchRange; /* these parameters can be used */
978 FT_UShort entrySelector; /* for a binary search */
979 FT_UShort rangeShift;
981 TT_CMap4Segment segments;
982 FT_UShort* glyphIdArray;
983 FT_UShort numGlyphId; /* control value */
985 TT_CMap4Segment last_segment; /* last used segment; this is a small */
986 /* cache to potentially increase speed */
987 } TT_CMap4Rec, *TT_CMap4;
992 typedef struct TT_CMap6_
994 FT_ULong language; /* for Mac fonts (originally ushort) */
996 FT_UShort firstCode; /* first character code of subrange */
997 FT_UShort entryCount; /* number of character codes in subrange */
999 FT_UShort* glyphIdArray;
1001 } TT_CMap6Rec, *TT_CMap6;
1004 /* auxiliary table for format 8 and 12 */
1006 typedef struct TT_CMapGroupRec_
1008 FT_ULong startCharCode;
1009 FT_ULong endCharCode;
1010 FT_ULong startGlyphID;
1012 } TT_CMapGroupRec, *TT_CMapGroup;
1015 /* FreeType handles format 8 and 12 identically. It is not necessary to
1016 cover mixed 16bit and 32bit codes since FreeType always uses FT_ULong
1017 for input character codes -- converting Unicode surrogates to 32bit
1018 character codes must be done by the application. */
1020 typedef struct TT_CMap8_12Rec_
1022 FT_ULong language; /* for Mac fonts */
1025 TT_CMapGroup groups;
1027 TT_CMapGroup last_group; /* last used group; this is a small */
1028 /* cache to potentially increase speed */
1029 } TT_CMap8_12Rec, *TT_CMap8_12;
1034 typedef struct TT_CMap10Rec_
1036 FT_ULong language; /* for Mac fonts */
1038 FT_ULong startCharCode; /* first character covered */
1039 FT_ULong numChars; /* number of characters covered */
1043 } TT_CMap10Rec, *TT_CMap10;
1046 typedef struct TT_CMapTableRec_* TT_CMapTable;
1050 (*TT_CharMap_Func)( TT_CMapTable charmap,
1051 FT_ULong char_code );
1054 (*TT_CharNext_Func)( TT_CMapTable charmap,
1055 FT_ULong char_code );
1059 typedef struct TT_CMapTableRec_
1061 FT_UShort platformID;
1062 FT_UShort platformEncodingID;
1064 FT_ULong length; /* must be ulong for formats 8, 10, and 12 */
1075 TT_CMap8_12Rec cmap8_12;
1076 TT_CMap10Rec cmap10;
1079 TT_CharMap_Func get_index;
1080 TT_CharNext_Func get_next_char;
1085 /*************************************************************************/
1091 /* The TrueType character map object type. */
1094 /* root :: The parent character map structure. */
1096 /* cmap :: The used character map. */
1098 typedef struct TT_CharMapRec_
1101 TT_CMapTableRec cmap;
1106 /*************************************************************************/
1107 /*************************************************************************/
1108 /*************************************************************************/
1111 /*** ORIGINAL TT_FACE CLASS DEFINITION ***/
1114 /*************************************************************************/
1115 /*************************************************************************/
1116 /*************************************************************************/
1119 /*************************************************************************/
1121 /* This structure/class is defined here because it is common to the */
1122 /* following formats: TTF, OpenType-TT, and OpenType-CFF. */
1124 /* Note, however, that the classes TT_Size, TT_GlyphSlot, and TT_CharMap */
1125 /* are not shared between font drivers, and are thus defined in */
1128 /*************************************************************************/
1131 /*************************************************************************/
1137 /* A handle to a TrueType face/font object. A TT_Face encapsulates */
1138 /* the resolution and scaling independent parts of a TrueType font */
1142 /* The TT_Face structure is also used as a `parent class' for the */
1143 /* OpenType-CFF class (T2_Face). */
1145 typedef struct TT_FaceRec_* TT_Face;
1148 /*************************************************************************/
1154 /* A handle to a TrueType character mapping object. */
1156 typedef struct TT_CharMapRec_* TT_CharMap;
1159 /* a function type used for the truetype bytecode interpreter hooks */
1161 (*TT_Interpreter)( void* exec_context );
1163 /* forward declaration */
1164 typedef struct TT_LoaderRec_* TT_Loader;
1167 /*************************************************************************/
1170 /* TT_Loader_GotoTableFunc */
1173 /* Seeks a stream to the start of a given TrueType table. */
1176 /* face :: A handle to the target face object. */
1178 /* tag :: A 4-byte tag used to name the table. */
1180 /* stream :: The input stream. */
1183 /* length :: The length of the table in bytes. Set to 0 if not */
1187 /* FreeType error code. 0 means success. */
1190 /* The stream cursor must be at the font file's origin. */
1193 (*TT_Loader_GotoTableFunc)( TT_Face face,
1199 /*************************************************************************/
1202 /* TT_Loader_StartGlyphFunc */
1205 /* Seeks a stream to the start of a given glyph element, and opens a */
1209 /* loader :: The current TrueType glyph loader object. */
1211 /* glyph index :: The index of the glyph to access. */
1213 /* offset :: The offset of the glyph according to the */
1214 /* `locations' table. */
1216 /* byte_count :: The size of the frame in bytes. */
1219 /* FreeType error code. 0 means success. */
1222 /* This function is normally equivalent to FT_STREAM_SEEK(offset) */
1223 /* followed by FT_FRAME_ENTER(byte_count) with the loader's stream, */
1224 /* but alternative formats (e.g. compressed ones) might use something */
1228 (*TT_Loader_StartGlyphFunc)( TT_Loader loader,
1229 FT_UInt glyph_index,
1231 FT_UInt byte_count );
1234 /*************************************************************************/
1237 /* TT_Loader_ReadGlyphFunc */
1240 /* Reads one glyph element (its header, a simple glyph, or a */
1241 /* composite) from the loader's current stream frame. */
1244 /* loader :: The current TrueType glyph loader object. */
1247 /* FreeType error code. 0 means success. */
1250 (*TT_Loader_ReadGlyphFunc)( TT_Loader loader );
1253 /*************************************************************************/
1256 /* TT_Loader_EndGlyphFunc */
1259 /* Closes the current loader stream frame for the glyph. */
1262 /* loader :: The current TrueType glyph loader object. */
1265 (*TT_Loader_EndGlyphFunc)( TT_Loader loader );
1268 /*************************************************************************/
1270 /* TrueType Face Type */
1276 /* The TrueType face class. These objects model the resolution and */
1277 /* point-size independent data found in a TrueType font file. */
1280 /* root :: The base FT_Face structure, managed by the */
1283 /* ttc_header :: The TrueType collection header, used when */
1284 /* the file is a `ttc' rather than a `ttf'. */
1285 /* For ordinary font files, the field */
1286 /* `ttc_header.count' is set to 0. */
1288 /* format_tag :: The font format tag. */
1290 /* num_tables :: The number of TrueType tables in this font */
1293 /* dir_tables :: The directory of TrueType tables for this */
1296 /* header :: The font's font header (`head' table). */
1297 /* Read on font opening. */
1299 /* horizontal :: The font's horizontal header (`hhea' */
1300 /* table). This field also contains the */
1301 /* associated horizontal metrics table */
1304 /* max_profile :: The font's maximum profile table. Read on */
1305 /* font opening. Note that some maximum */
1306 /* values cannot be taken directly from this */
1307 /* table. We thus define additional fields */
1308 /* below to hold the computed maxima. */
1310 /* max_components :: The maximum number of glyph components */
1311 /* required to load any composite glyph from */
1312 /* this font. Used to size the load stack. */
1314 /* vertical_info :: A boolean which is set when the font file */
1315 /* contains vertical metrics. If not, the */
1316 /* value of the `vertical' field is */
1319 /* vertical :: The font's vertical header (`vhea' table). */
1320 /* This field also contains the associated */
1321 /* vertical metrics table (`vmtx'), if found. */
1322 /* IMPORTANT: The contents of this field is */
1323 /* undefined if the `verticalInfo' field is */
1326 /* num_names :: The number of name records within this */
1327 /* TrueType font. */
1329 /* name_table :: The table of name records (`name'). */
1331 /* os2 :: The font's OS/2 table (`OS/2'). */
1333 /* postscript :: The font's PostScript table (`post' */
1334 /* table). The PostScript glyph names are */
1335 /* not loaded by the driver on face opening. */
1336 /* See the `ttpost' module for more details. */
1338 /* cmap_table :: Address of the face's `cmap' SFNT table */
1339 /* in memory (it's an extracted frame). */
1341 /* cmap_size :: The size in bytes of the `cmap_table' */
1342 /* described above. */
1344 /* num_charmaps :: The number of character mappings in the */
1347 /* charmaps :: The array of charmap objects for this font */
1348 /* file. Note that this field is a typeless */
1349 /* pointer. The Reason is that the format of */
1350 /* charmaps varies with the underlying font */
1351 /* format and cannot be determined here. */
1353 /* goto_table :: A function called by each TrueType table */
1354 /* loader to position a stream's cursor to */
1355 /* the start of a given table according to */
1356 /* its tag. It defaults to TT_Goto_Face but */
1357 /* can be different for strange formats (e.g. */
1360 /* access_glyph_frame :: A function used to access the frame of a */
1361 /* given glyph within the face's font file. */
1363 /* forget_glyph_frame :: A function used to forget the frame of a */
1364 /* given glyph when all data has been loaded. */
1366 /* read_glyph_header :: A function used to read a glyph header. */
1367 /* It must be called between an `access' and */
1370 /* read_simple_glyph :: A function used to read a simple glyph. */
1371 /* It must be called after the header was */
1372 /* read, and before the `forget'. */
1374 /* read_composite_glyph :: A function used to read a composite glyph. */
1375 /* It must be called after the header was */
1376 /* read, and before the `forget'. */
1378 /* sfnt :: A pointer to the SFNT `driver' interface. */
1380 /* psnames :: A pointer to the `PSNames' module */
1383 /* hdmx :: The face's horizontal device metrics */
1384 /* (`hdmx' table). This table is optional in */
1385 /* TrueType/OpenType fonts. */
1387 /* gasp :: The grid-fitting and scaling properties */
1388 /* table (`gasp'). This table is optional in */
1389 /* TrueType/OpenType fonts. */
1391 /* pclt :: The `pclt' SFNT table. */
1393 /* num_sbit_strikes :: The number of sbit strikes, i.e., bitmap */
1394 /* sizes, embedded in this font. */
1396 /* sbit_strikes :: An array of sbit strikes embedded in this */
1397 /* font. This table is optional in a */
1398 /* TrueType/OpenType font. */
1400 /* num_sbit_scales :: The number of sbit scales for this font. */
1402 /* sbit_scales :: Array of sbit scales embedded in this */
1403 /* font. This table is optional in a */
1404 /* TrueType/OpenType font. */
1406 /* postscript_names :: A table used to store the Postscript names */
1407 /* of the glyphs for this font. See the */
1408 /* file `ttconfig.h' for comments on the */
1409 /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES option. */
1411 /* num_locations :: The number of glyph locations in this */
1412 /* TrueType file. This should be */
1413 /* identical to the number of glyphs. */
1414 /* Ignored for Type 2 fonts. */
1416 /* glyph_locations :: An array of longs. These are offsets to */
1417 /* glyph data within the `glyf' table. */
1418 /* Ignored for Type 2 font faces. */
1420 /* font_program_size :: Size in bytecodes of the face's font */
1421 /* program. 0 if none defined. Ignored for */
1424 /* font_program :: The face's font program (bytecode stream) */
1425 /* executed at load time, also used during */
1426 /* glyph rendering. Comes from the `fpgm' */
1427 /* table. Ignored for Type 2 font fonts. */
1429 /* cvt_program_size :: The size in bytecodes of the face's cvt */
1430 /* program. Ignored for Type 2 fonts. */
1432 /* cvt_program :: The face's cvt program (bytecode stream) */
1433 /* executed each time an instance/size is */
1434 /* changed/reset. Comes from the `prep' */
1435 /* table. Ignored for Type 2 fonts. */
1437 /* cvt_size :: Size of the control value table (in */
1438 /* entries). Ignored for Type 2 fonts. */
1440 /* cvt :: The face's original control value table. */
1441 /* Coordinates are expressed in unscaled font */
1442 /* units. Comes from the `cvt ' table. */
1443 /* Ignored for Type 2 fonts. */
1445 /* num_kern_pairs :: The number of kerning pairs present in the */
1446 /* font file. The engine only loads the */
1447 /* first horizontal format 0 kern table it */
1448 /* finds in the font file. Ignored for */
1451 /* kern_table_index :: The index of the kerning table in the font */
1452 /* kerning directory. Ignored for Type 2 */
1455 /* interpreter :: A pointer to the TrueType bytecode */
1456 /* interpreters field is also used to hook */
1457 /* the debugger in `ttdebug'. */
1459 /* extra :: Reserved for third-party font drivers. */
1461 typedef struct TT_FaceRec_
1465 TTC_HeaderRec ttc_header;
1467 FT_ULong format_tag;
1468 FT_UShort num_tables;
1469 TT_Table dir_tables;
1471 TT_Header header; /* TrueType header table */
1472 TT_HoriHeader horizontal; /* TrueType horizontal header */
1474 TT_MaxProfile max_profile;
1475 FT_ULong max_components;
1477 FT_Bool vertical_info;
1478 TT_VertHeader vertical; /* TT Vertical header, if present */
1480 FT_UShort num_names; /* number of name records */
1481 TT_NameTableRec name_table; /* name table */
1483 TT_OS2 os2; /* TrueType OS/2 table */
1484 TT_Postscript postscript; /* TrueType Postscript table */
1486 FT_Byte* cmap_table; /* extracted 'cmap' table */
1489 TT_Loader_GotoTableFunc goto_table;
1491 TT_Loader_StartGlyphFunc access_glyph_frame;
1492 TT_Loader_EndGlyphFunc forget_glyph_frame;
1493 TT_Loader_ReadGlyphFunc read_glyph_header;
1494 TT_Loader_ReadGlyphFunc read_simple_glyph;
1495 TT_Loader_ReadGlyphFunc read_composite_glyph;
1497 /* a typeless pointer to the SFNT_Interface table used to load */
1498 /* the basic TrueType tables in the face object */
1501 /* a typeless pointer to the PSNames_Interface table used to */
1502 /* handle glyph names <-> unicode & Mac values */
1505 /***********************************************************************/
1507 /* Optional TrueType/OpenType tables */
1509 /***********************************************************************/
1511 /* horizontal device metrics */
1514 /* grid-fitting and scaling table */
1515 TT_GaspRec gasp; /* the `gasp' table */
1520 /* embedded bitmaps support */
1521 FT_ULong num_sbit_strikes;
1522 TT_SBit_Strike sbit_strikes;
1524 FT_ULong num_sbit_scales;
1525 TT_SBit_Scale sbit_scales;
1527 /* postscript names table */
1528 TT_Post_NamesRec postscript_names;
1531 /***********************************************************************/
1533 /* TrueType-specific fields (ignored by the OTF-Type2 driver) */
1535 /***********************************************************************/
1537 /* the glyph locations */
1538 FT_UShort num_locations;
1539 FT_Long* glyph_locations;
1541 /* the font program, if any */
1542 FT_ULong font_program_size;
1543 FT_Byte* font_program;
1545 /* the cvt program, if any */
1546 FT_ULong cvt_program_size;
1547 FT_Byte* cvt_program;
1549 /* the original, unscaled, control value table */
1553 /* the format 0 kerning table, if any */
1554 FT_Int num_kern_pairs;
1555 FT_Int kern_table_index;
1556 TT_Kern0_Pair kern_pairs;
1558 /* A pointer to the bytecode interpreter to use. This is also */
1559 /* used to hook the debugger for the `ttdebug' utility. */
1560 TT_Interpreter interpreter;
1563 /***********************************************************************/
1565 /* Other tables or fields. This is used by derivative formats like */
1568 /***********************************************************************/
1575 /*************************************************************************/
1578 /* TT_GlyphZoneRec */
1581 /* A glyph zone is used to load, scale and hint glyph outline */
1585 /* memory :: A handle to the memory manager. */
1587 /* max_points :: The maximal size in points of the zone. */
1589 /* max_contours :: Max size in links contours of thez one. */
1591 /* n_points :: The current number of points in the zone. */
1593 /* n_contours :: The current number of contours in the zone. */
1595 /* org :: The original glyph coordinates (font */
1596 /* units/scaled). */
1598 /* cur :: The current glyph coordinates (scaled/hinted). */
1600 /* tags :: The point control tags. */
1602 /* contours :: The contours end points. */
1604 typedef struct TT_GlyphZoneRec_
1607 FT_UShort max_points;
1608 FT_UShort max_contours;
1609 FT_UShort n_points; /* number of points in zone */
1610 FT_Short n_contours; /* number of contours */
1612 FT_Vector* org; /* original point coordinates */
1613 FT_Vector* cur; /* current point coordinates */
1615 FT_Byte* tags; /* current touch flags */
1616 FT_UShort* contours; /* contour end points */
1618 } TT_GlyphZoneRec, *TT_GlyphZone;
1621 /* handle to execution context */
1622 typedef struct TT_ExecContextRec_* TT_ExecContext;
1624 /* glyph loader structure */
1625 typedef struct TT_LoaderRec_
1630 FT_GlyphLoader gloader;
1632 FT_ULong load_flags;
1633 FT_UInt glyph_index;
1638 FT_Short n_contours;
1640 FT_Int left_bearing;
1644 FT_Bool preserve_pps;
1648 FT_ULong glyf_offset;
1650 /* the zone where we load our glyphs */
1651 TT_GlyphZoneRec base;
1652 TT_GlyphZoneRec zone;
1654 TT_ExecContext exec;
1655 FT_Byte* instructions;
1658 /* for possible extensibility in other formats */
1666 #endif /* __TTTYPES_H__ */