Move header-like stuff to a new header file.
[ttfautohint.git] / src / ta.h
blob629841702bc7b3f118503b4bc8f59e05b0a4967b
1 /* ta.h */
3 /* written 2011 by Werner Lemberg <wl@gnu.org> */
5 #ifndef __TA_H__
6 #define __TA_H__
8 #include <config.h>
10 #include <ft2build.h>
11 #include FT_FREETYPE_H
12 #include FT_TRUETYPE_TABLES_H
13 #include FT_TRUETYPE_TAGS_H
15 #include "ttfautohint.h"
18 /* these macros convert 16bit and 32bit numbers into single bytes */
19 /* using the byte order needed within SFNT files */
21 #define HIGH(x) (FT_Byte)(((x) & 0xFF00) >> 8)
22 #define LOW(x) ((x) & 0x00FF)
24 #define BYTE1(x) (FT_Byte)(((x) & 0xFF000000UL) >> 24);
25 #define BYTE2(x) (FT_Byte)(((x) & 0x00FF0000UL) >> 16);
26 #define BYTE3(x) (FT_Byte)(((x) & 0x0000FF00UL) >> 8);
27 #define BYTE4(x) ((x) & 0x000000FFUL);
30 /* the length of a dummy `DSIG' table */
31 #define DSIG_LEN 8
33 /* an empty slot in the table info array */
34 #define MISSING (FT_ULong)~0
36 /* the offset to the loca table format in the `head' table */
37 #define LOCA_FORMAT_OFFSET 51
39 /* various offsets within the `maxp' table */
40 #define MAXP_MAX_ZONES_OFFSET 14
41 #define MAXP_MAX_TWILIGHT_POINTS_OFFSET 16
42 #define MAXP_MAX_STORAGE_OFFSET 18
43 #define MAXP_MAX_FUNCTION_DEFS_OFFSET 20
44 #define MAXP_MAX_INSTRUCTION_DEFS_OFFSET 22
45 #define MAXP_MAX_STACK_ELEMENTS_OFFSET 24
46 #define MAXP_MAX_INSTRUCTIONS_OFFSET 26
48 #define MAXP_LEN 32
51 /* flags in composite glyph records */
52 #define ARGS_ARE_WORDS 0x0001
53 #define ARGS_ARE_XY_VALUES 0x0002
54 #define WE_HAVE_A_SCALE 0x0008
55 #define MORE_COMPONENTS 0x0020
56 #define WE_HAVE_AN_XY_SCALE 0x0040
57 #define WE_HAVE_A_2X2 0x0080
58 #define WE_HAVE_INSTR 0x0100
60 /* flags in simple glyph records */
61 #define X_SHORT_VECTOR 0x02
62 #define Y_SHORT_VECTOR 0x04
63 #define REPEAT 0x08
64 #define SAME_X 0x10
65 #define SAME_Y 0x20
68 /* a single glyph */
69 typedef struct GLYPH_
71 FT_ULong len;
72 FT_Byte* buf;
73 } GLYPH;
75 /* a representation of the data in the `glyf' table */
76 typedef struct glyf_Data_
78 FT_UShort num_glyphs;
79 GLYPH* glyphs;
80 } glyf_Data;
82 /* an SFNT table */
83 typedef struct SFNT_Table_ {
84 FT_ULong tag;
85 FT_ULong len;
86 FT_Byte* buf; /* the table data */
87 FT_ULong offset; /* from beginning of file */
88 FT_ULong checksum;
89 void* data; /* used e.g. for `glyf' table data */
90 FT_Bool processed;
91 } SFNT_Table;
93 /* we use indices into the SFNT table array to */
94 /* represent table info records of the TTF header */
95 typedef FT_ULong SFNT_Table_Info;
97 /* this structure is used to model a TTF or a subfont within a TTC */
98 typedef struct SFNT_ {
99 FT_Face face;
101 SFNT_Table_Info* table_infos;
102 FT_ULong num_table_infos;
104 /* various SFNT table indices */
105 FT_ULong glyf_idx;
106 FT_ULong loca_idx;
107 FT_ULong head_idx;
108 FT_ULong maxp_idx;
109 } SFNT;
111 /* our font object */
112 typedef struct FONT_ {
113 FT_Library lib;
115 FT_Byte* in_buf;
116 size_t in_len;
118 FT_Byte* out_buf;
119 size_t out_len;
121 SFNT* sfnts;
122 FT_Long num_sfnts;
124 SFNT_Table* tables;
125 FT_ULong num_tables;
126 } FONT;
128 #endif /* __TA_H__ */
130 /* end of ta.h */