21 #include FT_INTERNAL_CALC_H
35 if ( axis->num_segments >= axis->max_segments )
37 FT_Int old_max = axis->max_segments;
42 if ( old_max >= big_max )
44 error = AF_Err_Out_Of_Memory;
48 new_max += ( new_max >> 2 ) + 4;
49 if ( new_max < old_max || new_max > big_max )
55 axis->max_segments = new_max;
58 segment = axis->segments + axis->num_segments++;
80 if ( axis->num_edges >= axis->max_edges )
82 FT_Int old_max = axis->max_edges;
87 if ( old_max >= big_max )
89 error = AF_Err_Out_Of_Memory;
93 new_max += ( new_max >> 2 ) + 4;
94 if ( new_max < old_max || new_max > big_max )
100 axis->max_edges = new_max;
104 edge = edges + axis->num_edges;
106 while ( edge > edges )
108 if ( edge[-1].fpos < fpos )
113 if ( edge[-1].fpos == fpos && dir == axis->major_dir )
132 #ifdef FT_DEBUG_AUTOFIT
134 #include FT_CONFIG_STANDARD_LIBRARY_H
164 #define AF_INDEX_NUM( ptr, base ) ( (ptr) ? ( (ptr) - (base) ) : -1 )
178 printf(
"Table of points:\n" );
179 printf(
" [ index | xorg | yorg | xscale | yscale"
180 " | xfit | yfit | flags ]\n" );
182 for ( point = points; point <
limit; point++ )
184 printf(
" [ %5d | %5d | %5d | %6.2f | %6.2f"
185 " | %5.2f | %5.2f | %c%c%c%c%c%c ]\n",
210 static char temp[32];
246 for ( dimension = 1; dimension >= 0; dimension-- )
254 printf (
"Table of %s segments:\n",
256 printf (
" [ index | pos | dir | link | serif |"
257 " height | extra | flags ]\n" );
259 for ( seg = segments; seg <
limit; seg++ )
261 printf (
" [ %5d | %5.2g | %5s | %4d | %5d | %6d | %5d | %11s ]\n",
266 AF_INDEX_NUM( seg->
link, segments ),
267 AF_INDEX_NUM( seg->
serif, segments ),
296 axis = &hints->
axis[dim];
323 return AF_Err_Invalid_Argument;
327 axis = &hints->
axis[dim];
330 return AF_Err_Invalid_Argument;
354 for ( dimension = 1; dimension >= 0; dimension-- )
366 printf (
"Table of %s edges:\n",
368 printf (
" [ index | pos | dir | link |"
369 " serif | blue | opos | pos | flags ]\n" );
371 for ( edge = edges; edge <
limit; edge++ )
373 printf (
" [ %5d | %5.2g | %5s | %4d |"
374 " %5d | %c | %5.2f | %5.2f | %11s ]\n",
376 (
int)edge->
opos / 64.0,
378 AF_INDEX_NUM( edge->
link, edges ),
379 AF_INDEX_NUM( edge->
serif, edges ),
512 hints->memory = memory;
519 if ( hints && hints->memory )
544 hints->max_contours = 0;
545 hints->num_contours = 0;
548 hints->num_points = 0;
549 hints->max_points = 0;
551 hints->memory =
NULL;
563 hints->scaler_flags = metrics->scaler.flags;
579 FT_Pos x_delta = hints->x_delta;
580 FT_Pos y_delta = hints->y_delta;
584 hints->num_points = 0;
585 hints->num_contours = 0;
587 hints->axis[0].num_segments = 0;
588 hints->axis[0].num_edges = 0;
589 hints->axis[1].num_segments = 0;
590 hints->axis[1].num_edges = 0;
593 new_max = (
FT_UInt)outline->n_contours;
594 old_max = hints->max_contours;
595 if ( new_max > old_max )
597 new_max = ( new_max + 3 ) & ~3;
602 hints->max_contours = new_max;
610 new_max = (
FT_UInt)( outline->n_points + 2 );
611 old_max = hints->max_points;
612 if ( new_max > old_max )
614 new_max = ( new_max + 2 + 7 ) & ~7;
619 hints->max_points = new_max;
622 hints->num_points = outline->n_points;
623 hints->num_contours = outline->n_contours;
638 hints->x_scale = x_scale;
639 hints->y_scale = y_scale;
640 hints->x_delta = x_delta;
641 hints->y_delta = y_delta;
643 hints->xmin_delta = 0;
644 hints->xmax_delta = 0;
646 points = hints->points;
647 if ( hints->num_points == 0 )
652 AF_Point point_limit = points + hints->num_points;
658 char* tag = outline->tags;
664 for ( point = points; point < point_limit; point++, vec++, tag++ )
668 point->
ox = point->
x =
FT_MulFix( vec->x, x_scale ) + x_delta;
669 point->
oy = point->
y =
FT_MulFix( vec->y, y_scale ) + y_delta;
689 if ( ++contour_index < outline->n_contours )
691 end = points + outline->contours[contour_index];
700 AF_Point* contour = hints->contours;
701 AF_Point* contour_limit = contour + hints->num_contours;
702 short*
end = outline->contours;
706 for ( ; contour < contour_limit; contour++, end++ )
708 contour[0] = points +
idx;
709 idx = (short)( end[0] + 1 );
722 for ( point = points; point < point_limit; point++ )
728 if ( point == first )
731 in_x = first->
fx - prev->
fx;
732 in_y = first->
fy - prev->
fy;
740 out_x = next->
fx - point->
fx;
741 out_y = next->
fy - point->
fy;
783 AF_Point limit = point + hints->num_points;
785 char* tag = outline->tags;
788 for ( ; point <
limit; point++, vec++, tag++ )
825 for ( seg = segments; seg < segment_limit; seg++ )
839 point->
x = edge->
pos;
851 for ( seg = segments; seg < segment_limit; seg++ )
865 point->
y = edge->
pos;
893 AF_Point point_limit = points + hints->num_points;
905 if ( edges < edge_limit )
911 for ( point = points; point < point_limit; point++ )
917 if ( point->
flags & touch_flag )
942 delta = edge->
fpos -
u;
945 u = edge->
pos - ( edge->
opos - ou );
950 edge = edge_limit - 1;
951 delta = u - edge->
fpos;
954 u = edge->
pos + ( ou - edge->
opos );
965 max = edge_limit - edges;
974 for ( nn = 0; nn <
max; nn++ )
975 if ( edges[nn].fpos >= u )
978 if ( edges[nn].fpos == u )
989 mid = ( max +
min ) >> 1;
1007 AF_Edge before = edges + min - 1;
1008 AF_Edge after = edges + min + 0;
1012 if ( before->
scale == 0 )
1028 point->
flags |= touch_flag;
1057 for ( p = p1; p <
ref; p++ )
1058 p->
u = p->
v + delta;
1060 for ( p = ref + 1; p <= p2; p++ )
1061 p->
u = p->
v + delta;
1091 for ( p = p1; p <= p2; p++ )
1107 for ( p = p1; p <= p2; p++ )
1116 u = ref1->
u +
FT_MulDiv( u - v1, ref2->
u - ref1->
u, v2 - v1 );
1123 for ( p = p1; p <= p2; p++ )
1132 u = ref1->
u +
FT_MulDiv( u - v1, ref2->
u - ref1->
u, v2 - v1 );
1148 AF_Point point_limit = points + hints->num_points;
1149 AF_Point* contour = hints->contours;
1150 AF_Point* contour_limit = contour + hints->num_contours;
1163 for ( point = points; point < point_limit; point++ )
1165 point->
u = point->
x;
1166 point->
v = point->
ox;
1173 for ( point = points; point < point_limit; point++ )
1175 point->
u = point->
y;
1176 point->
v = point->
oy;
1182 for ( ; contour < contour_limit; contour++ )
1184 AF_Point first_touched, last_touched;
1188 end_point = point->
prev;
1189 first_point = point;
1194 if ( point > end_point )
1197 if ( point->
flags & touch_flag )
1203 first_touched = point;
1204 last_touched = point;
1209 ( point->
flags & touch_flag ) != 0 );
1212 while ( point < end_point &&
1213 ( point[1].flags & touch_flag ) != 0 )
1216 last_touched = point;
1222 if ( point > end_point )
1225 if ( ( point->
flags & touch_flag ) != 0 )
1233 last_touched, point );
1238 if ( last_touched == first_touched )
1243 if ( last_touched < end_point )
1245 last_touched, first_touched );
1247 if ( first_touched > points )
1249 last_touched, first_touched );
1259 for ( point = points; point < point_limit; point++ )
1260 point->
x = point->
u;
1264 for ( point = points; point < point_limit; point++ )
1265 point->
y = point->
u;
1270 #ifdef AF_CONFIG_OPTION_USE_WARPER
1281 AF_Point points_limit = points + hints->num_points;
1287 for ( point = points; point < points_limit; point++ )
1292 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)
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
#define FT_CURVE_TAG_CUBIC
af_glyph_hints_init(AF_GlyphHints hints, FT_Memory memory)
static void af_iup_interp(AF_Point p1, AF_Point p2, AF_Point ref1, AF_Point ref2)
GLuint GLsizei GLsizei GLfloat * metrics
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 *aedge)
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
#define FT_RENEW_ARRAY(ptr, curcnt, newcnt)
af_direction_compute(FT_Pos dx, FT_Pos dy)
GLenum GLenum GLenum GLenum GLenum scale
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)
FT_BEGIN_HEADER enum AF_Dimension_ AF_Dimension
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags
GLuint GLdouble GLdouble GLint GLint const GLdouble * points
static void af_iup_shift(AF_Point p1, AF_Point p2, AF_Point ref)
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)
#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)
GLfloat GLfloat GLfloat v2