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 /* #define TA_DEBUG */
40 _ta_message(const char *format
,
44 extern int _ta_debug_disable_horz_hints
;
45 extern int _ta_debug_disable_vert_hints
;
46 extern int _ta_debug_disable_blue_hints
;
47 extern void* _ta_debug_hints
;
52 do { } while (0) /* nothing */
54 #endif /* !TA_DEBUG */
57 #define TA_ABS(a) ((a) < 0 ? -(a) : (a))
59 /* from file `ftobjs.h' from FreeType */
60 #define TA_PAD_FLOOR(x, n) ((x) & ~((n) - 1))
61 #define TA_PAD_ROUND(x, n) TA_PAD_FLOOR((x) + ((n) / 2), n)
62 #define TA_PAD_CEIL(x, n) TA_PAD_FLOOR((x) + ((n) - 1), n)
64 #define TA_PIX_FLOOR(x) ((x) & ~63)
65 #define TA_PIX_ROUND(x) TA_PIX_FLOOR((x) + 32)
66 #define TA_PIX_CEIL(x) TA_PIX_FLOOR((x) + 63)
69 typedef struct TA_WidthRec_
71 FT_Pos org
; /* original position/width in font units */
72 FT_Pos cur
; /* current/scaled position/width in device sub-pixels */
73 FT_Pos fit
; /* current/fitted position/width in device sub-pixels */
74 } TA_WidthRec
, *TA_Width
;
77 /* the auto-hinter doesn't need a very high angular accuracy */
78 typedef FT_Int TA_Angle
;
80 #define TA_ANGLE_PI 256
81 #define TA_ANGLE_2PI (TA_ANGLE_PI * 2)
82 #define TA_ANGLE_PI2 (TA_ANGLE_PI / 2)
83 #define TA_ANGLE_PI4 (TA_ANGLE_PI / 4)
85 #define TA_ANGLE_DIFF(result, angle1, angle2) \
87 TA_Angle _delta = (angle2) - (angle1); \
90 _delta %= TA_ANGLE_2PI; \
92 _delta += TA_ANGLE_2PI; \
94 if (_delta > TA_ANGLE_PI) \
95 _delta -= TA_ANGLE_2PI; \
101 /* opaque handle to glyph-specific hints -- */
102 /* see `tahints.h' for more details */
103 typedef struct TA_GlyphHintsRec_
* TA_GlyphHints
;
106 /* a scaler models the target pixel device that will receive */
107 /* the auto-hinted glyph image */
108 #define TA_SCALER_FLAG_NO_HORIZONTAL 0x01 /* disable horizontal hinting */
109 #define TA_SCALER_FLAG_NO_VERTICAL 0x02 /* disable vertical hinting */
110 #define TA_SCALER_FLAG_NO_ADVANCE 0x04 /* disable advance hinting */
112 /* for ttfautohint, we add more scaler flags; */
113 /* note that FreeType uses a different mechanism */
114 /* to pass control arguments to the auto-hinter */
115 /* (this isn't implemented yet in version 2.4.8) */
116 #define TA_SCALER_FLAG_INCREASE_X_HEIGHT 0x08
118 typedef struct TA_ScalerRec_
120 FT_Face face
; /* source font face */
121 FT_Fixed x_scale
; /* from font units to 1/64th device pixels */
122 FT_Fixed y_scale
; /* from font units to 1/64th device pixels */
123 FT_Pos x_delta
; /* in 1/64th device pixels */
124 FT_Pos y_delta
; /* in 1/64th device pixels */
125 FT_Render_Mode render_mode
; /* monochrome, anti-aliased, LCD, etc.*/
126 FT_UInt32 flags
; /* additional control flags, see above */
127 } TA_ScalerRec
, *TA_Scaler
;
129 #define TA_SCALER_EQUAL_SCALES(a, b) \
130 ((a)->x_scale == (b)->x_scale \
131 && (a)->y_scale == (b)->y_scale \
132 && (a)->x_delta == (b)->x_delta \
133 && (a)->y_delta == (b)->y_delta)
137 * The list of known scripts. Each different script corresponds to the
138 * following information:
140 * - A set of Unicode ranges to test whether the face supports the
143 * - A specific global analyzer that will compute global metrics
144 * specific to the script.
146 * - A specific glyph analyzer that will compute segments and
147 * edges for each glyph covered by the script.
149 * - A specific grid-fitting algorithm that will distort the
150 * scaled glyph outline according to the results of the glyph
153 * Note that a given analyzer and/or grid-fitting algorithm can be
154 * used by more than one script.
157 typedef enum TA_Script_
163 #ifdef FT_OPTION_AUTOFIT2
164 TA_SCRIPT_LATIN2
= 4,
167 /* add new scripts here; */
168 /* don't forget to update the list in `taglobal.c' */
170 TA_SCRIPT_MAX
/* do not remove */
173 typedef struct TA_ScriptClassRec_
const* TA_ScriptClass
;
175 typedef struct TA_ScriptMetricsRec_
177 TA_ScriptClass clazz
;
179 FT_Bool digits_have_same_width
;
180 } TA_ScriptMetricsRec
, *TA_ScriptMetrics
;
183 /* this function parses an FT_Face to compute global metrics */
184 /* for a specific script */
186 (*TA_Script_InitMetricsFunc
)(TA_ScriptMetrics metrics
,
189 (*TA_Script_ScaleMetricsFunc
)(TA_ScriptMetrics metrics
,
192 (*TA_Script_DoneMetricsFunc
)(TA_ScriptMetrics metrics
);
194 (*TA_Script_InitHintsFunc
)(TA_GlyphHints hints
,
195 TA_ScriptMetrics metrics
);
197 (*TA_Script_ApplyHintsFunc
)(TA_GlyphHints hints
,
199 TA_ScriptMetrics metrics
);
202 typedef struct TA_Script_UniRangeRec_
206 } TA_Script_UniRangeRec
;
208 #define TA_UNIRANGE_REC(a, b) \
209 { (FT_UInt32)(a), (FT_UInt32)(b) }
211 typedef const TA_Script_UniRangeRec
* TA_Script_UniRange
;
213 typedef struct TA_ScriptClassRec_
216 TA_Script_UniRange script_uni_ranges
; /* last must be { 0, 0 } */
218 FT_Offset script_metrics_size
;
219 TA_Script_InitMetricsFunc script_metrics_init
;
220 TA_Script_ScaleMetricsFunc script_metrics_scale
;
221 TA_Script_DoneMetricsFunc script_metrics_done
;
223 TA_Script_InitHintsFunc script_hints_init
;
224 TA_Script_ApplyHintsFunc script_hints_apply
;
227 #endif /* __TATYPES_H__ */
229 /* end of tatypes.h */