21 #include FT_INTERNAL_CALC_H 22 #include FT_INTERNAL_DEBUG_H 32 #define FT_COMPONENT trace_afhints 46 if ( axis->num_segments >= axis->max_segments )
48 FT_Int old_max = axis->max_segments;
53 if ( old_max >= big_max )
59 new_max += ( new_max >> 2 ) + 4;
60 if ( new_max < old_max || new_max > big_max )
66 axis->max_segments = new_max;
69 segment = axis->segments + axis->num_segments++;
91 if ( axis->num_edges >= axis->max_edges )
93 FT_Int old_max = axis->max_edges;
98 if ( old_max >= big_max )
104 new_max += ( new_max >> 2 ) + 4;
105 if ( new_max < old_max || new_max > big_max )
111 axis->max_edges = new_max;
115 edge = edges + axis->num_edges;
117 while ( edge > edges )
119 if ( edge[-1].fpos < fpos )
124 if ( edge[-1].fpos == fpos && dir == axis->major_dir )
143 #ifdef FT_DEBUG_AUTOFIT 145 #include FT_CONFIG_STANDARD_LIBRARY_H 175 #define AF_INDEX_NUM( ptr, base ) ( (ptr) ? ( (ptr) - (base) ) : -1 ) 190 " [ index | xorg | yorg | xscale | yscale" 191 " | xfit | yfit | flags ]\n" ));
193 for ( point = points; point <
limit; point++ )
194 FT_TRACE7((
" [ %5d | %5d | %5d | %6.2f | %6.2f" 195 " | %5.2f | %5.2f | %c%c%c%c%c%c ]\n",
219 static char temp[32];
255 for ( dimension = 1; dimension >= 0; dimension-- )
269 FT_TRACE7((
" [ index | pos | dir | from" 270 " | to | link | serif | edge" 271 " | height | extra | flags ]\n" ));
275 for ( seg = segments; seg <
limit; seg++ )
277 " | %4d | %4d | %5d | %4d" 278 " | %6d | %5d | %11s ]\n",
284 AF_INDEX_NUM( seg->
first, points ),
285 AF_INDEX_NUM( seg->
last, points ),
286 AF_INDEX_NUM( seg->
link, segments ),
287 AF_INDEX_NUM( seg->
serif, segments ),
288 AF_INDEX_NUM( seg->
edge, edges ),
316 axis = &hints->
axis[dim];
343 return FT_THROW( Invalid_Argument );
347 axis = &hints->
axis[dim];
350 return FT_THROW( Invalid_Argument );
374 for ( dimension = 1; dimension >= 0; dimension-- )
390 FT_TRACE7((
" [ index | pos | dir | link" 391 " | serif | blue | opos | pos | flags ]\n" ));
395 for ( edge = edges; edge <
limit; edge++ )
397 " | %5d | %c | %5.2f | %5.2f | %11s ]\n",
399 (
int)edge->
opos / 64.0,
401 AF_INDEX_NUM( edge->
link, edges ),
402 AF_INDEX_NUM( edge->
serif, edges ),
534 hints->memory = memory;
545 if ( !( hints && hints->memory ) )
567 hints->max_contours = 0;
568 hints->num_contours = 0;
571 hints->num_points = 0;
572 hints->max_points = 0;
574 hints->memory =
NULL;
585 hints->scaler_flags =
metrics->scaler.flags;
601 FT_Pos x_delta = hints->x_delta;
602 FT_Pos y_delta = hints->y_delta;
606 hints->num_points = 0;
607 hints->num_contours = 0;
609 hints->axis[0].num_segments = 0;
610 hints->axis[0].num_edges = 0;
611 hints->axis[1].num_segments = 0;
612 hints->axis[1].num_edges = 0;
615 new_max = (
FT_UInt)outline->n_contours;
616 old_max = hints->max_contours;
617 if ( new_max > old_max )
619 new_max = ( new_max + 3 ) & ~3;
624 hints->max_contours = new_max;
632 new_max = (
FT_UInt)( outline->n_points + 2 );
633 old_max = hints->max_points;
634 if ( new_max > old_max )
636 new_max = ( new_max + 2 + 7 ) & ~7;
641 hints->max_points = new_max;
644 hints->num_points = outline->n_points;
645 hints->num_contours = outline->n_contours;
660 hints->x_scale = x_scale;
661 hints->y_scale = y_scale;
662 hints->x_delta = x_delta;
663 hints->y_delta = y_delta;
665 hints->xmin_delta = 0;
666 hints->xmax_delta = 0;
668 points = hints->points;
669 if ( hints->num_points == 0 )
674 AF_Point point_limit = points + hints->num_points;
680 char* tag = outline->tags;
686 for ( point = points; point < point_limit; point++, vec++, tag++ )
690 point->
ox = point->
x =
FT_MulFix( vec->x, x_scale ) + x_delta;
691 point->
oy = point->
y =
FT_MulFix( vec->y, y_scale ) + y_delta;
711 if ( ++contour_index < outline->n_contours )
713 end = points + outline->contours[contour_index];
722 AF_Point* contour = hints->contours;
723 AF_Point* contour_limit = contour + hints->num_contours;
724 short*
end = outline->contours;
728 for ( ; contour < contour_limit; contour++, end++ )
730 contour[0] = points +
idx;
731 idx = (short)( end[0] + 1 );
744 for ( point = points; point < point_limit; point++ )
750 if ( point == first )
753 in_x = first->
fx - prev->
fx;
754 in_y = first->
fy - prev->
fy;
762 out_x = next->
fx - point->
fx;
763 out_y = next->
fy - point->
fy;
807 char* tag = outline->tags;
810 for ( ; point <
limit; point++, vec++, tag++ )
847 for ( seg = segments; seg < segment_limit; seg++ )
861 point->
x = edge->
pos;
873 for ( seg = segments; seg < segment_limit; seg++ )
887 point->
y = edge->
pos;
915 AF_Point point_limit = points + hints->num_points;
927 if ( edges < edge_limit )
933 for ( point = points; point < point_limit; point++ )
939 if ( point->
flags & touch_flag )
964 delta = edge->
fpos - u;
967 u = edge->
pos - ( edge->
opos - ou );
972 edge = edge_limit - 1;
973 delta = u - edge->
fpos;
976 u = edge->
pos + ( ou - edge->
opos );
987 max = edge_limit - edges;
996 for ( nn = 0; nn <
max; nn++ )
997 if ( edges[nn].fpos >= u )
1000 if ( edges[nn].fpos == u )
1011 mid = ( max +
min ) >> 1;
1017 else if ( u > fpos )
1029 AF_Edge before = edges + min - 1;
1030 AF_Edge after = edges + min + 0;
1034 if ( before->
scale == 0 )
1050 point->
flags |= touch_flag;
1079 for ( p = p1; p <
ref; p++ )
1080 p->
u = p->
v + delta;
1082 for ( p = ref + 1; p <= p2; p++ )
1083 p->
u = p->
v + delta;
1113 for ( p = p1; p <= p2; p++ )
1129 for ( p = p1; p <= p2; p++ )
1138 u = ref1->
u +
FT_MulDiv( u - v1, ref2->
u - ref1->
u, v2 - v1 );
1145 for ( p = p1; p <= p2; p++ )
1154 u = ref1->
u +
FT_MulDiv( u - v1, ref2->
u - ref1->
u, v2 - v1 );
1170 AF_Point point_limit = points + hints->num_points;
1171 AF_Point* contour = hints->contours;
1172 AF_Point* contour_limit = contour + hints->num_contours;
1185 for ( point = points; point < point_limit; point++ )
1187 point->
u = point->
x;
1188 point->
v = point->
ox;
1195 for ( point = points; point < point_limit; point++ )
1197 point->
u = point->
y;
1198 point->
v = point->
oy;
1204 for ( ; contour < contour_limit; contour++ )
1206 AF_Point first_touched, last_touched;
1210 end_point = point->
prev;
1211 first_point = point;
1216 if ( point > end_point )
1219 if ( point->
flags & touch_flag )
1225 first_touched = point;
1226 last_touched = point;
1231 ( point->
flags & touch_flag ) != 0 );
1234 while ( point < end_point &&
1235 ( point[1].
flags & touch_flag ) != 0 )
1238 last_touched = point;
1244 if ( point > end_point )
1247 if ( ( point->
flags & touch_flag ) != 0 )
1254 af_iup_interp( last_touched + 1, point - 1,
1255 last_touched, point );
1260 if ( last_touched == first_touched )
1261 af_iup_shift( first_point, end_point, first_touched );
1265 if ( last_touched < end_point )
1266 af_iup_interp( last_touched + 1, end_point,
1267 last_touched, first_touched );
1269 if ( first_touched > points )
1270 af_iup_interp( first_point, first_touched - 1,
1271 last_touched, first_touched );
1281 for ( point = points; point < point_limit; point++ )
1282 point->
x = point->
u;
1286 for ( point = points; point < point_limit; point++ )
1287 point->
y = point->
u;
1292 #ifdef AF_CONFIG_OPTION_USE_WARPER 1309 for ( point = points; point < points_limit; point++ )
1314 for ( point = points; point < points_limit; point++ )
af_glyph_hints_save(AF_GlyphHints hints, FT_Outline *outline)
FT_DivFix(FT_Long a, FT_Long b)
for(n=1;n< outline->n_points;n++)
GLenum GLenum GLenum GLenum GLenum scale
af_glyph_hints_align_edge_points(AF_GlyphHints hints, AF_Dimension dim)
af_glyph_hints_done(AF_GlyphHints hints)
FT_BEGIN_HEADER typedef signed long FT_Pos
GLsizei const GLfloat * points
GLfloat GLfloat GLfloat v2
#define FT_CURVE_TAG_CUBIC
af_glyph_hints_init(AF_GlyphHints hints, FT_Memory memory)
return FT_THROW(Missing_Property)
FT_Outline_Get_Orientation(FT_Outline *outline)
enum AF_Direction_ AF_Direction
af_glyph_hints_reload(AF_GlyphHints hints, FT_Outline *outline)
#define FT_ASSERT(condition)
ft_corner_is_flat(FT_Pos in_x, FT_Pos in_y, FT_Pos out_x, FT_Pos out_y)
af_axis_hints_new_edge(AF_AxisHints axis, FT_Int fpos, AF_Direction dir, FT_Memory memory, AF_Edge *anedge)
FT_MulDiv(FT_Long a, FT_Long b, FT_Long c)
af_glyph_hints_align_strong_points(AF_GlyphHints hints, AF_Dimension dim)
void af_glyph_hints_dump_points(AF_GlyphHints hints)
enum AF_Edge_Flags_ AF_Edge_Flags
float min(float a, float b)
#define FT_TRACE7(varformat)
#define FT_RENEW_ARRAY(ptr, curcnt, newcnt)
af_direction_compute(FT_Pos dx, FT_Pos dy)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
void af_glyph_hints_dump_edges(AF_GlyphHints hints)
void af_glyph_hints_dump_segments(AF_GlyphHints hints)
FT_MulFix(FT_Long a, FT_Long b)
af_axis_hints_new_segment(AF_AxisHints axis, FT_Memory memory, AF_Segment *asegment)
if(!abbox) return FT_THROW(Invalid_Argument)
FT_BEGIN_HEADER enum AF_Dimension_ AF_Dimension
AF_AxisHintsRec axis[AF_DIMENSION_MAX]
#define FT_CURVE_TAG_CONIC
af_glyph_hints_align_weak_points(AF_GlyphHints hints, AF_Dimension dim)
FT_Error af_glyph_hints_get_num_segments(AF_GlyphHints hints, FT_Int dimension, FT_Int *num_segments)
GLsizei GLenum const GLvoid GLuint GLsizei GLfloat * metrics
#define FT_CURVE_TAG(flag)
FT_Error af_glyph_hints_get_segment_offset(AF_GlyphHints hints, FT_Int dimension, FT_Int idx, FT_Pos *offset)
af_glyph_hints_rescale(AF_GlyphHints hints, AF_ScriptMetrics metrics)