1 /***************************************************************************/
5 /* Basic SFNT/TrueType type definitions and interface (specification */
8 /* Copyright 1996-2001, 2002, 2004, 2005, 2006, 2007 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
28 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
29 #include FT_MULTIPLE_MASTERS_H
36 /*************************************************************************/
37 /*************************************************************************/
38 /*************************************************************************/
41 /*** REQUIRED TRUETYPE/OPENTYPE TABLES DEFINITIONS ***/
44 /*************************************************************************/
45 /*************************************************************************/
46 /*************************************************************************/
49 /*************************************************************************/
55 /* TrueType collection header. This table contains the offsets of */
56 /* the font headers of each distinct TrueType face in the file. */
59 /* tag :: Must be `ttc ' to indicate a TrueType collection. */
61 /* version :: The version number. */
63 /* count :: The number of faces in the collection. The */
64 /* specification says this should be an unsigned long, but */
65 /* we use a signed long since we need the value -1 for */
66 /* specific purposes. */
68 /* offsets :: The offsets of the font headers, one per face. */
70 typedef struct TTC_HeaderRec_
80 /*************************************************************************/
86 /* SFNT file format header. */
89 /* format_tag :: The font format tag. */
91 /* num_tables :: The number of tables in file. */
93 /* search_range :: Must be `16 * (max power of 2 <= num_tables)'. */
95 /* entry_selector :: Must be log2 of `search_range / 16'. */
97 /* range_shift :: Must be `num_tables * 16 - search_range'. */
99 typedef struct SFNT_HeaderRec_
102 FT_UShort num_tables
;
103 FT_UShort search_range
;
104 FT_UShort entry_selector
;
105 FT_UShort range_shift
;
107 FT_ULong offset
; /* not in file */
109 } SFNT_HeaderRec
, *SFNT_Header
;
112 /*************************************************************************/
118 /* This structure describes a given table of a TrueType font. */
121 /* Tag :: A four-bytes tag describing the table. */
123 /* CheckSum :: The table checksum. This value can be ignored. */
125 /* Offset :: The offset of the table from the start of the TrueType */
126 /* font in its resource. */
128 /* Length :: The table length (in bytes). */
130 typedef struct TT_TableRec_
132 FT_ULong Tag
; /* table type */
133 FT_ULong CheckSum
; /* table checksum */
134 FT_ULong Offset
; /* table file offset */
135 FT_ULong Length
; /* table length */
137 } TT_TableRec
, *TT_Table
;
140 /*************************************************************************/
143 /* TT_LongMetricsRec */
146 /* A structure modeling the long metrics of the `hmtx' and `vmtx' */
147 /* TrueType tables. The values are expressed in font units. */
150 /* advance :: The advance width or height for the glyph. */
152 /* bearing :: The left-side or top-side bearing for the glyph. */
154 typedef struct TT_LongMetricsRec_
159 } TT_LongMetricsRec
, *TT_LongMetrics
;
162 /*************************************************************************/
165 /* TT_ShortMetrics */
168 /* A simple type to model the short metrics of the `hmtx' and `vmtx' */
171 typedef FT_Short TT_ShortMetrics
;
174 /*************************************************************************/
177 /* TT_NameEntryRec */
180 /* A structure modeling TrueType name records. Name records are used */
181 /* to store important strings like family name, style name, */
182 /* copyright, etc. in _localized_ versions (i.e., language, encoding, */
186 /* platformID :: The ID of the name's encoding platform. */
188 /* encodingID :: The platform-specific ID for the name's encoding. */
190 /* languageID :: The platform-specific ID for the name's language. */
192 /* nameID :: The ID specifying what kind of name this is. */
194 /* stringLength :: The length of the string in bytes. */
196 /* stringOffset :: The offset to the string in the `name' table. */
198 /* string :: A pointer to the string's bytes. Note that these */
199 /* are usually UTF-16 encoded characters. */
201 typedef struct TT_NameEntryRec_
203 FT_UShort platformID
;
204 FT_UShort encodingID
;
205 FT_UShort languageID
;
207 FT_UShort stringLength
;
208 FT_ULong stringOffset
;
210 /* this last field is not defined in the spec */
211 /* but used by the FreeType engine */
215 } TT_NameEntryRec
, *TT_NameEntry
;
218 /*************************************************************************/
221 /* TT_NameTableRec */
224 /* A structure modeling the TrueType name table. */
227 /* format :: The format of the name table. */
229 /* numNameRecords :: The number of names in table. */
231 /* storageOffset :: The offset of the name table in the `name' */
232 /* TrueType table. */
234 /* names :: An array of name records. */
236 /* stream :: the file's input stream. */
238 typedef struct TT_NameTableRec_
241 FT_UInt numNameRecords
;
242 FT_UInt storageOffset
;
243 TT_NameEntryRec
* names
;
246 } TT_NameTableRec
, *TT_NameTable
;
249 /*************************************************************************/
250 /*************************************************************************/
251 /*************************************************************************/
254 /*** OPTIONAL TRUETYPE/OPENTYPE TABLES DEFINITIONS ***/
257 /*************************************************************************/
258 /*************************************************************************/
259 /*************************************************************************/
262 /*************************************************************************/
265 /* TT_GaspRangeRec */
268 /* A tiny structure used to model a gasp range according to the */
269 /* TrueType specification. */
272 /* maxPPEM :: The maximum ppem value to which `gaspFlag' applies. */
274 /* gaspFlag :: A flag describing the grid-fitting and anti-aliasing */
275 /* modes to be used. */
277 typedef struct TT_GaspRangeRec_
282 } TT_GaspRangeRec
, *TT_GaspRange
;
285 #define TT_GASP_GRIDFIT 0x01
286 #define TT_GASP_DOGRAY 0x02
289 /*************************************************************************/
295 /* A structure modeling the TrueType `gasp' table used to specify */
296 /* grid-fitting and anti-aliasing behaviour. */
299 /* version :: The version number. */
301 /* numRanges :: The number of gasp ranges in table. */
303 /* gaspRanges :: An array of gasp ranges. */
305 typedef struct TT_Gasp_
309 TT_GaspRange gaspRanges
;
314 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
316 /*************************************************************************/
319 /* TT_HdmxEntryRec */
322 /* A small structure used to model the pre-computed widths of a given */
323 /* size. They are found in the `hdmx' table. */
326 /* ppem :: The pixels per EM value at which these metrics apply. */
328 /* max_width :: The maximum advance width for this metric. */
330 /* widths :: An array of widths. Note: These are 8-bit bytes. */
332 typedef struct TT_HdmxEntryRec_
338 } TT_HdmxEntryRec
, *TT_HdmxEntry
;
341 /*************************************************************************/
347 /* A structure used to model the `hdmx' table, which contains */
348 /* pre-computed widths for a set of given sizes/dimensions. */
351 /* version :: The version number. */
353 /* num_records :: The number of hdmx records. */
355 /* records :: An array of hdmx records. */
357 typedef struct TT_HdmxRec_
360 FT_Short num_records
;
361 TT_HdmxEntry records
;
363 } TT_HdmxRec
, *TT_Hdmx
;
366 /*************************************************************************/
369 /* TT_Kern0_PairRec */
372 /* A structure used to model a kerning pair for the kerning table */
373 /* format 0. The engine now loads this table if it finds one in the */
377 /* left :: The index of the left glyph in pair. */
379 /* right :: The index of the right glyph in pair. */
381 /* value :: The kerning distance. A positive value spaces the */
382 /* glyphs, a negative one makes them closer. */
384 typedef struct TT_Kern0_PairRec_
386 FT_UShort left
; /* index of left glyph in pair */
387 FT_UShort right
; /* index of right glyph in pair */
388 FT_FWord value
; /* kerning value */
390 } TT_Kern0_PairRec
, *TT_Kern0_Pair
;
392 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
395 /*************************************************************************/
396 /*************************************************************************/
397 /*************************************************************************/
400 /*** EMBEDDED BITMAPS SUPPORT ***/
403 /*************************************************************************/
404 /*************************************************************************/
405 /*************************************************************************/
408 /*************************************************************************/
411 /* TT_SBit_MetricsRec */
414 /* A structure used to hold the big metrics of a given glyph bitmap */
415 /* in a TrueType or OpenType font. These are usually found in the */
416 /* `EBDT' (Microsoft) or `bloc' (Apple) table. */
419 /* height :: The glyph height in pixels. */
421 /* width :: The glyph width in pixels. */
423 /* horiBearingX :: The horizontal left bearing. */
425 /* horiBearingY :: The horizontal top bearing. */
427 /* horiAdvance :: The horizontal advance. */
429 /* vertBearingX :: The vertical left bearing. */
431 /* vertBearingY :: The vertical top bearing. */
433 /* vertAdvance :: The vertical advance. */
435 typedef struct TT_SBit_MetricsRec_
440 FT_Char horiBearingX
;
441 FT_Char horiBearingY
;
444 FT_Char vertBearingX
;
445 FT_Char vertBearingY
;
448 } TT_SBit_MetricsRec
, *TT_SBit_Metrics
;
451 /*************************************************************************/
454 /* TT_SBit_SmallMetricsRec */
457 /* A structure used to hold the small metrics of a given glyph bitmap */
458 /* in a TrueType or OpenType font. These are usually found in the */
459 /* `EBDT' (Microsoft) or the `bdat' (Apple) table. */
462 /* height :: The glyph height in pixels. */
464 /* width :: The glyph width in pixels. */
466 /* bearingX :: The left-side bearing. */
468 /* bearingY :: The top-side bearing. */
470 /* advance :: The advance width or height. */
472 typedef struct TT_SBit_Small_Metrics_
481 } TT_SBit_SmallMetricsRec
, *TT_SBit_SmallMetrics
;
484 /*************************************************************************/
487 /* TT_SBit_LineMetricsRec */
490 /* A structure used to describe the text line metrics of a given */
491 /* bitmap strike, for either a horizontal or vertical layout. */
494 /* ascender :: The ascender in pixels. */
496 /* descender :: The descender in pixels. */
498 /* max_width :: The maximum glyph width in pixels. */
500 /* caret_slope_enumerator :: Rise of the caret slope, typically set */
501 /* to 1 for non-italic fonts. */
503 /* caret_slope_denominator :: Rise of the caret slope, typically set */
504 /* to 0 for non-italic fonts. */
506 /* caret_offset :: Offset in pixels to move the caret for */
507 /* proper positioning. */
509 /* min_origin_SB :: Minimum of horiBearingX (resp. */
511 /* min_advance_SB :: Minimum of */
513 /* horizontal advance - */
514 /* ( horiBearingX + width ) */
518 /* vertical advance - */
519 /* ( vertBearingY + height ) */
521 /* max_before_BL :: Maximum of horiBearingY (resp. */
524 /* min_after_BL :: Minimum of */
526 /* horiBearingY - height */
530 /* vertBearingX - width */
532 /* pads :: Unused (to make the size of the record */
533 /* a multiple of 32 bits. */
535 typedef struct TT_SBit_LineMetricsRec_
540 FT_Char caret_slope_numerator
;
541 FT_Char caret_slope_denominator
;
542 FT_Char caret_offset
;
543 FT_Char min_origin_SB
;
544 FT_Char min_advance_SB
;
545 FT_Char max_before_BL
;
546 FT_Char min_after_BL
;
549 } TT_SBit_LineMetricsRec
, *TT_SBit_LineMetrics
;
552 /*************************************************************************/
555 /* TT_SBit_RangeRec */
558 /* A TrueType/OpenType subIndexTable as defined in the `EBLC' */
559 /* (Microsoft) or `bloc' (Apple) tables. */
562 /* first_glyph :: The first glyph index in the range. */
564 /* last_glyph :: The last glyph index in the range. */
566 /* index_format :: The format of index table. Valid values are 1 */
569 /* image_format :: The format of `EBDT' image data. */
571 /* image_offset :: The offset to image data in `EBDT'. */
573 /* image_size :: For index formats 2 and 5. This is the size in */
574 /* bytes of each glyph bitmap. */
576 /* big_metrics :: For index formats 2 and 5. This is the big */
577 /* metrics for each glyph bitmap. */
579 /* num_glyphs :: For index formats 4 and 5. This is the number of */
580 /* glyphs in the code array. */
582 /* glyph_offsets :: For index formats 1 and 3. */
584 /* glyph_codes :: For index formats 4 and 5. */
586 /* table_offset :: The offset of the index table in the `EBLC' */
587 /* table. Only used during strike loading. */
589 typedef struct TT_SBit_RangeRec
591 FT_UShort first_glyph
;
592 FT_UShort last_glyph
;
594 FT_UShort index_format
;
595 FT_UShort image_format
;
596 FT_ULong image_offset
;
599 TT_SBit_MetricsRec metrics
;
602 FT_ULong
* glyph_offsets
;
603 FT_UShort
* glyph_codes
;
605 FT_ULong table_offset
;
607 } TT_SBit_RangeRec
, *TT_SBit_Range
;
610 /*************************************************************************/
613 /* TT_SBit_StrikeRec */
616 /* A structure used describe a given bitmap strike in the `EBLC' */
617 /* (Microsoft) or `bloc' (Apple) tables. */
620 /* num_index_ranges :: The number of index ranges. */
622 /* index_ranges :: An array of glyph index ranges. */
624 /* color_ref :: Unused. `color_ref' is put in for future */
625 /* enhancements, but these fields are already */
626 /* in use by other platforms (e.g. Newton). */
627 /* For details, please see */
629 /* http://fonts.apple.com/ */
630 /* TTRefMan/RM06/Chap6bloc.html */
632 /* hori :: The line metrics for horizontal layouts. */
634 /* vert :: The line metrics for vertical layouts. */
636 /* start_glyph :: The lowest glyph index for this strike. */
638 /* end_glyph :: The highest glyph index for this strike. */
640 /* x_ppem :: The number of horizontal pixels per EM. */
642 /* y_ppem :: The number of vertical pixels per EM. */
644 /* bit_depth :: The bit depth. Valid values are 1, 2, 4, */
647 /* flags :: Is this a vertical or horizontal strike? For */
648 /* details, please see */
650 /* http://fonts.apple.com/ */
651 /* TTRefMan/RM06/Chap6bloc.html */
653 typedef struct TT_SBit_StrikeRec_
656 TT_SBit_Range sbit_ranges
;
657 FT_ULong ranges_offset
;
661 TT_SBit_LineMetricsRec hori
;
662 TT_SBit_LineMetricsRec vert
;
664 FT_UShort start_glyph
;
673 } TT_SBit_StrikeRec
, *TT_SBit_Strike
;
676 /*************************************************************************/
679 /* TT_SBit_ComponentRec */
682 /* A simple structure to describe a compound sbit element. */
685 /* glyph_code :: The element's glyph index. */
687 /* x_offset :: The element's left bearing. */
689 /* y_offset :: The element's top bearing. */
691 typedef struct TT_SBit_ComponentRec_
693 FT_UShort glyph_code
;
697 } TT_SBit_ComponentRec
, *TT_SBit_Component
;
700 /*************************************************************************/
703 /* TT_SBit_ScaleRec */
706 /* A structure used describe a given bitmap scaling table, as defined */
707 /* in the `EBSC' table. */
710 /* hori :: The horizontal line metrics. */
712 /* vert :: The vertical line metrics. */
714 /* x_ppem :: The number of horizontal pixels per EM. */
716 /* y_ppem :: The number of vertical pixels per EM. */
718 /* x_ppem_substitute :: Substitution x_ppem value. */
720 /* y_ppem_substitute :: Substitution y_ppem value. */
722 typedef struct TT_SBit_ScaleRec_
724 TT_SBit_LineMetricsRec hori
;
725 TT_SBit_LineMetricsRec vert
;
730 FT_Byte x_ppem_substitute
;
731 FT_Byte y_ppem_substitute
;
733 } TT_SBit_ScaleRec
, *TT_SBit_Scale
;
736 /*************************************************************************/
737 /*************************************************************************/
738 /*************************************************************************/
741 /*** POSTSCRIPT GLYPH NAMES SUPPORT ***/
744 /*************************************************************************/
745 /*************************************************************************/
746 /*************************************************************************/
749 /*************************************************************************/
755 /* Postscript names sub-table, format 2.0. Stores the PS name of */
756 /* each glyph in the font face. */
759 /* num_glyphs :: The number of named glyphs in the table. */
761 /* num_names :: The number of PS names stored in the table. */
763 /* glyph_indices :: The indices of the glyphs in the names arrays. */
765 /* glyph_names :: The PS names not in Mac Encoding. */
767 typedef struct TT_Post_20Rec_
769 FT_UShort num_glyphs
;
771 FT_UShort
* glyph_indices
;
772 FT_Char
** glyph_names
;
774 } TT_Post_20Rec
, *TT_Post_20
;
777 /*************************************************************************/
783 /* Postscript names sub-table, format 2.5. Stores the PS name of */
784 /* each glyph in the font face. */
787 /* num_glyphs :: The number of glyphs in the table. */
789 /* offsets :: An array of signed offsets in a normal Mac */
790 /* Postscript name encoding. */
792 typedef struct TT_Post_25_
794 FT_UShort num_glyphs
;
797 } TT_Post_25Rec
, *TT_Post_25
;
800 /*************************************************************************/
803 /* TT_Post_NamesRec */
806 /* Postscript names table, either format 2.0 or 2.5. */
809 /* loaded :: A flag to indicate whether the PS names are loaded. */
811 /* format_20 :: The sub-table used for format 2.0. */
813 /* format_25 :: The sub-table used for format 2.5. */
815 typedef struct TT_Post_NamesRec_
821 TT_Post_20Rec format_20
;
822 TT_Post_25Rec format_25
;
826 } TT_Post_NamesRec
, *TT_Post_Names
;
829 /*************************************************************************/
830 /*************************************************************************/
831 /*************************************************************************/
834 /*** GX VARIATION TABLE SUPPORT ***/
837 /*************************************************************************/
838 /*************************************************************************/
839 /*************************************************************************/
842 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
843 typedef struct GX_BlendRec_
*GX_Blend
;
846 /*************************************************************************/
847 /*************************************************************************/
848 /*************************************************************************/
851 /*** EMBEDDED BDF PROPERTIES TABLE SUPPORT ***/
854 /*************************************************************************/
855 /*************************************************************************/
856 /*************************************************************************/
859 * These types are used to support a `BDF ' table that isn't part of the
860 * official TrueType specification. It is mainly used in SFNT-based
861 * bitmap fonts that were generated from a set of BDF fonts.
863 * The format of the table is as follows.
865 * USHORT version `BDF ' table version number, should be 0x0001.
866 * USHORT strikeCount Number of strikes (bitmap sizes) in this table.
867 * ULONG stringTable Offset (from start of BDF table) to string
870 * This is followed by an array of `strikeCount' descriptors, having the
873 * USHORT ppem Vertical pixels per EM for this strike.
874 * USHORT numItems Number of items for this strike (properties and
875 * atoms). Maximum is 255.
877 * This array in turn is followed by `strikeCount' value sets. Each
878 * `value set' is an array of `numItems' items with the following format.
880 * ULONG item_name Offset in string table to item name.
881 * USHORT item_type The item type. Possible values are
882 * 0 => string (e.g., COMMENT)
883 * 1 => atom (e.g., FONT or even SIZE)
886 * 0x10 => A flag to indicate a properties. This
887 * is ORed with the above values.
888 * ULONG item_value For strings => Offset into string table without
889 * the corresponding double quotes.
890 * For atoms => Offset into string table.
891 * For integers => Direct value.
893 * All strings in the string table consist of bytes and are
898 #ifdef TT_CONFIG_OPTION_BDF
900 typedef struct TT_BDFRec_
905 FT_UInt32 strings_size
;
909 } TT_BDFRec
, *TT_BDF
;
911 #endif /* TT_CONFIG_OPTION_BDF */
913 /*************************************************************************/
914 /*************************************************************************/
915 /*************************************************************************/
918 /*** ORIGINAL TT_FACE CLASS DEFINITION ***/
921 /*************************************************************************/
922 /*************************************************************************/
923 /*************************************************************************/
926 /*************************************************************************/
928 /* This structure/class is defined here because it is common to the */
929 /* following formats: TTF, OpenType-TT, and OpenType-CFF. */
931 /* Note, however, that the classes TT_Size and TT_GlyphSlot are not */
932 /* shared between font drivers, and are thus defined in `ttobjs.h'. */
934 /*************************************************************************/
937 /*************************************************************************/
943 /* A handle to a TrueType face/font object. A TT_Face encapsulates */
944 /* the resolution and scaling independent parts of a TrueType font */
948 /* The TT_Face structure is also used as a `parent class' for the */
949 /* OpenType-CFF class (T2_Face). */
951 typedef struct TT_FaceRec_
* TT_Face
;
954 /* a function type used for the truetype bytecode interpreter hooks */
956 (*TT_Interpreter
)( void* exec_context
);
958 /* forward declaration */
959 typedef struct TT_LoaderRec_
* TT_Loader
;
962 /*************************************************************************/
965 /* TT_Loader_GotoTableFunc */
968 /* Seeks a stream to the start of a given TrueType table. */
971 /* face :: A handle to the target face object. */
973 /* tag :: A 4-byte tag used to name the table. */
975 /* stream :: The input stream. */
978 /* length :: The length of the table in bytes. Set to 0 if not */
982 /* FreeType error code. 0 means success. */
985 /* The stream cursor must be at the font file's origin. */
988 (*TT_Loader_GotoTableFunc
)( TT_Face face
,
994 /*************************************************************************/
997 /* TT_Loader_StartGlyphFunc */
1000 /* Seeks a stream to the start of a given glyph element, and opens a */
1004 /* loader :: The current TrueType glyph loader object. */
1006 /* glyph index :: The index of the glyph to access. */
1008 /* offset :: The offset of the glyph according to the */
1009 /* `locations' table. */
1011 /* byte_count :: The size of the frame in bytes. */
1014 /* FreeType error code. 0 means success. */
1017 /* This function is normally equivalent to FT_STREAM_SEEK(offset) */
1018 /* followed by FT_FRAME_ENTER(byte_count) with the loader's stream, */
1019 /* but alternative formats (e.g. compressed ones) might use something */
1023 (*TT_Loader_StartGlyphFunc
)( TT_Loader loader
,
1024 FT_UInt glyph_index
,
1026 FT_UInt byte_count
);
1029 /*************************************************************************/
1032 /* TT_Loader_ReadGlyphFunc */
1035 /* Reads one glyph element (its header, a simple glyph, or a */
1036 /* composite) from the loader's current stream frame. */
1039 /* loader :: The current TrueType glyph loader object. */
1042 /* FreeType error code. 0 means success. */
1045 (*TT_Loader_ReadGlyphFunc
)( TT_Loader loader
);
1048 /*************************************************************************/
1051 /* TT_Loader_EndGlyphFunc */
1054 /* Closes the current loader stream frame for the glyph. */
1057 /* loader :: The current TrueType glyph loader object. */
1060 (*TT_Loader_EndGlyphFunc
)( TT_Loader loader
);
1063 /*************************************************************************/
1065 /* TrueType Face Type */
1071 /* The TrueType face class. These objects model the resolution and */
1072 /* point-size independent data found in a TrueType font file. */
1075 /* root :: The base FT_Face structure, managed by the */
1078 /* ttc_header :: The TrueType collection header, used when */
1079 /* the file is a `ttc' rather than a `ttf'. */
1080 /* For ordinary font files, the field */
1081 /* `ttc_header.count' is set to 0. */
1083 /* format_tag :: The font format tag. */
1085 /* num_tables :: The number of TrueType tables in this font */
1088 /* dir_tables :: The directory of TrueType tables for this */
1091 /* header :: The font's font header (`head' table). */
1092 /* Read on font opening. */
1094 /* horizontal :: The font's horizontal header (`hhea' */
1095 /* table). This field also contains the */
1096 /* associated horizontal metrics table */
1099 /* max_profile :: The font's maximum profile table. Read on */
1100 /* font opening. Note that some maximum */
1101 /* values cannot be taken directly from this */
1102 /* table. We thus define additional fields */
1103 /* below to hold the computed maxima. */
1105 /* vertical_info :: A boolean which is set when the font file */
1106 /* contains vertical metrics. If not, the */
1107 /* value of the `vertical' field is */
1110 /* vertical :: The font's vertical header (`vhea' table). */
1111 /* This field also contains the associated */
1112 /* vertical metrics table (`vmtx'), if found. */
1113 /* IMPORTANT: The contents of this field is */
1114 /* undefined if the `verticalInfo' field is */
1117 /* num_names :: The number of name records within this */
1118 /* TrueType font. */
1120 /* name_table :: The table of name records (`name'). */
1122 /* os2 :: The font's OS/2 table (`OS/2'). */
1124 /* postscript :: The font's PostScript table (`post' */
1125 /* table). The PostScript glyph names are */
1126 /* not loaded by the driver on face opening. */
1127 /* See the `ttpost' module for more details. */
1129 /* cmap_table :: Address of the face's `cmap' SFNT table */
1130 /* in memory (it's an extracted frame). */
1132 /* cmap_size :: The size in bytes of the `cmap_table' */
1133 /* described above. */
1135 /* goto_table :: A function called by each TrueType table */
1136 /* loader to position a stream's cursor to */
1137 /* the start of a given table according to */
1138 /* its tag. It defaults to TT_Goto_Face but */
1139 /* can be different for strange formats (e.g. */
1142 /* access_glyph_frame :: A function used to access the frame of a */
1143 /* given glyph within the face's font file. */
1145 /* forget_glyph_frame :: A function used to forget the frame of a */
1146 /* given glyph when all data has been loaded. */
1148 /* read_glyph_header :: A function used to read a glyph header. */
1149 /* It must be called between an `access' and */
1152 /* read_simple_glyph :: A function used to read a simple glyph. */
1153 /* It must be called after the header was */
1154 /* read, and before the `forget'. */
1156 /* read_composite_glyph :: A function used to read a composite glyph. */
1157 /* It must be called after the header was */
1158 /* read, and before the `forget'. */
1160 /* sfnt :: A pointer to the SFNT service. */
1162 /* psnames :: A pointer to the PostScript names service. */
1164 /* hdmx :: The face's horizontal device metrics */
1165 /* (`hdmx' table). This table is optional in */
1166 /* TrueType/OpenType fonts. */
1168 /* gasp :: The grid-fitting and scaling properties */
1169 /* table (`gasp'). This table is optional in */
1170 /* TrueType/OpenType fonts. */
1172 /* pclt :: The `pclt' SFNT table. */
1174 /* num_sbit_strikes :: The number of sbit strikes, i.e., bitmap */
1175 /* sizes, embedded in this font. */
1177 /* sbit_strikes :: An array of sbit strikes embedded in this */
1178 /* font. This table is optional in a */
1179 /* TrueType/OpenType font. */
1181 /* num_sbit_scales :: The number of sbit scales for this font. */
1183 /* sbit_scales :: Array of sbit scales embedded in this */
1184 /* font. This table is optional in a */
1185 /* TrueType/OpenType font. */
1187 /* postscript_names :: A table used to store the Postscript names */
1188 /* of the glyphs for this font. See the */
1189 /* file `ttconfig.h' for comments on the */
1190 /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES option. */
1192 /* num_locations :: The number of glyph locations in this */
1193 /* TrueType file. This should be */
1194 /* identical to the number of glyphs. */
1195 /* Ignored for Type 2 fonts. */
1197 /* glyph_locations :: An array of longs. These are offsets to */
1198 /* glyph data within the `glyf' table. */
1199 /* Ignored for Type 2 font faces. */
1201 /* glyf_len :: The length of the `glyf' table. Needed */
1202 /* for malformed `loca' tables. */
1204 /* font_program_size :: Size in bytecodes of the face's font */
1205 /* program. 0 if none defined. Ignored for */
1208 /* font_program :: The face's font program (bytecode stream) */
1209 /* executed at load time, also used during */
1210 /* glyph rendering. Comes from the `fpgm' */
1211 /* table. Ignored for Type 2 font fonts. */
1213 /* cvt_program_size :: The size in bytecodes of the face's cvt */
1214 /* program. Ignored for Type 2 fonts. */
1216 /* cvt_program :: The face's cvt program (bytecode stream) */
1217 /* executed each time an instance/size is */
1218 /* changed/reset. Comes from the `prep' */
1219 /* table. Ignored for Type 2 fonts. */
1221 /* cvt_size :: Size of the control value table (in */
1222 /* entries). Ignored for Type 2 fonts. */
1224 /* cvt :: The face's original control value table. */
1225 /* Coordinates are expressed in unscaled font */
1226 /* units. Comes from the `cvt ' table. */
1227 /* Ignored for Type 2 fonts. */
1229 /* num_kern_pairs :: The number of kerning pairs present in the */
1230 /* font file. The engine only loads the */
1231 /* first horizontal format 0 kern table it */
1232 /* finds in the font file. Ignored for */
1235 /* kern_table_index :: The index of the kerning table in the font */
1236 /* kerning directory. Ignored for Type 2 */
1239 /* interpreter :: A pointer to the TrueType bytecode */
1240 /* interpreters field is also used to hook */
1241 /* the debugger in `ttdebug'. */
1243 /* unpatented_hinting :: If true, use only unpatented methods in */
1244 /* the bytecode interpreter. */
1246 /* doblend :: A boolean which is set if the font should */
1247 /* be blended (this is for GX var). */
1249 /* blend :: Contains the data needed to control GX */
1250 /* variation tables (rather like Multiple */
1253 /* extra :: Reserved for third-party font drivers. */
1255 /* postscript_name :: The PS name of the font. Used by the */
1256 /* postscript name service. */
1258 typedef struct TT_FaceRec_
1262 TTC_HeaderRec ttc_header
;
1264 FT_ULong format_tag
;
1265 FT_UShort num_tables
;
1266 TT_Table dir_tables
;
1268 TT_Header header
; /* TrueType header table */
1269 TT_HoriHeader horizontal
; /* TrueType horizontal header */
1271 TT_MaxProfile max_profile
;
1272 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
1273 FT_ULong max_components
; /* stubbed to 0 */
1276 FT_Bool vertical_info
;
1277 TT_VertHeader vertical
; /* TT Vertical header, if present */
1279 FT_UShort num_names
; /* number of name records */
1280 TT_NameTableRec name_table
; /* name table */
1282 TT_OS2 os2
; /* TrueType OS/2 table */
1283 TT_Postscript postscript
; /* TrueType Postscript table */
1285 FT_Byte
* cmap_table
; /* extracted `cmap' table */
1288 TT_Loader_GotoTableFunc goto_table
;
1290 TT_Loader_StartGlyphFunc access_glyph_frame
;
1291 TT_Loader_EndGlyphFunc forget_glyph_frame
;
1292 TT_Loader_ReadGlyphFunc read_glyph_header
;
1293 TT_Loader_ReadGlyphFunc read_simple_glyph
;
1294 TT_Loader_ReadGlyphFunc read_composite_glyph
;
1296 /* a typeless pointer to the SFNT_Interface table used to load */
1297 /* the basic TrueType tables in the face object */
1300 /* a typeless pointer to the FT_Service_PsCMapsRec table used to */
1301 /* handle glyph names <-> unicode & Mac values */
1305 /***********************************************************************/
1307 /* Optional TrueType/OpenType tables */
1309 /***********************************************************************/
1311 /* horizontal device metrics */
1312 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
1316 /* grid-fitting and scaling table */
1317 TT_GaspRec gasp
; /* the `gasp' table */
1322 /* embedded bitmaps support */
1323 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
1324 FT_ULong num_sbit_strikes
;
1325 TT_SBit_Strike sbit_strikes
;
1328 FT_ULong num_sbit_scales
;
1329 TT_SBit_Scale sbit_scales
;
1331 /* postscript names table */
1332 TT_Post_NamesRec postscript_names
;
1335 /***********************************************************************/
1337 /* TrueType-specific fields (ignored by the OTF-Type2 driver) */
1339 /***********************************************************************/
1341 /* the glyph locations */
1342 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
1343 FT_UShort num_locations_stub
;
1344 FT_Long
* glyph_locations_stub
;
1347 /* the font program, if any */
1348 FT_ULong font_program_size
;
1349 FT_Byte
* font_program
;
1351 /* the cvt program, if any */
1352 FT_ULong cvt_program_size
;
1353 FT_Byte
* cvt_program
;
1355 /* the original, unscaled, control value table */
1359 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
1360 /* the format 0 kerning table, if any */
1361 FT_Int num_kern_pairs
;
1362 FT_Int kern_table_index
;
1363 TT_Kern0_Pair kern_pairs
;
1366 /* A pointer to the bytecode interpreter to use. This is also */
1367 /* used to hook the debugger for the `ttdebug' utility. */
1368 TT_Interpreter interpreter
;
1370 #ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
1371 /* Use unpatented hinting only. */
1372 FT_Bool unpatented_hinting
;
1375 /***********************************************************************/
1377 /* Other tables or fields. This is used by derivative formats like */
1380 /***********************************************************************/
1384 const char* postscript_name
;
1386 /* since version 2.1.8, but was originally placed after */
1387 /* `glyph_locations_stub' */
1390 /* since version 2.1.8, but was originally placed before `extra' */
1391 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1396 /* since version 2.2 */
1398 FT_Byte
* horz_metrics
;
1399 FT_ULong horz_metrics_size
;
1401 FT_Byte
* vert_metrics
;
1402 FT_ULong vert_metrics_size
;
1404 FT_UInt num_locations
;
1405 FT_Byte
* glyph_locations
;
1407 FT_Byte
* hdmx_table
;
1408 FT_ULong hdmx_table_size
;
1409 FT_UInt hdmx_record_count
;
1410 FT_ULong hdmx_record_size
;
1411 FT_Byte
* hdmx_record_sizes
;
1413 FT_Byte
* sbit_table
;
1414 FT_ULong sbit_table_size
;
1415 FT_UInt sbit_num_strikes
;
1417 FT_Byte
* kern_table
;
1418 FT_ULong kern_table_size
;
1419 FT_UInt num_kern_tables
;
1420 FT_UInt32 kern_avail_bits
;
1421 FT_UInt32 kern_order_bits
;
1423 #ifdef TT_CONFIG_OPTION_BDF
1425 #endif /* TT_CONFIG_OPTION_BDF */
1428 FT_ULong horz_metrics_offset
;
1429 FT_ULong vert_metrics_offset
;
1434 /*************************************************************************/
1437 /* TT_GlyphZoneRec */
1440 /* A glyph zone is used to load, scale and hint glyph outline */
1444 /* memory :: A handle to the memory manager. */
1446 /* max_points :: The maximal size in points of the zone. */
1448 /* max_contours :: Max size in links contours of the zone. */
1450 /* n_points :: The current number of points in the zone. */
1452 /* n_contours :: The current number of contours in the zone. */
1454 /* org :: The original glyph coordinates (font */
1455 /* units/scaled). */
1457 /* cur :: The current glyph coordinates (scaled/hinted). */
1459 /* tags :: The point control tags. */
1461 /* contours :: The contours end points. */
1463 /* first_point :: Offset of the current subglyph's first point. */
1465 typedef struct TT_GlyphZoneRec_
1468 FT_UShort max_points
;
1469 FT_UShort max_contours
;
1470 FT_UShort n_points
; /* number of points in zone */
1471 FT_Short n_contours
; /* number of contours */
1473 FT_Vector
* org
; /* original point coordinates */
1474 FT_Vector
* cur
; /* current point coordinates */
1475 FT_Vector
* orus
; /* original (unscaled) point coordinates */
1477 FT_Byte
* tags
; /* current touch flags */
1478 FT_UShort
* contours
; /* contour end points */
1480 FT_UShort first_point
; /* offset of first (#0) point */
1482 } TT_GlyphZoneRec
, *TT_GlyphZone
;
1485 /* handle to execution context */
1486 typedef struct TT_ExecContextRec_
* TT_ExecContext
;
1488 /* glyph loader structure */
1489 typedef struct TT_LoaderRec_
1494 FT_GlyphLoader gloader
;
1496 FT_ULong load_flags
;
1497 FT_UInt glyph_index
;
1502 FT_Short n_contours
;
1504 FT_Int left_bearing
;
1508 FT_Bool preserve_pps
;
1512 FT_ULong glyf_offset
;
1514 /* the zone where we load our glyphs */
1515 TT_GlyphZoneRec base
;
1516 TT_GlyphZoneRec zone
;
1518 TT_ExecContext exec
;
1519 FT_Byte
* instructions
;
1522 /* for possible extensibility in other formats */
1525 /* since version 2.1.8 */
1531 /* since version 2.2.1 */
1540 #endif /* __TTTYPES_H__ */