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
57 _ta_message(const char* format
,
61 extern int _ta_debug_disable_horz_hints
;
62 extern int _ta_debug_disable_vert_hints
;
63 extern int _ta_debug_disable_blue_hints
;
64 extern void* _ta_debug_hints
;
69 do { } while (0) /* nothing */
71 #endif /* !TA_DEBUG */
74 #define TA_ABS(a) ((a) < 0 ? -(a) : (a))
76 /* from file `ftobjs.h' from FreeType */
77 #define TA_PAD_FLOOR(x, n) ((x) & ~((n) - 1))
78 #define TA_PAD_ROUND(x, n) TA_PAD_FLOOR((x) + ((n) / 2), n)
79 #define TA_PAD_CEIL(x, n) TA_PAD_FLOOR((x) + ((n) - 1), n)
81 #define TA_PIX_FLOOR(x) ((x) & ~63)
82 #define TA_PIX_ROUND(x) TA_PIX_FLOOR((x) + 32)
83 #define TA_PIX_CEIL(x) TA_PIX_FLOOR((x) + 63)
86 typedef struct TA_WidthRec_
88 FT_Pos org
; /* original position/width in font units */
89 FT_Pos cur
; /* current/scaled position/width in device sub-pixels */
90 FT_Pos fit
; /* current/fitted position/width in device sub-pixels */
91 } TA_WidthRec
, *TA_Width
;
94 /* the auto-hinter doesn't need a very high angular accuracy */
95 typedef FT_Int TA_Angle
;
97 #define TA_ANGLE_PI 256
98 #define TA_ANGLE_2PI (TA_ANGLE_PI * 2)
99 #define TA_ANGLE_PI2 (TA_ANGLE_PI / 2)
100 #define TA_ANGLE_PI4 (TA_ANGLE_PI / 4)
102 #define TA_ANGLE_DIFF(result, angle1, angle2) \
105 TA_Angle _delta = (angle2) - (angle1); \
108 _delta %= TA_ANGLE_2PI; \
110 _delta += TA_ANGLE_2PI; \
112 if (_delta > TA_ANGLE_PI) \
113 _delta -= TA_ANGLE_2PI; \
119 /* opaque handle to glyph-specific hints -- */
120 /* see `tahints.h' for more details */
121 typedef struct TA_GlyphHintsRec_
* TA_GlyphHints
;
124 /* a scaler models the target pixel device that will receive */
125 /* the auto-hinted glyph image */
126 #define TA_SCALER_FLAG_NO_HORIZONTAL 0x01 /* disable horizontal hinting */
127 #define TA_SCALER_FLAG_NO_VERTICAL 0x02 /* disable vertical hinting */
128 #define TA_SCALER_FLAG_NO_ADVANCE 0x04 /* disable advance hinting */
130 typedef struct TA_ScalerRec_
132 FT_Face face
; /* source font face */
133 FT_Fixed x_scale
; /* from font units to 1/64th device pixels */
134 FT_Fixed y_scale
; /* from font units to 1/64th device pixels */
135 FT_Pos x_delta
; /* in 1/64th device pixels */
136 FT_Pos y_delta
; /* in 1/64th device pixels */
137 FT_Render_Mode render_mode
; /* monochrome, anti-aliased, LCD, etc.*/
138 FT_UInt32 flags
; /* additional control flags, see above */
139 } TA_ScalerRec
, *TA_Scaler
;
141 #define TA_SCALER_EQUAL_SCALES(a, b) \
142 ((a)->x_scale == (b)->x_scale \
143 && (a)->y_scale == (b)->y_scale \
144 && (a)->x_delta == (b)->x_delta \
145 && (a)->y_delta == (b)->y_delta)
149 * The list of known scripts. Each different script corresponds to the
150 * following information:
152 * - A set of Unicode ranges to test whether the face supports the
155 * - A specific global analyzer that will compute global metrics
156 * specific to the script.
158 * - A specific glyph analyzer that will compute segments and
159 * edges for each glyph covered by the script.
161 * - A specific grid-fitting algorithm that will distort the
162 * scaled glyph outline according to the results of the glyph
165 * Note that a given analyzer and/or grid-fitting algorithm can be
166 * used by more than one script.
169 typedef enum TA_Script_
175 #ifdef FT_OPTION_AUTOFIT2
176 TA_SCRIPT_LATIN2
= 4,
179 /* add new scripts here; */
180 /* don't forget to update the list in `taglobal.c' */
182 TA_SCRIPT_MAX
/* do not remove */
185 typedef struct TA_ScriptClassRec_
const* TA_ScriptClass
;
186 typedef struct TA_FaceGlobalsRec_
* TA_FaceGlobals
;
188 typedef struct TA_ScriptMetricsRec_
190 TA_ScriptClass clazz
;
192 FT_Bool digits_have_same_width
;
194 TA_FaceGlobals globals
; /* to access properties */
195 } TA_ScriptMetricsRec
, *TA_ScriptMetrics
;
198 /* this function parses an FT_Face to compute global metrics */
199 /* for a specific script */
201 (*TA_Script_InitMetricsFunc
)(TA_ScriptMetrics metrics
,
204 (*TA_Script_ScaleMetricsFunc
)(TA_ScriptMetrics metrics
,
207 (*TA_Script_DoneMetricsFunc
)(TA_ScriptMetrics metrics
);
209 (*TA_Script_InitHintsFunc
)(TA_GlyphHints hints
,
210 TA_ScriptMetrics metrics
);
212 (*TA_Script_ApplyHintsFunc
)(TA_GlyphHints hints
,
214 TA_ScriptMetrics metrics
);
217 typedef struct TA_Script_UniRangeRec_
221 } TA_Script_UniRangeRec
;
223 #define TA_UNIRANGE_REC(a, b) \
224 { (FT_UInt32)(a), (FT_UInt32)(b) }
226 typedef const TA_Script_UniRangeRec
* TA_Script_UniRange
;
228 typedef struct TA_ScriptClassRec_
231 TA_Script_UniRange script_uni_ranges
; /* last must be { 0, 0 } */
232 FT_UInt32 standard_char
; /* for default width and height */
234 FT_Offset script_metrics_size
;
235 TA_Script_InitMetricsFunc script_metrics_init
;
236 TA_Script_ScaleMetricsFunc script_metrics_scale
;
237 TA_Script_DoneMetricsFunc script_metrics_done
;
239 TA_Script_InitHintsFunc script_hints_init
;
240 TA_Script_ApplyHintsFunc script_hints_apply
;
243 #endif /* __TATYPES_H__ */
245 /* end of tatypes.h */