1 /***************************************************************************/
5 /* Basic SFNT/TrueType type definitions and interface (specification */
8 /* Copyright 1996-2015 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 /*************************************************************************/
146 /* WOFF file format header. */
151 /* http://www.w3.org/TR/WOFF/#WOFFHeader */
153 typedef struct WOFF_HeaderRec_
158 FT_UShort num_tables
;
160 FT_ULong totalSfntSize
;
161 FT_UShort majorVersion
;
162 FT_UShort minorVersion
;
165 FT_ULong metaOrigLength
;
169 } WOFF_HeaderRec
, *WOFF_Header
;
172 /*************************************************************************/
178 /* This structure describes a given table of a WOFF font. */
181 /* Tag :: A four-bytes tag describing the table. */
183 /* Offset :: The offset of the table from the start of the WOFF */
184 /* font in its resource. */
186 /* CompLength :: Compressed table length (in bytes). */
188 /* OrigLength :: Unompressed table length (in bytes). */
190 /* CheckSum :: The table checksum. This value can be ignored. */
192 /* OrigOffset :: The uncompressed table file offset. This value gets */
193 /* computed while constructing the (uncompressed) SFNT */
194 /* header. It is not contained in the WOFF file. */
196 typedef struct WOFF_TableRec_
198 FT_ULong Tag
; /* table ID */
199 FT_ULong Offset
; /* table file offset */
200 FT_ULong CompLength
; /* compressed table length */
201 FT_ULong OrigLength
; /* uncompressed table length */
202 FT_ULong CheckSum
; /* uncompressed checksum */
204 FT_ULong OrigOffset
; /* uncompressed table file offset */
205 /* (not in the WOFF file) */
206 } WOFF_TableRec
, *WOFF_Table
;
209 /*************************************************************************/
212 /* TT_LongMetricsRec */
215 /* A structure modeling the long metrics of the `hmtx' and `vmtx' */
216 /* TrueType tables. The values are expressed in font units. */
219 /* advance :: The advance width or height for the glyph. */
221 /* bearing :: The left-side or top-side bearing for the glyph. */
223 typedef struct TT_LongMetricsRec_
228 } TT_LongMetricsRec
, *TT_LongMetrics
;
231 /*************************************************************************/
234 /* TT_ShortMetrics */
237 /* A simple type to model the short metrics of the `hmtx' and `vmtx' */
240 typedef FT_Short TT_ShortMetrics
;
243 /*************************************************************************/
246 /* TT_NameEntryRec */
249 /* A structure modeling TrueType name records. Name records are used */
250 /* to store important strings like family name, style name, */
251 /* copyright, etc. in _localized_ versions (i.e., language, encoding, */
255 /* platformID :: The ID of the name's encoding platform. */
257 /* encodingID :: The platform-specific ID for the name's encoding. */
259 /* languageID :: The platform-specific ID for the name's language. */
261 /* nameID :: The ID specifying what kind of name this is. */
263 /* stringLength :: The length of the string in bytes. */
265 /* stringOffset :: The offset to the string in the `name' table. */
267 /* string :: A pointer to the string's bytes. Note that these */
268 /* are usually UTF-16 encoded characters. */
270 typedef struct TT_NameEntryRec_
272 FT_UShort platformID
;
273 FT_UShort encodingID
;
274 FT_UShort languageID
;
276 FT_UShort stringLength
;
277 FT_ULong stringOffset
;
279 /* this last field is not defined in the spec */
280 /* but used by the FreeType engine */
284 } TT_NameEntryRec
, *TT_NameEntry
;
287 /*************************************************************************/
290 /* TT_NameTableRec */
293 /* A structure modeling the TrueType name table. */
296 /* format :: The format of the name table. */
298 /* numNameRecords :: The number of names in table. */
300 /* storageOffset :: The offset of the name table in the `name' */
301 /* TrueType table. */
303 /* names :: An array of name records. */
305 /* stream :: the file's input stream. */
307 typedef struct TT_NameTableRec_
310 FT_UInt numNameRecords
;
311 FT_UInt storageOffset
;
312 TT_NameEntryRec
* names
;
315 } TT_NameTableRec
, *TT_NameTable
;
318 /*************************************************************************/
319 /*************************************************************************/
320 /*************************************************************************/
323 /*** OPTIONAL TRUETYPE/OPENTYPE TABLES DEFINITIONS ***/
326 /*************************************************************************/
327 /*************************************************************************/
328 /*************************************************************************/
331 /*************************************************************************/
334 /* TT_GaspRangeRec */
337 /* A tiny structure used to model a gasp range according to the */
338 /* TrueType specification. */
341 /* maxPPEM :: The maximum ppem value to which `gaspFlag' applies. */
343 /* gaspFlag :: A flag describing the grid-fitting and anti-aliasing */
344 /* modes to be used. */
346 typedef struct TT_GaspRangeRec_
351 } TT_GaspRangeRec
, *TT_GaspRange
;
354 #define TT_GASP_GRIDFIT 0x01
355 #define TT_GASP_DOGRAY 0x02
358 /*************************************************************************/
364 /* A structure modeling the TrueType `gasp' table used to specify */
365 /* grid-fitting and anti-aliasing behaviour. */
368 /* version :: The version number. */
370 /* numRanges :: The number of gasp ranges in table. */
372 /* gaspRanges :: An array of gasp ranges. */
374 typedef struct TT_Gasp_
378 TT_GaspRange gaspRanges
;
383 /*************************************************************************/
384 /*************************************************************************/
385 /*************************************************************************/
388 /*** EMBEDDED BITMAPS SUPPORT ***/
391 /*************************************************************************/
392 /*************************************************************************/
393 /*************************************************************************/
396 /*************************************************************************/
399 /* TT_SBit_MetricsRec */
402 /* A structure used to hold the big metrics of a given glyph bitmap */
403 /* in a TrueType or OpenType font. These are usually found in the */
404 /* `EBDT' (Microsoft) or `bloc' (Apple) table. */
407 /* height :: The glyph height in pixels. */
409 /* width :: The glyph width in pixels. */
411 /* horiBearingX :: The horizontal left bearing. */
413 /* horiBearingY :: The horizontal top bearing. */
415 /* horiAdvance :: The horizontal advance. */
417 /* vertBearingX :: The vertical left bearing. */
419 /* vertBearingY :: The vertical top bearing. */
421 /* vertAdvance :: The vertical advance. */
423 typedef struct TT_SBit_MetricsRec_
428 FT_Short horiBearingX
;
429 FT_Short horiBearingY
;
430 FT_UShort horiAdvance
;
432 FT_Short vertBearingX
;
433 FT_Short vertBearingY
;
434 FT_UShort vertAdvance
;
436 } TT_SBit_MetricsRec
, *TT_SBit_Metrics
;
439 /*************************************************************************/
442 /* TT_SBit_SmallMetricsRec */
445 /* A structure used to hold the small metrics of a given glyph bitmap */
446 /* in a TrueType or OpenType font. These are usually found in the */
447 /* `EBDT' (Microsoft) or the `bdat' (Apple) table. */
450 /* height :: The glyph height in pixels. */
452 /* width :: The glyph width in pixels. */
454 /* bearingX :: The left-side bearing. */
456 /* bearingY :: The top-side bearing. */
458 /* advance :: The advance width or height. */
460 typedef struct TT_SBit_Small_Metrics_
469 } TT_SBit_SmallMetricsRec
, *TT_SBit_SmallMetrics
;
472 /*************************************************************************/
475 /* TT_SBit_LineMetricsRec */
478 /* A structure used to describe the text line metrics of a given */
479 /* bitmap strike, for either a horizontal or vertical layout. */
482 /* ascender :: The ascender in pixels. */
484 /* descender :: The descender in pixels. */
486 /* max_width :: The maximum glyph width in pixels. */
488 /* caret_slope_enumerator :: Rise of the caret slope, typically set */
489 /* to 1 for non-italic fonts. */
491 /* caret_slope_denominator :: Rise of the caret slope, typically set */
492 /* to 0 for non-italic fonts. */
494 /* caret_offset :: Offset in pixels to move the caret for */
495 /* proper positioning. */
497 /* min_origin_SB :: Minimum of horiBearingX (resp. */
499 /* min_advance_SB :: Minimum of */
501 /* horizontal advance - */
502 /* ( horiBearingX + width ) */
506 /* vertical advance - */
507 /* ( vertBearingY + height ) */
509 /* max_before_BL :: Maximum of horiBearingY (resp. */
512 /* min_after_BL :: Minimum of */
514 /* horiBearingY - height */
518 /* vertBearingX - width */
520 /* pads :: Unused (to make the size of the record */
521 /* a multiple of 32 bits. */
523 typedef struct TT_SBit_LineMetricsRec_
528 FT_Char caret_slope_numerator
;
529 FT_Char caret_slope_denominator
;
530 FT_Char caret_offset
;
531 FT_Char min_origin_SB
;
532 FT_Char min_advance_SB
;
533 FT_Char max_before_BL
;
534 FT_Char min_after_BL
;
537 } TT_SBit_LineMetricsRec
, *TT_SBit_LineMetrics
;
540 /*************************************************************************/
543 /* TT_SBit_RangeRec */
546 /* A TrueType/OpenType subIndexTable as defined in the `EBLC' */
547 /* (Microsoft) or `bloc' (Apple) tables. */
550 /* first_glyph :: The first glyph index in the range. */
552 /* last_glyph :: The last glyph index in the range. */
554 /* index_format :: The format of index table. Valid values are 1 */
557 /* image_format :: The format of `EBDT' image data. */
559 /* image_offset :: The offset to image data in `EBDT'. */
561 /* image_size :: For index formats 2 and 5. This is the size in */
562 /* bytes of each glyph bitmap. */
564 /* big_metrics :: For index formats 2 and 5. This is the big */
565 /* metrics for each glyph bitmap. */
567 /* num_glyphs :: For index formats 4 and 5. This is the number of */
568 /* glyphs in the code array. */
570 /* glyph_offsets :: For index formats 1 and 3. */
572 /* glyph_codes :: For index formats 4 and 5. */
574 /* table_offset :: The offset of the index table in the `EBLC' */
575 /* table. Only used during strike loading. */
577 typedef struct TT_SBit_RangeRec_
579 FT_UShort first_glyph
;
580 FT_UShort last_glyph
;
582 FT_UShort index_format
;
583 FT_UShort image_format
;
584 FT_ULong image_offset
;
587 TT_SBit_MetricsRec metrics
;
590 FT_ULong
* glyph_offsets
;
591 FT_UShort
* glyph_codes
;
593 FT_ULong table_offset
;
595 } TT_SBit_RangeRec
, *TT_SBit_Range
;
598 /*************************************************************************/
601 /* TT_SBit_StrikeRec */
604 /* A structure used describe a given bitmap strike in the `EBLC' */
605 /* (Microsoft) or `bloc' (Apple) tables. */
608 /* num_index_ranges :: The number of index ranges. */
610 /* index_ranges :: An array of glyph index ranges. */
612 /* color_ref :: Unused. `color_ref' is put in for future */
613 /* enhancements, but these fields are already */
614 /* in use by other platforms (e.g. Newton). */
615 /* For details, please see */
617 /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html */
619 /* hori :: The line metrics for horizontal layouts. */
621 /* vert :: The line metrics for vertical layouts. */
623 /* start_glyph :: The lowest glyph index for this strike. */
625 /* end_glyph :: The highest glyph index for this strike. */
627 /* x_ppem :: The number of horizontal pixels per EM. */
629 /* y_ppem :: The number of vertical pixels per EM. */
631 /* bit_depth :: The bit depth. Valid values are 1, 2, 4, */
634 /* flags :: Is this a vertical or horizontal strike? For */
635 /* details, please see */
637 /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html */
639 typedef struct TT_SBit_StrikeRec_
642 TT_SBit_Range sbit_ranges
;
643 FT_ULong ranges_offset
;
647 TT_SBit_LineMetricsRec hori
;
648 TT_SBit_LineMetricsRec vert
;
650 FT_UShort start_glyph
;
659 } TT_SBit_StrikeRec
, *TT_SBit_Strike
;
662 /*************************************************************************/
665 /* TT_SBit_ComponentRec */
668 /* A simple structure to describe a compound sbit element. */
671 /* glyph_code :: The element's glyph index. */
673 /* x_offset :: The element's left bearing. */
675 /* y_offset :: The element's top bearing. */
677 typedef struct TT_SBit_ComponentRec_
679 FT_UShort glyph_code
;
683 } TT_SBit_ComponentRec
, *TT_SBit_Component
;
686 /*************************************************************************/
689 /* TT_SBit_ScaleRec */
692 /* A structure used describe a given bitmap scaling table, as defined */
693 /* in the `EBSC' table. */
696 /* hori :: The horizontal line metrics. */
698 /* vert :: The vertical line metrics. */
700 /* x_ppem :: The number of horizontal pixels per EM. */
702 /* y_ppem :: The number of vertical pixels per EM. */
704 /* x_ppem_substitute :: Substitution x_ppem value. */
706 /* y_ppem_substitute :: Substitution y_ppem value. */
708 typedef struct TT_SBit_ScaleRec_
710 TT_SBit_LineMetricsRec hori
;
711 TT_SBit_LineMetricsRec vert
;
716 FT_Byte x_ppem_substitute
;
717 FT_Byte y_ppem_substitute
;
719 } TT_SBit_ScaleRec
, *TT_SBit_Scale
;
722 /*************************************************************************/
723 /*************************************************************************/
724 /*************************************************************************/
727 /*** POSTSCRIPT GLYPH NAMES SUPPORT ***/
730 /*************************************************************************/
731 /*************************************************************************/
732 /*************************************************************************/
735 /*************************************************************************/
741 /* Postscript names sub-table, format 2.0. Stores the PS name of */
742 /* each glyph in the font face. */
745 /* num_glyphs :: The number of named glyphs in the table. */
747 /* num_names :: The number of PS names stored in the table. */
749 /* glyph_indices :: The indices of the glyphs in the names arrays. */
751 /* glyph_names :: The PS names not in Mac Encoding. */
753 typedef struct TT_Post_20Rec_
755 FT_UShort num_glyphs
;
757 FT_UShort
* glyph_indices
;
758 FT_Char
** glyph_names
;
760 } TT_Post_20Rec
, *TT_Post_20
;
763 /*************************************************************************/
769 /* Postscript names sub-table, format 2.5. Stores the PS name of */
770 /* each glyph in the font face. */
773 /* num_glyphs :: The number of glyphs in the table. */
775 /* offsets :: An array of signed offsets in a normal Mac */
776 /* Postscript name encoding. */
778 typedef struct TT_Post_25_
780 FT_UShort num_glyphs
;
783 } TT_Post_25Rec
, *TT_Post_25
;
786 /*************************************************************************/
789 /* TT_Post_NamesRec */
792 /* Postscript names table, either format 2.0 or 2.5. */
795 /* loaded :: A flag to indicate whether the PS names are loaded. */
797 /* format_20 :: The sub-table used for format 2.0. */
799 /* format_25 :: The sub-table used for format 2.5. */
801 typedef struct TT_Post_NamesRec_
807 TT_Post_20Rec format_20
;
808 TT_Post_25Rec format_25
;
812 } TT_Post_NamesRec
, *TT_Post_Names
;
815 /*************************************************************************/
816 /*************************************************************************/
817 /*************************************************************************/
820 /*** GX VARIATION TABLE SUPPORT ***/
823 /*************************************************************************/
824 /*************************************************************************/
825 /*************************************************************************/
828 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
829 typedef struct GX_BlendRec_
*GX_Blend
;
832 /*************************************************************************/
833 /*************************************************************************/
834 /*************************************************************************/
837 /*** EMBEDDED BDF PROPERTIES TABLE SUPPORT ***/
840 /*************************************************************************/
841 /*************************************************************************/
842 /*************************************************************************/
845 * These types are used to support a `BDF ' table that isn't part of the
846 * official TrueType specification. It is mainly used in SFNT-based
847 * bitmap fonts that were generated from a set of BDF fonts.
849 * The format of the table is as follows.
851 * USHORT version `BDF ' table version number, should be 0x0001.
852 * USHORT strikeCount Number of strikes (bitmap sizes) in this table.
853 * ULONG stringTable Offset (from start of BDF table) to string
856 * This is followed by an array of `strikeCount' descriptors, having the
859 * USHORT ppem Vertical pixels per EM for this strike.
860 * USHORT numItems Number of items for this strike (properties and
861 * atoms). Maximum is 255.
863 * This array in turn is followed by `strikeCount' value sets. Each
864 * `value set' is an array of `numItems' items with the following format.
866 * ULONG item_name Offset in string table to item name.
867 * USHORT item_type The item type. Possible values are
868 * 0 => string (e.g., COMMENT)
869 * 1 => atom (e.g., FONT or even SIZE)
872 * 0x10 => A flag to indicate a properties. This
873 * is ORed with the above values.
874 * ULONG item_value For strings => Offset into string table without
875 * the corresponding double quotes.
876 * For atoms => Offset into string table.
877 * For integers => Direct value.
879 * All strings in the string table consist of bytes and are
884 #ifdef TT_CONFIG_OPTION_BDF
886 typedef struct TT_BDFRec_
891 FT_ULong strings_size
;
895 } TT_BDFRec
, *TT_BDF
;
897 #endif /* TT_CONFIG_OPTION_BDF */
899 /*************************************************************************/
900 /*************************************************************************/
901 /*************************************************************************/
904 /*** ORIGINAL TT_FACE CLASS DEFINITION ***/
907 /*************************************************************************/
908 /*************************************************************************/
909 /*************************************************************************/
912 /*************************************************************************/
914 /* This structure/class is defined here because it is common to the */
915 /* following formats: TTF, OpenType-TT, and OpenType-CFF. */
917 /* Note, however, that the classes TT_Size and TT_GlyphSlot are not */
918 /* shared between font drivers, and are thus defined in `ttobjs.h'. */
920 /*************************************************************************/
923 /*************************************************************************/
929 /* A handle to a TrueType face/font object. A TT_Face encapsulates */
930 /* the resolution and scaling independent parts of a TrueType font */
934 /* The TT_Face structure is also used as a `parent class' for the */
935 /* OpenType-CFF class (T2_Face). */
937 typedef struct TT_FaceRec_
* TT_Face
;
940 /* a function type used for the truetype bytecode interpreter hooks */
942 (*TT_Interpreter
)( void* exec_context
);
944 /* forward declaration */
945 typedef struct TT_LoaderRec_
* TT_Loader
;
948 /*************************************************************************/
951 /* TT_Loader_GotoTableFunc */
954 /* Seeks a stream to the start of a given TrueType table. */
957 /* face :: A handle to the target face object. */
959 /* tag :: A 4-byte tag used to name the table. */
961 /* stream :: The input stream. */
964 /* length :: The length of the table in bytes. Set to 0 if not */
968 /* FreeType error code. 0 means success. */
971 /* The stream cursor must be at the font file's origin. */
974 (*TT_Loader_GotoTableFunc
)( TT_Face face
,
980 /*************************************************************************/
983 /* TT_Loader_StartGlyphFunc */
986 /* Seeks a stream to the start of a given glyph element, and opens a */
990 /* loader :: The current TrueType glyph loader object. */
992 /* glyph index :: The index of the glyph to access. */
994 /* offset :: The offset of the glyph according to the */
995 /* `locations' table. */
997 /* byte_count :: The size of the frame in bytes. */
1000 /* FreeType error code. 0 means success. */
1003 /* This function is normally equivalent to FT_STREAM_SEEK(offset) */
1004 /* followed by FT_FRAME_ENTER(byte_count) with the loader's stream, */
1005 /* but alternative formats (e.g. compressed ones) might use something */
1009 (*TT_Loader_StartGlyphFunc
)( TT_Loader loader
,
1010 FT_UInt glyph_index
,
1012 FT_UInt byte_count
);
1015 /*************************************************************************/
1018 /* TT_Loader_ReadGlyphFunc */
1021 /* Reads one glyph element (its header, a simple glyph, or a */
1022 /* composite) from the loader's current stream frame. */
1025 /* loader :: The current TrueType glyph loader object. */
1028 /* FreeType error code. 0 means success. */
1031 (*TT_Loader_ReadGlyphFunc
)( TT_Loader loader
);
1034 /*************************************************************************/
1037 /* TT_Loader_EndGlyphFunc */
1040 /* Closes the current loader stream frame for the glyph. */
1043 /* loader :: The current TrueType glyph loader object. */
1046 (*TT_Loader_EndGlyphFunc
)( TT_Loader loader
);
1049 typedef enum TT_SbitTableType_
1051 TT_SBIT_TABLE_TYPE_NONE
= 0,
1052 TT_SBIT_TABLE_TYPE_EBLC
, /* `EBLC' (Microsoft), */
1053 /* `bloc' (Apple) */
1054 TT_SBIT_TABLE_TYPE_CBLC
, /* `CBLC' (Google) */
1055 TT_SBIT_TABLE_TYPE_SBIX
, /* `sbix' (Apple) */
1058 TT_SBIT_TABLE_TYPE_MAX
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 `vertical_info' 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_scales :: The number of sbit scales for this font. */
1176 /* sbit_scales :: Array of sbit scales embedded in this */
1177 /* font. This table is optional in a */
1178 /* TrueType/OpenType font. */
1180 /* postscript_names :: A table used to store the Postscript names */
1181 /* of the glyphs for this font. See the */
1182 /* file `ttconfig.h' for comments on the */
1183 /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES option. */
1185 /* num_locations :: The number of glyph locations in this */
1186 /* TrueType file. This should be */
1187 /* identical to the number of glyphs. */
1188 /* Ignored for Type 2 fonts. */
1190 /* glyph_locations :: An array of longs. These are offsets to */
1191 /* glyph data within the `glyf' table. */
1192 /* Ignored for Type 2 font faces. */
1194 /* glyf_len :: The length of the `glyf' table. Needed */
1195 /* for malformed `loca' tables. */
1197 /* font_program_size :: Size in bytecodes of the face's font */
1198 /* program. 0 if none defined. Ignored for */
1201 /* font_program :: The face's font program (bytecode stream) */
1202 /* executed at load time, also used during */
1203 /* glyph rendering. Comes from the `fpgm' */
1204 /* table. Ignored for Type 2 font fonts. */
1206 /* cvt_program_size :: The size in bytecodes of the face's cvt */
1207 /* program. Ignored for Type 2 fonts. */
1209 /* cvt_program :: The face's cvt program (bytecode stream) */
1210 /* executed each time an instance/size is */
1211 /* changed/reset. Comes from the `prep' */
1212 /* table. Ignored for Type 2 fonts. */
1214 /* cvt_size :: Size of the control value table (in */
1215 /* entries). Ignored for Type 2 fonts. */
1217 /* cvt :: The face's original control value table. */
1218 /* Coordinates are expressed in unscaled font */
1219 /* units. Comes from the `cvt ' table. */
1220 /* Ignored for Type 2 fonts. */
1222 /* num_kern_pairs :: The number of kerning pairs present in the */
1223 /* font file. The engine only loads the */
1224 /* first horizontal format 0 kern table it */
1225 /* finds in the font file. Ignored for */
1228 /* kern_table_index :: The index of the kerning table in the font */
1229 /* kerning directory. Ignored for Type 2 */
1232 /* interpreter :: A pointer to the TrueType bytecode */
1233 /* interpreters field is also used to hook */
1234 /* the debugger in `ttdebug'. */
1236 /* unpatented_hinting :: If true, use only unpatented methods in */
1237 /* the bytecode interpreter. */
1239 /* doblend :: A boolean which is set if the font should */
1240 /* be blended (this is for GX var). */
1242 /* blend :: Contains the data needed to control GX */
1243 /* variation tables (rather like Multiple */
1246 /* extra :: Reserved for third-party font drivers. */
1248 /* postscript_name :: The PS name of the font. Used by the */
1249 /* postscript name service. */
1251 typedef struct TT_FaceRec_
1255 TTC_HeaderRec ttc_header
;
1257 FT_ULong format_tag
;
1258 FT_UShort num_tables
;
1259 TT_Table dir_tables
;
1261 TT_Header header
; /* TrueType header table */
1262 TT_HoriHeader horizontal
; /* TrueType horizontal header */
1264 TT_MaxProfile max_profile
;
1266 FT_Bool vertical_info
;
1267 TT_VertHeader vertical
; /* TT Vertical header, if present */
1269 FT_UShort num_names
; /* number of name records */
1270 TT_NameTableRec name_table
; /* name table */
1272 TT_OS2 os2
; /* TrueType OS/2 table */
1273 TT_Postscript postscript
; /* TrueType Postscript table */
1275 FT_Byte
* cmap_table
; /* extracted `cmap' table */
1278 TT_Loader_GotoTableFunc goto_table
;
1280 TT_Loader_StartGlyphFunc access_glyph_frame
;
1281 TT_Loader_EndGlyphFunc forget_glyph_frame
;
1282 TT_Loader_ReadGlyphFunc read_glyph_header
;
1283 TT_Loader_ReadGlyphFunc read_simple_glyph
;
1284 TT_Loader_ReadGlyphFunc read_composite_glyph
;
1286 /* a typeless pointer to the SFNT_Interface table used to load */
1287 /* the basic TrueType tables in the face object */
1290 /* a typeless pointer to the FT_Service_PsCMapsRec table used to */
1291 /* handle glyph names <-> unicode & Mac values */
1295 /***********************************************************************/
1297 /* Optional TrueType/OpenType tables */
1299 /***********************************************************************/
1301 /* grid-fitting and scaling table */
1302 TT_GaspRec gasp
; /* the `gasp' table */
1307 /* embedded bitmaps support */
1308 FT_ULong num_sbit_scales
;
1309 TT_SBit_Scale sbit_scales
;
1311 /* postscript names table */
1312 TT_Post_NamesRec postscript_names
;
1315 /***********************************************************************/
1317 /* TrueType-specific fields (ignored by the OTF-Type2 driver) */
1319 /***********************************************************************/
1321 /* the font program, if any */
1322 FT_ULong font_program_size
;
1323 FT_Byte
* font_program
;
1325 /* the cvt program, if any */
1326 FT_ULong cvt_program_size
;
1327 FT_Byte
* cvt_program
;
1329 /* the original, unscaled, control value table */
1333 /* A pointer to the bytecode interpreter to use. This is also */
1334 /* used to hook the debugger for the `ttdebug' utility. */
1335 TT_Interpreter interpreter
;
1337 #ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
1338 /* Use unpatented hinting only. */
1339 FT_Bool unpatented_hinting
;
1342 /***********************************************************************/
1344 /* Other tables or fields. This is used by derivative formats like */
1347 /***********************************************************************/
1351 const char* postscript_name
;
1355 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1360 /* since version 2.2 */
1362 FT_Byte
* horz_metrics
;
1363 FT_ULong horz_metrics_size
;
1365 FT_Byte
* vert_metrics
;
1366 FT_ULong vert_metrics_size
;
1368 FT_ULong num_locations
; /* in broken TTF, gid > 0xFFFF */
1369 FT_Byte
* glyph_locations
;
1371 FT_Byte
* hdmx_table
;
1372 FT_ULong hdmx_table_size
;
1373 FT_UInt hdmx_record_count
;
1374 FT_ULong hdmx_record_size
;
1375 FT_Byte
* hdmx_record_sizes
;
1377 FT_Byte
* sbit_table
;
1378 FT_ULong sbit_table_size
;
1379 TT_SbitTableType sbit_table_type
;
1380 FT_UInt sbit_num_strikes
;
1382 FT_Byte
* kern_table
;
1383 FT_ULong kern_table_size
;
1384 FT_UInt num_kern_tables
;
1385 FT_UInt32 kern_avail_bits
;
1386 FT_UInt32 kern_order_bits
;
1388 #ifdef TT_CONFIG_OPTION_BDF
1390 #endif /* TT_CONFIG_OPTION_BDF */
1393 FT_ULong horz_metrics_offset
;
1394 FT_ULong vert_metrics_offset
;
1396 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
1398 FT_ULong sph_found_func_flags
; /* special functions found */
1400 FT_Bool sph_compatibility_mode
;
1401 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
1406 /*************************************************************************/
1409 /* TT_GlyphZoneRec */
1412 /* A glyph zone is used to load, scale and hint glyph outline */
1416 /* memory :: A handle to the memory manager. */
1418 /* max_points :: The maximum size in points of the zone. */
1420 /* max_contours :: Max size in links contours of the zone. */
1422 /* n_points :: The current number of points in the zone. */
1424 /* n_contours :: The current number of contours in the zone. */
1426 /* org :: The original glyph coordinates (font */
1427 /* units/scaled). */
1429 /* cur :: The current glyph coordinates (scaled/hinted). */
1431 /* tags :: The point control tags. */
1433 /* contours :: The contours end points. */
1435 /* first_point :: Offset of the current subglyph's first point. */
1437 typedef struct TT_GlyphZoneRec_
1440 FT_UShort max_points
;
1441 FT_Short max_contours
;
1442 FT_UShort n_points
; /* number of points in zone */
1443 FT_Short n_contours
; /* number of contours */
1445 FT_Vector
* org
; /* original point coordinates */
1446 FT_Vector
* cur
; /* current point coordinates */
1447 FT_Vector
* orus
; /* original (unscaled) point coordinates */
1449 FT_Byte
* tags
; /* current touch flags */
1450 FT_UShort
* contours
; /* contour end points */
1452 FT_UShort first_point
; /* offset of first (#0) point */
1454 } TT_GlyphZoneRec
, *TT_GlyphZone
;
1457 /* handle to execution context */
1458 typedef struct TT_ExecContextRec_
* TT_ExecContext
;
1460 /* glyph loader structure */
1461 typedef struct TT_LoaderRec_
1466 FT_GlyphLoader gloader
;
1468 FT_ULong load_flags
;
1469 FT_UInt glyph_index
;
1474 FT_Short n_contours
;
1476 FT_Int left_bearing
;
1483 FT_ULong glyf_offset
;
1485 /* the zone where we load our glyphs */
1486 TT_GlyphZoneRec base
;
1487 TT_GlyphZoneRec zone
;
1489 TT_ExecContext exec
;
1490 FT_Byte
* instructions
;
1493 /* for possible extensibility in other formats */
1496 /* since version 2.1.8 */
1502 /* since version 2.2.1 */
1511 #endif /* __TTTYPES_H__ */