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.
16 /* originally file `aftypes.h' (2011-Mar-30) from FreeType */
18 /* heavily modified 2011 by Werner Lemberg <wl@gnu.org> */
25 #include FT_FREETYPE_H
29 /* enable one of the following three definitions for debugging */
30 /* #define TA_DEBUG */
31 /* #define TA_DEBUG_HORZ */
34 #if defined TA_DEBUG_HORZ
35 # define TA_DEBUG_STARTDIM TA_DIMENSION_HORZ
36 # define TA_DEBUG_ENDDIM TA_DIMENSION_HORZ
38 #elif defined TA_DEBUG_VERT
39 # define TA_DEBUG_STARTDIM TA_DIMENSION_VERT
40 # define TA_DEBUG_ENDDIM TA_DIMENSION_VERT
42 #elif defined TA_DEBUG
43 # define TA_DEBUG_STARTDIM TA_DIMENSION_VERT
44 # define TA_DEBUG_ENDDIM TA_DIMENSION_HORZ
56 _ta_message(const char *format
,
60 extern int _ta_debug_disable_horz_hints
;
61 extern int _ta_debug_disable_vert_hints
;
62 extern int _ta_debug_disable_blue_hints
;
63 extern void* _ta_debug_hints
;
68 do { } while (0) /* nothing */
70 #endif /* !TA_DEBUG */
73 #define TA_ABS(a) ((a) < 0 ? -(a) : (a))
75 /* from file `ftobjs.h' from FreeType */
76 #define TA_PAD_FLOOR(x, n) ((x) & ~((n) - 1))
77 #define TA_PAD_ROUND(x, n) TA_PAD_FLOOR((x) + ((n) / 2), n)
78 #define TA_PAD_CEIL(x, n) TA_PAD_FLOOR((x) + ((n) - 1), n)
80 #define TA_PIX_FLOOR(x) ((x) & ~63)
81 #define TA_PIX_ROUND(x) TA_PIX_FLOOR((x) + 32)
82 #define TA_PIX_CEIL(x) TA_PIX_FLOOR((x) + 63)
85 typedef struct TA_WidthRec_
87 FT_Pos org
; /* original position/width in font units */
88 FT_Pos cur
; /* current/scaled position/width in device sub-pixels */
89 FT_Pos fit
; /* current/fitted position/width in device sub-pixels */
90 } TA_WidthRec
, *TA_Width
;
93 /* the auto-hinter doesn't need a very high angular accuracy */
94 typedef FT_Int TA_Angle
;
96 #define TA_ANGLE_PI 256
97 #define TA_ANGLE_2PI (TA_ANGLE_PI * 2)
98 #define TA_ANGLE_PI2 (TA_ANGLE_PI / 2)
99 #define TA_ANGLE_PI4 (TA_ANGLE_PI / 4)
101 #define TA_ANGLE_DIFF(result, angle1, angle2) \
103 TA_Angle _delta = (angle2) - (angle1); \
106 _delta %= TA_ANGLE_2PI; \
108 _delta += TA_ANGLE_2PI; \
110 if (_delta > TA_ANGLE_PI) \
111 _delta -= TA_ANGLE_2PI; \
117 /* opaque handle to glyph-specific hints -- */
118 /* see `tahints.h' for more details */
119 typedef struct TA_GlyphHintsRec_
* TA_GlyphHints
;
122 /* a scaler models the target pixel device that will receive */
123 /* the auto-hinted glyph image */
124 #define TA_SCALER_FLAG_NO_HORIZONTAL 0x01 /* disable horizontal hinting */
125 #define TA_SCALER_FLAG_NO_VERTICAL 0x02 /* disable vertical hinting */
126 #define TA_SCALER_FLAG_NO_ADVANCE 0x04 /* disable advance hinting */
128 typedef struct TA_ScalerRec_
130 FT_Face face
; /* source font face */
131 FT_Fixed x_scale
; /* from font units to 1/64th device pixels */
132 FT_Fixed y_scale
; /* from font units to 1/64th device pixels */
133 FT_Pos x_delta
; /* in 1/64th device pixels */
134 FT_Pos y_delta
; /* in 1/64th device pixels */
135 FT_Render_Mode render_mode
; /* monochrome, anti-aliased, LCD, etc.*/
136 FT_UInt32 flags
; /* additional control flags, see above */
137 } TA_ScalerRec
, *TA_Scaler
;
139 #define TA_SCALER_EQUAL_SCALES(a, b) \
140 ((a)->x_scale == (b)->x_scale \
141 && (a)->y_scale == (b)->y_scale \
142 && (a)->x_delta == (b)->x_delta \
143 && (a)->y_delta == (b)->y_delta)
147 * The list of known scripts. Each different script corresponds to the
148 * following information:
150 * - A set of Unicode ranges to test whether the face supports the
153 * - A specific global analyzer that will compute global metrics
154 * specific to the script.
156 * - A specific glyph analyzer that will compute segments and
157 * edges for each glyph covered by the script.
159 * - A specific grid-fitting algorithm that will distort the
160 * scaled glyph outline according to the results of the glyph
163 * Note that a given analyzer and/or grid-fitting algorithm can be
164 * used by more than one script.
167 typedef enum TA_Script_
173 #ifdef FT_OPTION_AUTOFIT2
174 TA_SCRIPT_LATIN2
= 4,
177 /* add new scripts here; */
178 /* don't forget to update the list in `taglobal.c' */
180 TA_SCRIPT_MAX
/* do not remove */
183 typedef struct TA_ScriptClassRec_
const* TA_ScriptClass
;
184 typedef struct TA_FaceGlobalsRec_
* TA_FaceGlobals
;
186 typedef struct TA_ScriptMetricsRec_
188 TA_ScriptClass clazz
;
190 FT_Bool digits_have_same_width
;
192 TA_FaceGlobals globals
; /* to access properties */
193 } TA_ScriptMetricsRec
, *TA_ScriptMetrics
;
196 /* this function parses an FT_Face to compute global metrics */
197 /* for a specific script */
199 (*TA_Script_InitMetricsFunc
)(TA_ScriptMetrics metrics
,
202 (*TA_Script_ScaleMetricsFunc
)(TA_ScriptMetrics metrics
,
205 (*TA_Script_DoneMetricsFunc
)(TA_ScriptMetrics metrics
);
207 (*TA_Script_InitHintsFunc
)(TA_GlyphHints hints
,
208 TA_ScriptMetrics metrics
);
210 (*TA_Script_ApplyHintsFunc
)(TA_GlyphHints hints
,
212 TA_ScriptMetrics metrics
);
215 typedef struct TA_Script_UniRangeRec_
219 } TA_Script_UniRangeRec
;
221 #define TA_UNIRANGE_REC(a, b) \
222 { (FT_UInt32)(a), (FT_UInt32)(b) }
224 typedef const TA_Script_UniRangeRec
* TA_Script_UniRange
;
226 typedef struct TA_ScriptClassRec_
229 TA_Script_UniRange script_uni_ranges
; /* last must be { 0, 0 } */
231 FT_Offset script_metrics_size
;
232 TA_Script_InitMetricsFunc script_metrics_init
;
233 TA_Script_ScaleMetricsFunc script_metrics_scale
;
234 TA_Script_DoneMetricsFunc script_metrics_done
;
236 TA_Script_InitHintsFunc script_hints_init
;
237 TA_Script_ApplyHintsFunc script_hints_apply
;
240 #endif /* __TATYPES_H__ */
242 /* end of tatypes.h */