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;
99 xx1min = warper->
x2min -
w;
101 xx1max = warper->
x1max;
102 if ( xx1max + w > warper->
x2max )
103 xx1max = warper->
x2max -
w;
105 idx_min = xx1min - warper->
t1;
106 idx_max = xx1max - warper->
t1;
108 if ( idx_min < 0 || idx_min > idx_max || idx_max > 64 )
111 " min=%d max=%d, xx1=%ld xx2=%ld,\n" 112 " x1min=%ld x1max=%ld, x2min=%ld x2max=%ld\n",
113 idx_min, idx_max, xx1, xx2,
120 for ( nn = 0; nn < num_segments; nn++ )
124 FT_Pos y = y0 + ( idx_min - idx0 );
129 for ( idx = idx_min; idx <= idx_max; idx++, y++ )
130 scores[idx] += af_warper_weights[y & 63] * len;
138 for ( idx = idx_min; idx <= idx_max; idx++ )
146 distort < warper->best_distort ) )
174 FT_UInt nn, num_points, num_segments;
199 axis = &hints->
axis[dim];
205 *a_scale = org_scale;
206 *a_delta = org_delta;
209 if ( num_segments < 1 )
213 X1 = X2 = points[0].
fx;
214 for ( nn = 1; nn < num_points; nn++ )
225 X1 = X2 = segments[0].
pos;
226 for ( nn = 1; nn < num_segments; nn++ )
241 warper->
x1 =
FT_MulFix( X1, org_scale ) + org_delta;
242 warper->
x2 =
FT_MulFix( X2, org_scale ) + org_delta;
248 warper->
x1min = warper->
x1 & ~31;
250 warper->
x2min = warper->
x2 & ~31;
253 if ( warper->
x1max > warper->
x2 )
256 if ( warper->
x2min < warper->
x1 )
259 warper->
w0 = warper->
x2 - warper->
x1;
261 if ( warper->
w0 <= 64 )
277 if ( warper->
w0 <= 128 )
280 if ( warper->
w0 <= 96 )
284 if ( warper->
wmin < warper->
w0 - margin )
285 warper->
wmin = warper->
w0 - margin;
287 if ( warper->
wmax > warper->
w0 + margin )
288 warper->
wmax = warper->
w0 + margin;
291 if ( warper->
wmin < warper->
w0 * 3 / 4 )
292 warper->
wmin = warper->
w0 * 3 / 4;
294 if ( warper->
wmax > warper->
w0 * 5 / 4 )
295 warper->
wmax = warper->
w0 * 5 / 4;
312 if ( w >= warper->
w0 )
314 xx1 -= w - warper->
w0;
315 if ( xx1 < warper->x1min )
317 xx2 += warper->
x1min - xx1;
323 xx1 -= w - warper->
w0;
324 if ( xx1 > warper->
x1max )
326 xx2 -= xx1 - warper->
x1max;
331 if ( xx1 < warper->x1 )
332 base_distort = warper->
x1 - xx1;
334 base_distort = xx1 - warper->
x1;
336 if ( xx2 < warper->x2 )
337 base_distort += warper->
x2 - xx2;
339 base_distort += xx2 - warper->
x2;
344 new_scale = org_scale +
FT_DivFix( w - warper->
w0, X2 - X1 );
345 new_delta = xx1 -
FT_MulFix( X1, new_scale );
347 af_warper_compute_line_best( warper, new_scale, new_delta, xx1, xx2,
349 segments, num_segments );
362 *a_scale = best_scale;
363 *a_delta = best_delta;
FT_DivFix(FT_Long a, FT_Long b)
GLenum GLenum GLenum GLenum GLenum scale
FT_BEGIN_HEADER typedef signed long FT_Pos
GLsizei const GLfloat * points
GLint GLint GLint GLint GLint GLint y
png_infop png_charp png_int_32 png_int_32 * X1
AF_WarpScore best_distort
af_warper_compute(AF_Warper warper, AF_GlyphHints hints, AF_Dimension dim, FT_Fixed *a_scale, FT_Fixed *a_delta)
FT_MulFix(FT_Long a, FT_Long b)
FT_BEGIN_HEADER enum AF_Dimension_ AF_Dimension
GLubyte GLubyte GLubyte GLubyte w
#define AF_WARPER_CEIL(x)
#define FT_TRACE5(varformat)
AF_AxisHintsRec axis[AF_DIMENSION_MAX]
#define AF_WARPER_FLOOR(x)