4 * Copyright (C) 2011-2012 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.
22 #include FT_FREETYPE_H
23 #include FT_TRUETYPE_TABLES_H
24 #include FT_TRUETYPE_TAGS_H
31 #include <ttfautohint.h>
34 #define TTFAUTOHINT_GLYPH ".ttfautohint"
35 #define TTFAUTOHINT_GLYPH_FIRST_BYTE "\x0C" /* first byte is string length */
36 #define TTFAUTOHINT_GLYPH_LEN 13
38 /* these macros convert 16bit and 32bit numbers into single bytes */
39 /* using the byte order needed within SFNT files */
41 #define HIGH(x) (FT_Byte)(((x) & 0xFF00) >> 8)
42 #define LOW(x) ((x) & 0x00FF)
44 #define BYTE1(x) (FT_Byte)(((x) & 0xFF000000UL) >> 24);
45 #define BYTE2(x) (FT_Byte)(((x) & 0x00FF0000UL) >> 16);
46 #define BYTE3(x) (FT_Byte)(((x) & 0x0000FF00UL) >> 8);
47 #define BYTE4(x) ((x) & 0x000000FFUL);
50 /* the length of a dummy `DSIG' table */
53 /* the length of our `gasp' table */
56 /* an empty slot in the table info array */
57 #define MISSING (FT_ULong)~0
59 /* the offset to the loca table format in the `head' table */
60 #define LOCA_FORMAT_OFFSET 51
62 /* various offsets within the `maxp' table */
63 #define MAXP_NUM_GLYPHS 4
64 #define MAXP_MAX_COMPOSITE_POINTS 10
65 #define MAXP_MAX_COMPOSITE_CONTOURS 12
66 #define MAXP_MAX_ZONES_OFFSET 14
67 #define MAXP_MAX_TWILIGHT_POINTS_OFFSET 16
68 #define MAXP_MAX_STORAGE_OFFSET 18
69 #define MAXP_MAX_FUNCTION_DEFS_OFFSET 20
70 #define MAXP_MAX_INSTRUCTION_DEFS_OFFSET 22
71 #define MAXP_MAX_STACK_ELEMENTS_OFFSET 24
72 #define MAXP_MAX_INSTRUCTIONS_OFFSET 26
73 #define MAXP_MAX_COMPONENTS_OFFSET 28
77 /* the offset of the type flags field in the `OS/2' table */
78 #define OS2_FSTYPE_OFFSET 8
81 /* flags in composite glyph records */
82 #define ARGS_ARE_WORDS 0x0001
83 #define ARGS_ARE_XY_VALUES 0x0002
84 #define WE_HAVE_A_SCALE 0x0008
85 #define MORE_COMPONENTS 0x0020
86 #define WE_HAVE_AN_XY_SCALE 0x0040
87 #define WE_HAVE_A_2X2 0x0080
88 #define WE_HAVE_INSTR 0x0100
90 /* flags in simple glyph records */
92 #define X_SHORT_VECTOR 0x02
93 #define Y_SHORT_VECTOR 0x04
100 typedef struct GLYPH_
102 FT_ULong len1
; /* number of bytes before instruction related data */
103 FT_ULong len2
; /* number of bytes after instruction related data; */
104 /* if zero, this indicates a composite glyph */
105 FT_Byte
* buf
; /* extracted glyph data (without instruction related data) */
106 FT_ULong flags_offset
; /* offset to last flag in a composite glyph */
108 FT_ULong ins_len
; /* number of new instructions */
109 FT_Byte
* ins_buf
; /* new instruction data */
111 FT_Short num_contours
; /* >= 0 for simple glyphs */
112 FT_UShort num_points
; /* number of points in a simple glyph */
114 FT_UShort num_components
;
115 FT_UShort
* components
; /* the subglyph indices of a composite glyph */
117 FT_UShort num_pointsums
;
118 FT_UShort
* pointsums
; /* the pointsums of all composite elements */
119 /* (after walking recursively over all subglyphs) */
121 FT_UShort num_composite_contours
; /* after recursion */
124 /* a representation of the data in the `glyf' table */
125 typedef struct glyf_Data_
127 FT_UShort num_glyphs
;
132 typedef struct SFNT_Table_
136 FT_Byte
* buf
; /* the table data */
137 FT_ULong offset
; /* from beginning of file */
139 void* data
; /* used e.g. for `glyf' table data */
143 /* we use indices into the SFNT table array to */
144 /* represent table info records of the TTF header */
145 typedef FT_ULong SFNT_Table_Info
;
147 /* this structure is used to model a TTF or a subfont within a TTC */
152 SFNT_Table_Info
* table_infos
;
153 FT_ULong num_table_infos
;
155 /* various SFNT table indices */
166 /* values necessary to update the `maxp' table */
167 FT_UShort max_composite_points
;
168 FT_UShort max_composite_contours
;
169 FT_UShort max_storage
;
170 FT_UShort max_stack_elements
;
171 FT_UShort max_twilight_points
;
172 FT_UShort max_instructions
;
173 FT_UShort max_components
;
176 /* our font object */
195 TA_LoaderRec loader
[1]; /* the interface to the autohinter */
197 /* configuration options */
198 TA_Progress_Func progress
;
202 FT_UInt hinting_range_min
;
203 FT_UInt hinting_range_max
;
204 FT_UInt hinting_limit
;
205 FT_UInt increase_x_height
;
206 FT_Bool gray_strong_stem_width
;
207 FT_Bool gdi_cleartype_strong_stem_width
;
208 FT_Bool dw_cleartype_strong_stem_width
;
210 FT_Bool hint_with_components
;
211 FT_Bool no_x_height_snapping
;
212 FT_Byte
* x_height_snapping_exceptions
;
213 FT_Bool ignore_restrictions
;
214 FT_UInt fallback_script
;
220 #include "tatables.h"
221 #include "tabytecode.h"
225 TA_get_error_message(FT_Error error
);
228 TA_get_current_time(FT_ULong
* high
,
232 TA_font_init(FONT
* font
);
234 TA_font_unload(FONT
* font
,
239 TA_font_file_read(FONT
* font
,
242 TA_font_file_write(FONT
* font
,
246 TA_sfnt_build_glyph_instructions(SFNT
* sfnt
,
251 TA_sfnt_split_into_SFNT_tables(SFNT
* sfnt
,
255 TA_sfnt_build_cvt_table(SFNT
* sfnt
,
259 TA_table_build_DSIG(FT_Byte
** DSIG
);
262 TA_sfnt_build_fpgm_table(SFNT
* sfnt
,
266 TA_sfnt_build_gasp_table(SFNT
* sfnt
,
270 TA_sfnt_build_glyf_hints(SFNT
* sfnt
,
273 TA_sfnt_split_glyf_table(SFNT
* sfnt
,
276 TA_sfnt_build_glyf_table(SFNT
* sfnt
,
279 TA_sfnt_create_glyf_data(SFNT
* sfnt
,
283 TA_sfnt_update_GPOS_table(SFNT
* sfnt
,
287 TA_sfnt_update_hmtx_table(SFNT
* sfnt
,
291 TA_sfnt_build_loca_table(SFNT
* sfnt
,
295 TA_sfnt_update_maxp_table(SFNT
* sfnt
,
299 TA_sfnt_update_post_table(SFNT
* sfnt
,
303 TA_sfnt_update_name_table(SFNT
* sfnt
,
307 TA_sfnt_build_prep_table(SFNT
* sfnt
,
311 TA_sfnt_build_TTF_header(SFNT
* sfnt
,
313 FT_Byte
** header_buf
,
314 FT_ULong
* header_len
,
317 TA_font_build_TTF(FONT
* font
);
320 TA_font_build_TTC(FONT
* font
);
322 #endif /* __TA_H__ */