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 /* 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 /* #define TA_DEBUG */
42 extern int _ta_debug_disable_horz_hints
;
43 extern int _ta_debug_disable_vert_hints
;
44 extern int _ta_debug_disable_blue_hints
;
45 extern void* _ta_debug_hints
;
50 do { } while (0) /* nothing */
52 #endif /* !TA_DEBUG */
55 #define TA_ABS(a) ((a) < 0 ? -(a) : (a))
57 /* from file `ftobjs.h' from FreeType */
58 #define TA_PAD_FLOOR(x, n) ((x) & ~((n) - 1))
59 #define TA_PAD_ROUND(x, n) TA_PAD_FLOOR((x) + ((n) / 2), n)
60 #define TA_PAD_CEIL(x, n) TA_PAD_FLOOR((x) + ((n) - 1), n)
62 #define TA_PIX_FLOOR(x) ((x) & ~63)
63 #define TA_PIX_ROUND(x) TA_PIX_FLOOR((x) + 32)
64 #define TA_PIX_CEIL(x) TA_PIX_FLOOR((x) + 63)
67 typedef struct TA_WidthRec_
69 FT_Pos org
; /* original position/width in font units */
70 FT_Pos cur
; /* current/scaled position/width in device sub-pixels */
71 FT_Pos fit
; /* current/fitted position/width in device sub-pixels */
72 } TA_WidthRec
, *TA_Width
;
75 /* the auto-hinter doesn't need a very high angular accuracy */
76 typedef FT_Int TA_Angle
;
78 #define TA_ANGLE_PI 256
79 #define TA_ANGLE_2PI (TA_ANGLE_PI * 2)
80 #define TA_ANGLE_PI2 (TA_ANGLE_PI / 2)
81 #define TA_ANGLE_PI4 (TA_ANGLE_PI / 4)
83 #define TA_ANGLE_DIFF(result, angle1, angle2) \
85 TA_Angle _delta = (angle2) - (angle1); \
88 _delta %= TA_ANGLE_2PI; \
90 _delta += TA_ANGLE_2PI; \
92 if (_delta > TA_ANGLE_PI) \
93 _delta -= TA_ANGLE_2PI; \
99 /* opaque handle to glyph-specific hints -- */
100 /* see `tahints.h' for more details */
101 typedef struct TA_GlyphHintsRec_
* TA_GlyphHints
;
104 /* a scaler models the target pixel device that will receive */
105 /* the auto-hinted glyph image */
106 #define TA_SCALER_FLAG_NO_HORIZONTAL 1 /* disable horizontal hinting */
107 #define TA_SCALER_FLAG_NO_VERTICAL 2 /* disable vertical hinting */
108 #define TA_SCALER_FLAG_NO_ADVANCE 4 /* disable advance hinting */
110 typedef struct TA_ScalerRec_
112 FT_Face face
; /* source font face */
113 FT_Fixed x_scale
; /* from font units to 1/64th device pixels */
114 FT_Fixed y_scale
; /* from font units to 1/64th device pixels */
115 FT_Pos x_delta
; /* in 1/64th device pixels */
116 FT_Pos y_delta
; /* in 1/64th device pixels */
117 FT_Render_Mode render_mode
; /* monochrome, anti-aliased, LCD, etc.*/
118 FT_UInt32 flags
; /* additional control flags, see above */
119 } TA_ScalerRec
, *TA_Scaler
;
121 #define TA_SCALER_EQUAL_SCALES(a, b) \
122 ((a)->x_scale == (b)->x_scale \
123 && (a)->y_scale == (b)->y_scale \
124 && (a)->x_delta == (b)->x_delta \
125 && (a)->y_delta == (b)->y_delta)
129 * The list of known scripts. Each different script corresponds to the
130 * following information:
132 * - A set of Unicode ranges to test whether the face supports the
135 * - A specific global analyzer that will compute global metrics
136 * specific to the script.
138 * - A specific glyph analyzer that will compute segments and
139 * edges for each glyph covered by the script.
141 * - A specific grid-fitting algorithm that will distort the
142 * scaled glyph outline according to the results of the glyph
145 * Note that a given analyzer and/or grid-fitting algorithm can be
146 * used by more than one script.
149 typedef enum TA_Script_
155 #ifdef FT_OPTION_AUTOFIT2
156 TA_SCRIPT_LATIN2
= 4,
159 /* add new scripts here; */
160 /* don't forget to update the list in `taglobal.c' */
162 TA_SCRIPT_MAX
/* do not remove */
165 typedef struct TA_ScriptClassRec_
const* TA_ScriptClass
;
167 typedef struct TA_ScriptMetricsRec_
169 TA_ScriptClass clazz
;
171 FT_Bool digits_have_same_width
;
172 } TA_ScriptMetricsRec
, *TA_ScriptMetrics
;
175 /* this function parses an FT_Face to compute global metrics */
176 /* for a specific script */
178 (*TA_Script_InitMetricsFunc
)(TA_ScriptMetrics metrics
,
181 (*TA_Script_ScaleMetricsFunc
)(TA_ScriptMetrics metrics
,
184 (*TA_Script_DoneMetricsFunc
)(TA_ScriptMetrics metrics
);
186 (*TA_Script_InitHintsFunc
)(TA_GlyphHints hints
,
187 TA_ScriptMetrics metrics
);
189 (*TA_Script_ApplyHintsFunc
)(TA_GlyphHints hints
,
191 TA_ScriptMetrics metrics
);
194 typedef struct TA_Script_UniRangeRec_
198 } TA_Script_UniRangeRec
;
200 #define TA_UNIRANGE_REC(a, b) \
201 { (FT_UInt32)(a), (FT_UInt32)(b) }
203 typedef const TA_Script_UniRangeRec
*TA_Script_UniRange
;
205 typedef struct TA_ScriptClassRec_
208 TA_Script_UniRange script_uni_ranges
; /* last must be { 0, 0 } */
210 FT_Offset script_metrics_size
;
211 TA_Script_InitMetricsFunc script_metrics_init
;
212 TA_Script_ScaleMetricsFunc script_metrics_scale
;
213 TA_Script_DoneMetricsFunc script_metrics_done
;
215 TA_Script_InitHintsFunc script_hints_init
;
216 TA_Script_ApplyHintsFunc script_hints_apply
;
219 #endif /* __TATYPES_H__ */
221 /* end of tatypes.h */