Add code to build a `gasp' table.
[ttfautohint.git] / src / ta.h
blobb0196e66de8232fbbc680385c30adfe17176252b
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 "taloader.h"
16 #include "talatin.h"
17 #include "ttfautohint.h"
20 /* these macros convert 16bit and 32bit numbers into single bytes */
21 /* using the byte order needed within SFNT files */
23 #define HIGH(x) (FT_Byte)(((x) & 0xFF00) >> 8)
24 #define LOW(x) ((x) & 0x00FF)
26 #define BYTE1(x) (FT_Byte)(((x) & 0xFF000000UL) >> 24);
27 #define BYTE2(x) (FT_Byte)(((x) & 0x00FF0000UL) >> 16);
28 #define BYTE3(x) (FT_Byte)(((x) & 0x0000FF00UL) >> 8);
29 #define BYTE4(x) ((x) & 0x000000FFUL);
32 /* the length of a dummy `DSIG' table */
33 #define DSIG_LEN 8
35 /* the length of our `gasp' table */
36 #define GASP_LEN 8
38 /* an empty slot in the table info array */
39 #define MISSING (FT_ULong)~0
41 /* the offset to the loca table format in the `head' table */
42 #define LOCA_FORMAT_OFFSET 51
44 /* various offsets within the `maxp' table */
45 #define MAXP_MAX_ZONES_OFFSET 14
46 #define MAXP_MAX_TWILIGHT_POINTS_OFFSET 16
47 #define MAXP_MAX_STORAGE_OFFSET 18
48 #define MAXP_MAX_FUNCTION_DEFS_OFFSET 20
49 #define MAXP_MAX_INSTRUCTION_DEFS_OFFSET 22
50 #define MAXP_MAX_STACK_ELEMENTS_OFFSET 24
51 #define MAXP_MAX_INSTRUCTIONS_OFFSET 26
53 #define MAXP_LEN 32
56 /* flags in composite glyph records */
57 #define ARGS_ARE_WORDS 0x0001
58 #define ARGS_ARE_XY_VALUES 0x0002
59 #define WE_HAVE_A_SCALE 0x0008
60 #define MORE_COMPONENTS 0x0020
61 #define WE_HAVE_AN_XY_SCALE 0x0040
62 #define WE_HAVE_A_2X2 0x0080
63 #define WE_HAVE_INSTR 0x0100
65 /* flags in simple glyph records */
66 #define X_SHORT_VECTOR 0x02
67 #define Y_SHORT_VECTOR 0x04
68 #define REPEAT 0x08
69 #define SAME_X 0x10
70 #define SAME_Y 0x20
73 /* a single glyph */
74 typedef struct GLYPH_
76 FT_ULong len1; /* number of bytes before instructions location */
77 FT_ULong len2; /* number of bytes after instructions location; */
78 /* if zero, this indicates a composite glyph */
79 FT_Byte* buf; /* extracted glyph data */
80 FT_ULong flags_offset; /* offset to last flag in a composite glyph */
82 FT_ULong ins_len; /* number of new instructions */
83 FT_Byte* ins_buf; /* new instruction data */
84 } GLYPH;
86 /* a representation of the data in the `glyf' table */
87 typedef struct glyf_Data_
89 FT_UShort num_glyphs;
90 GLYPH* glyphs;
91 } glyf_Data;
93 /* an SFNT table */
94 typedef struct SFNT_Table_ {
95 FT_ULong tag;
96 FT_ULong len;
97 FT_Byte* buf; /* the table data */
98 FT_ULong offset; /* from beginning of file */
99 FT_ULong checksum;
100 void* data; /* used e.g. for `glyf' table data */
101 FT_Bool processed;
102 } SFNT_Table;
104 /* we use indices into the SFNT table array to */
105 /* represent table info records of the TTF header */
106 typedef FT_ULong SFNT_Table_Info;
108 /* this structure is used to model a TTF or a subfont within a TTC */
109 typedef struct SFNT_ {
110 FT_Face face;
112 SFNT_Table_Info* table_infos;
113 FT_ULong num_table_infos;
115 /* various SFNT table indices */
116 FT_ULong glyf_idx;
117 FT_ULong loca_idx;
118 FT_ULong head_idx;
119 FT_ULong maxp_idx;
120 } SFNT;
122 /* our font object */
123 typedef struct FONT_ {
124 FT_Library lib;
126 FT_Byte* in_buf;
127 size_t in_len;
129 FT_Byte* out_buf;
130 size_t out_len;
132 SFNT* sfnts;
133 FT_Long num_sfnts;
135 SFNT_Table* tables;
136 FT_ULong num_tables;
138 TA_LoaderRec loader[1]; /* the interface to the autohinter */
139 } FONT;
141 #include "tatables.h"
142 #include "tabytecode.h"
144 #endif /* __TA_H__ */
146 /* end of ta.h */