Typo.
[ttfautohint.git] / src / ta.h
blob87b39acd3b4432f5f9f0e3cdc4660df55f8fe9b7
1 /* ta.h */
3 /*
4 * Copyright (C) 2011 by Werner Lemberg.
6 * This file is part of the ttfautohint library, and may only be used,
7 * modified, and distributed under the terms given in `COPYING'. By
8 * continuing to use, modify, or distribute this file you indicate that you
9 * have read `COPYING' and understand and accept it fully.
11 * The file `COPYING' mentioned in the previous paragraph is distributed
12 * with the ttfautohint library.
16 #ifndef __TA_H__
17 #define __TA_H__
19 #include <config.h>
21 #include <ft2build.h>
22 #include FT_FREETYPE_H
23 #include FT_TRUETYPE_TABLES_H
24 #include FT_TRUETYPE_TAGS_H
26 #include "taloader.h"
27 #include "tadummy.h"
28 #include "talatin.h"
29 #include "ttfautohint.h"
32 /* these macros convert 16bit and 32bit numbers into single bytes */
33 /* using the byte order needed within SFNT files */
35 #define HIGH(x) (FT_Byte)(((x) & 0xFF00) >> 8)
36 #define LOW(x) ((x) & 0x00FF)
38 #define BYTE1(x) (FT_Byte)(((x) & 0xFF000000UL) >> 24);
39 #define BYTE2(x) (FT_Byte)(((x) & 0x00FF0000UL) >> 16);
40 #define BYTE3(x) (FT_Byte)(((x) & 0x0000FF00UL) >> 8);
41 #define BYTE4(x) ((x) & 0x000000FFUL);
44 /* the length of a dummy `DSIG' table */
45 #define DSIG_LEN 8
47 /* the length of our `gasp' table */
48 #define GASP_LEN 8
50 /* an empty slot in the table info array */
51 #define MISSING (FT_ULong)~0
53 /* the offset to the loca table format in the `head' table */
54 #define LOCA_FORMAT_OFFSET 51
56 /* various offsets within the `maxp' table */
57 #define MAXP_MAX_ZONES_OFFSET 14
58 #define MAXP_MAX_TWILIGHT_POINTS_OFFSET 16
59 #define MAXP_MAX_STORAGE_OFFSET 18
60 #define MAXP_MAX_FUNCTION_DEFS_OFFSET 20
61 #define MAXP_MAX_INSTRUCTION_DEFS_OFFSET 22
62 #define MAXP_MAX_STACK_ELEMENTS_OFFSET 24
63 #define MAXP_MAX_INSTRUCTIONS_OFFSET 26
65 #define MAXP_LEN 32
67 /* the offset of the type flags field in the `OS/2' table */
68 #define OS2_FSTYPE_OFFSET 8
71 /* flags in composite glyph records */
72 #define ARGS_ARE_WORDS 0x0001
73 #define ARGS_ARE_XY_VALUES 0x0002
74 #define WE_HAVE_A_SCALE 0x0008
75 #define MORE_COMPONENTS 0x0020
76 #define WE_HAVE_AN_XY_SCALE 0x0040
77 #define WE_HAVE_A_2X2 0x0080
78 #define WE_HAVE_INSTR 0x0100
80 /* flags in simple glyph records */
81 #define X_SHORT_VECTOR 0x02
82 #define Y_SHORT_VECTOR 0x04
83 #define REPEAT 0x08
84 #define SAME_X 0x10
85 #define SAME_Y 0x20
88 /* a single glyph */
89 typedef struct GLYPH_
91 FT_ULong len1; /* number of bytes before instructions location */
92 FT_ULong len2; /* number of bytes after instructions location; */
93 /* if zero, this indicates a composite glyph */
94 FT_Byte* buf; /* extracted glyph data */
95 FT_ULong flags_offset; /* offset to last flag in a composite glyph */
97 FT_ULong ins_len; /* number of new instructions */
98 FT_Byte* ins_buf; /* new instruction data */
99 } GLYPH;
101 /* a representation of the data in the `glyf' table */
102 typedef struct glyf_Data_
104 FT_UShort num_glyphs;
105 GLYPH* glyphs;
106 } glyf_Data;
108 /* an SFNT table */
109 typedef struct SFNT_Table_ {
110 FT_ULong tag;
111 FT_ULong len;
112 FT_Byte* buf; /* the table data */
113 FT_ULong offset; /* from beginning of file */
114 FT_ULong checksum;
115 void* data; /* used e.g. for `glyf' table data */
116 FT_Bool processed;
117 } SFNT_Table;
119 /* we use indices into the SFNT table array to */
120 /* represent table info records of the TTF header */
121 typedef FT_ULong SFNT_Table_Info;
123 /* this structure is used to model a TTF or a subfont within a TTC */
124 typedef struct SFNT_ {
125 FT_Face face;
127 SFNT_Table_Info* table_infos;
128 FT_ULong num_table_infos;
130 /* various SFNT table indices */
131 FT_ULong glyf_idx;
132 FT_ULong loca_idx;
133 FT_ULong head_idx;
134 FT_ULong maxp_idx;
135 FT_ULong OS2_idx;
137 /* values necessary to update the `maxp' table */
138 FT_UShort max_storage;
139 FT_UShort max_stack_elements;
140 FT_UShort max_twilight_points;
141 FT_UShort max_instructions;
142 } SFNT;
144 /* our font object */
145 typedef struct FONT_ {
146 FT_Library lib;
148 FT_Byte* in_buf;
149 size_t in_len;
151 FT_Byte* out_buf;
152 size_t out_len;
154 SFNT* sfnts;
155 FT_Long num_sfnts;
157 SFNT_Table* tables;
158 FT_ULong num_tables;
160 TA_LoaderRec loader[1]; /* the interface to the autohinter */
162 /* configuration options */
163 TA_Progress_Func progress;
164 void *progress_data;
165 FT_UInt hinting_range_min;
166 FT_UInt hinting_range_max;
167 FT_Bool pre_hinting;
168 FT_Bool no_x_height_snapping;
169 FT_Byte* x_height_snapping_exceptions;
170 FT_Bool ignore_permissions;
171 FT_UInt fallback_script;
172 } FONT;
174 #include "tatables.h"
175 #include "tabytecode.h"
177 #endif /* __TA_H__ */
179 /* end of ta.h */