28#ifdef AF_CONFIG_OPTION_USE_WARPER
37#define FT_COMPONENT trace_afwarp
45 af_warper_weights[64] =
47 35, 32, 30, 25, 20, 15, 12, 10, 5, 1, 0, 0, 0, 0, 0, 0,
48 0, 0, 0, 0, 0, 0, -1, -2, -5, -8,-10,-10,-20,-20,-30,-30,
50 -30,-30,-20,-20,-10,-10, -8, -5, -2, -1, 0, 0, 0, 0, 0, 0,
51 0, 0, 0, 0, 0, 0, 0, 1, 5, 10, 12, 15, 20, 25, 30, 32,
55 af_warper_weights[64] =
57 30, 20, 10, 5, 4, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0,
58 0, 0, 0, 0, 0, 0, 0, -1, -2, -2, -5, -5,-10,-10,-15,-20,
60 -20,-15,-15,-10,-10, -5, -5, -2, -2, -1, 0, 0, 0, 0, 0, 0,
61 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 4, 5, 10, 20,
72 af_warper_compute_line_best(
AF_Warper warper,
81 FT_Int idx_min, idx_max, idx0;
86 for ( nn = 0; nn < 65; nn++ )
89 idx0 = xx1 - warper->
t1;
98 if ( xx1min + w < warper->x2min )
99 xx1min = warper->
x2min -
w;
101 if ( xx1max +
w > warper->
x2max )
102 xx1max = warper->
x2max -
w;
104 idx_min = xx1min - warper->
t1;
105 idx_max = xx1max - warper->
t1;
107 if ( idx_min < 0 || idx_min > idx_max || idx_max > 64 )
110 " min=%d max=%d, xx1=%ld xx2=%ld,\n"
111 " x1min=%ld x1max=%ld, x2min=%ld x2max=%ld\n",
112 idx_min, idx_max, xx1, xx2,
119 for ( nn = 0; nn < num_segments; nn++ )
128 for (
idx = idx_min;
idx <= idx_max;
idx++,
y++ )
129 scores[
idx] += af_warper_weights[
y & 63] *
len;
137 for (
idx = idx_min;
idx <= idx_max;
idx++ )
145 distort < warper->best_distort ) )
173 FT_Int nn, num_points, num_segments;
184 org_scale =
hints->y_scale;
185 org_delta =
hints->y_delta;
189 org_scale =
hints->x_scale;
190 org_delta =
hints->x_delta;
198 axis = &
hints->axis[dim];
202 num_points =
hints->num_points;
204 *a_scale = org_scale;
205 *a_delta = org_delta;
208 if ( num_segments < 1 )
213 for ( nn = 1; nn < num_points; nn++ )
224 X1 =
X2 = segments[0].
pos;
225 for ( nn = 1; nn < num_segments; nn++ )
240 warper->
x1 =
FT_MulFix( X1, org_scale ) + org_delta;
247 warper->
x1min = warper->
x1 & ~31;
249 warper->
x2min = warper->
x2 & ~31;
252 if ( warper->
x1max > warper->
x2 )
255 if ( warper->
x2min < warper->
x1 )
258 warper->
w0 = warper->
x2 - warper->
x1;
260 if ( warper->
w0 <= 64 )
276 if ( warper->
w0 <= 128 )
279 if ( warper->
w0 <= 96 )
283 if ( warper->
wmin < warper->
w0 - margin )
284 warper->
wmin = warper->
w0 - margin;
286 if ( warper->
wmax > warper->
w0 + margin )
287 warper->
wmax = warper->
w0 + margin;
290 if ( warper->
wmin < warper->
w0 * 3 / 4 )
291 warper->
wmin = warper->
w0 * 3 / 4;
293 if ( warper->
wmax > warper->
w0 * 5 / 4 )
294 warper->
wmax = warper->
w0 * 5 / 4;
300 for (
w = warper->
wmin; w <= warper->wmax;
w++ )
311 if (
w >= warper->
w0 )
313 xx1 -=
w - warper->
w0;
314 if ( xx1 < warper->x1min )
316 xx2 += warper->
x1min - xx1;
322 xx1 -=
w - warper->
w0;
323 if ( xx1 > warper->
x1max )
325 xx2 -= xx1 - warper->
x1max;
330 if ( xx1 < warper->
x1 )
331 base_distort = warper->
x1 - xx1;
333 base_distort = xx1 - warper->
x1;
335 if ( xx2 < warper->
x2 )
336 base_distort += warper->
x2 - xx2;
338 base_distort += xx2 - warper->
x2;
344 new_delta = xx1 -
FT_MulFix( X1, new_scale );
346 af_warper_compute_line_best( warper, new_scale, new_delta, xx1, xx2,
348 segments, num_segments );
361 *a_scale = best_scale;
362 *a_delta = best_delta;
FT_BEGIN_HEADER enum AF_Dimension_ AF_Dimension
#define AF_WARPER_CEIL(x)
af_warper_compute(AF_Warper warper, AF_GlyphHints hints, AF_Dimension dim, FT_Fixed *a_scale, FT_Fixed *a_delta)
#define AF_WARPER_FLOOR(x)
FT_DivFix(FT_Long a, FT_Long b)
FT_MulFix(FT_Long a, FT_Long b)
#define FT_TRACE5(varformat)
FT_BEGIN_HEADER typedef signed long FT_Pos
GLint GLint GLint GLint GLint GLint y
GLenum GLenum GLenum GLenum GLenum scale
GLubyte GLubyte GLubyte GLubyte w
GLsizei const GLfloat * points
namespace GUID const ADDRINFOEXW * hints
AF_WarpScore best_distort
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1