* Sync up to trunk HEAD (r62502).
[reactos.git] / lib / 3rdparty / freetype / src / autofit / aflatin.h
1 /***************************************************************************/
2 /* */
3 /* aflatin.h */
4 /* */
5 /* Auto-fitter hinting routines for latin script (specification). */
6 /* */
7 /* Copyright 2003-2007, 2009, 2011-2013 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
9 /* */
10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
15 /* */
16 /***************************************************************************/
17
18
19 #ifndef __AFLATIN_H__
20 #define __AFLATIN_H__
21
22 #include "afhints.h"
23
24
25 FT_BEGIN_HEADER
26
27 /* the `latin' writing system */
28
29 AF_DECLARE_WRITING_SYSTEM_CLASS( af_latin_writing_system_class )
30
31
32 /* the latin-specific script classes */
33
34 AF_DECLARE_SCRIPT_CLASS( af_cyrl_script_class )
35 AF_DECLARE_SCRIPT_CLASS( af_grek_script_class )
36 AF_DECLARE_SCRIPT_CLASS( af_latn_script_class )
37 AF_DECLARE_SCRIPT_CLASS( af_hebr_script_class )
38 #if 0
39 AF_DECLARE_SCRIPT_CLASS( af_armn_script_class )
40 #endif
41
42
43 /* constants are given with units_per_em == 2048 in mind */
44 #define AF_LATIN_CONSTANT( metrics, c ) \
45 ( ( (c) * (FT_Long)( (AF_LatinMetrics)(metrics) )->units_per_em ) / 2048 )
46
47
48 /*************************************************************************/
49 /*************************************************************************/
50 /***** *****/
51 /***** L A T I N G L O B A L M E T R I C S *****/
52 /***** *****/
53 /*************************************************************************/
54 /*************************************************************************/
55
56
57 /*
58 * The following declarations could be embedded in the file `aflatin.c';
59 * they have been made semi-public to allow alternate script hinters to
60 * re-use some of them.
61 */
62
63
64 #define AF_LATIN_IS_TOP_BLUE( b ) \
65 ( (b)->properties & AF_BLUE_PROPERTY_LATIN_TOP )
66 #define AF_LATIN_IS_X_HEIGHT_BLUE( b ) \
67 ( (b)->properties & AF_BLUE_PROPERTY_LATIN_X_HEIGHT )
68 #define AF_LATIN_IS_LONG_BLUE( b ) \
69 ( (b)->properties & AF_BLUE_PROPERTY_LATIN_LONG )
70
71 #define AF_LATIN_MAX_WIDTHS 16
72
73
74 enum
75 {
76 AF_LATIN_BLUE_ACTIVE = 1 << 0, /* set if zone height is <= 3/4px */
77 AF_LATIN_BLUE_TOP = 1 << 1, /* result of AF_LATIN_IS_TOP_BLUE */
78 AF_LATIN_BLUE_ADJUSTMENT = 1 << 2, /* used for scale adjustment */
79 /* optimization */
80 AF_LATIN_BLUE_FLAG_MAX
81 };
82
83
84 typedef struct AF_LatinBlueRec_
85 {
86 AF_WidthRec ref;
87 AF_WidthRec shoot;
88 FT_UInt flags;
89
90 } AF_LatinBlueRec, *AF_LatinBlue;
91
92
93 typedef struct AF_LatinAxisRec_
94 {
95 FT_Fixed scale;
96 FT_Pos delta;
97
98 FT_UInt width_count; /* number of used widths */
99 AF_WidthRec widths[AF_LATIN_MAX_WIDTHS]; /* widths array */
100 FT_Pos edge_distance_threshold; /* used for creating edges */
101 FT_Pos standard_width; /* the default stem thickness */
102 FT_Bool extra_light; /* is standard width very light? */
103
104 /* ignored for horizontal metrics */
105 FT_UInt blue_count;
106 AF_LatinBlueRec blues[AF_BLUE_STRINGSET_MAX];
107
108 FT_Fixed org_scale;
109 FT_Pos org_delta;
110
111 } AF_LatinAxisRec, *AF_LatinAxis;
112
113
114 typedef struct AF_LatinMetricsRec_
115 {
116 AF_ScriptMetricsRec root;
117 FT_UInt units_per_em;
118 AF_LatinAxisRec axis[AF_DIMENSION_MAX];
119
120 } AF_LatinMetricsRec, *AF_LatinMetrics;
121
122
123 FT_LOCAL( FT_Error )
124 af_latin_metrics_init( AF_LatinMetrics metrics,
125 FT_Face face );
126
127 FT_LOCAL( void )
128 af_latin_metrics_scale( AF_LatinMetrics metrics,
129 AF_Scaler scaler );
130
131 FT_LOCAL( void )
132 af_latin_metrics_init_widths( AF_LatinMetrics metrics,
133 FT_Face face );
134
135 FT_LOCAL( void )
136 af_latin_metrics_check_digits( AF_LatinMetrics metrics,
137 FT_Face face );
138
139
140 /*************************************************************************/
141 /*************************************************************************/
142 /***** *****/
143 /***** L A T I N G L Y P H A N A L Y S I S *****/
144 /***** *****/
145 /*************************************************************************/
146 /*************************************************************************/
147
148 enum
149 {
150 AF_LATIN_HINTS_HORZ_SNAP = 1 << 0, /* enable stem width snapping */
151 AF_LATIN_HINTS_VERT_SNAP = 1 << 1, /* enable stem height snapping */
152 AF_LATIN_HINTS_STEM_ADJUST = 1 << 2, /* enable stem width/height */
153 /* adjustment */
154 AF_LATIN_HINTS_MONO = 1 << 3 /* indicate monochrome */
155 /* rendering */
156 };
157
158
159 #define AF_LATIN_HINTS_DO_HORZ_SNAP( h ) \
160 AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_HORZ_SNAP )
161
162 #define AF_LATIN_HINTS_DO_VERT_SNAP( h ) \
163 AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_VERT_SNAP )
164
165 #define AF_LATIN_HINTS_DO_STEM_ADJUST( h ) \
166 AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_STEM_ADJUST )
167
168 #define AF_LATIN_HINTS_DO_MONO( h ) \
169 AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_MONO )
170
171
172 /*
173 * The next functions shouldn't normally be exported. However, other
174 * scripts might like to use these functions as-is.
175 */
176 FT_LOCAL( FT_Error )
177 af_latin_hints_compute_segments( AF_GlyphHints hints,
178 AF_Dimension dim );
179
180 FT_LOCAL( void )
181 af_latin_hints_link_segments( AF_GlyphHints hints,
182 AF_Dimension dim );
183
184 FT_LOCAL( FT_Error )
185 af_latin_hints_compute_edges( AF_GlyphHints hints,
186 AF_Dimension dim );
187
188 FT_LOCAL( FT_Error )
189 af_latin_hints_detect_features( AF_GlyphHints hints,
190 AF_Dimension dim );
191
192 /* */
193
194 FT_END_HEADER
195
196 #endif /* __AFLATIN_H__ */
197
198
199 /* END */