mirror of https://github.com/freetype/freetype
[autofit] Improve tracing.
* src/autofit/afhints.c (af_print_idx, af_get_segment_index, af_get_edge_index): New functions. (af_glyph_hints_dump_points): Remove unnecessary `|', `[', and `]'. Add segment and edge index for each point. Slightly change printing order of some elements. Don't print `-1' but `--' for missing elements. (af_glyph_hints_dump_segments, af_glyph_hints_dump_edges): Remove unnecessary `|', `[', and `]'. Don't print `-1' but `--' for missing elements.
This commit is contained in:
parent
07f27e1e43
commit
7f00fa6462
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2015-10-25 Werner Lemberg <wl@gnu.org>
|
||||
|
||||
[autofit] Improve tracing.
|
||||
|
||||
* src/autofit/afhints.c (af_print_idx, af_get_segment_index,
|
||||
af_get_edge_index): New functions.
|
||||
|
||||
(af_glyph_hints_dump_points): Remove unnecessary `|', `[', and `]'.
|
||||
Add segment and edge index for each point.
|
||||
Slightly change printing order of some elements.
|
||||
Don't print `-1' but `--' for missing elements.
|
||||
|
||||
(af_glyph_hints_dump_segments, af_glyph_hints_dump_edges): Remove
|
||||
unnecessary `|', `[', and `]'.
|
||||
Don't print `-1' but `--' for missing elements.
|
||||
|
||||
2015-10-24 Werner Lemberg <wl@gnu.org>
|
||||
|
||||
[sfnt] Sanitize bitmap strike glyph height.
|
||||
|
|
|
@ -219,6 +219,70 @@
|
|||
#define AF_INDEX_NUM( ptr, base ) (int)( (ptr) ? ( (ptr) - (base) ) : -1 )
|
||||
|
||||
|
||||
static char*
|
||||
af_print_idx( char* p,
|
||||
int idx )
|
||||
{
|
||||
if ( idx == -1 )
|
||||
{
|
||||
p[0] = '-';
|
||||
p[1] = '-';
|
||||
p[2] = '\0';
|
||||
}
|
||||
else
|
||||
ft_sprintf( p, "%d", idx );
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
af_get_segment_index( AF_GlyphHints hints,
|
||||
int point_idx,
|
||||
int dimension )
|
||||
{
|
||||
AF_AxisHints axis = &hints->axis[dimension];
|
||||
AF_Point point = hints->points + point_idx;
|
||||
AF_Segment segments = axis->segments;
|
||||
AF_Segment limit = segments + axis->num_segments;
|
||||
AF_Segment segment;
|
||||
|
||||
|
||||
for ( segment = segments; segment < limit; segment++ )
|
||||
{
|
||||
if ( segment->first <= segment->last )
|
||||
{
|
||||
if ( point >= segment->first && point <= segment->last )
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( point >= segment->first || point <= segment->last )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( segment == limit )
|
||||
return -1;
|
||||
|
||||
return (int)( segment - segments );
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
af_get_edge_index( AF_GlyphHints hints,
|
||||
int segment_idx,
|
||||
int dimension )
|
||||
{
|
||||
AF_AxisHints axis = &hints->axis[dimension];
|
||||
AF_Edge edges = axis->edges;
|
||||
AF_Segment segment = axis->segments + segment_idx;
|
||||
|
||||
|
||||
return segment_idx == -1 ? -1 : AF_INDEX_NUM( segment->edge, edges );
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -234,22 +298,38 @@
|
|||
AF_DUMP(( "Table of points:\n" ));
|
||||
|
||||
if ( hints->num_points )
|
||||
AF_DUMP(( " [ index | xorg | yorg | xscale | yscale"
|
||||
" | xfit | yfit | flags ]\n" ));
|
||||
AF_DUMP(( " index hedge hseg vedge vseg flags"
|
||||
" xorg yorg xscale yscale xfit yfit\n" ));
|
||||
else
|
||||
AF_DUMP(( " (none)\n" ));
|
||||
|
||||
for ( point = points; point < limit; point++ )
|
||||
AF_DUMP(( " [ %5d | %5d | %5d | %6.2f | %6.2f"
|
||||
" | %5.2f | %5.2f | %c ]\n",
|
||||
AF_INDEX_NUM( point, points ),
|
||||
{
|
||||
int point_idx = AF_INDEX_NUM( point, points );
|
||||
int segment_idx_0 = af_get_segment_index( hints, point_idx, 0 );
|
||||
int segment_idx_1 = af_get_segment_index( hints, point_idx, 1 );
|
||||
|
||||
char buf1[16], buf2[16], buf3[16], buf4[16];
|
||||
|
||||
|
||||
AF_DUMP(( " %5d %5s %5s %5s %5s %c "
|
||||
" %5d %5d %7.2f %7.2f %7.2f %7.2f\n",
|
||||
point_idx,
|
||||
af_print_idx( buf1,
|
||||
af_get_edge_index( hints, segment_idx_1, 1 ) ),
|
||||
af_print_idx( buf2, segment_idx_1 ),
|
||||
af_print_idx( buf3,
|
||||
af_get_edge_index( hints, segment_idx_0, 0 ) ),
|
||||
af_print_idx( buf4, segment_idx_0 ),
|
||||
( point->flags & AF_FLAG_WEAK_INTERPOLATION ) ? 'w' : '-',
|
||||
|
||||
point->fx,
|
||||
point->fy,
|
||||
point->ox / 64.0,
|
||||
point->oy / 64.0,
|
||||
point->x / 64.0,
|
||||
point->y / 64.0,
|
||||
( point->flags & AF_FLAG_WEAK_INTERPOLATION ) ? 'w' : ' '));
|
||||
point->y / 64.0 ));
|
||||
}
|
||||
AF_DUMP(( "\n" ));
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
|
@ -306,21 +386,23 @@
|
|||
AF_Segment limit = segments + axis->num_segments;
|
||||
AF_Segment seg;
|
||||
|
||||
char buf1[16], buf2[16], buf3[16];
|
||||
|
||||
|
||||
AF_DUMP(( "Table of %s segments:\n",
|
||||
dimension == AF_DIMENSION_HORZ ? "vertical"
|
||||
: "horizontal" ));
|
||||
if ( axis->num_segments )
|
||||
AF_DUMP(( " [ index | pos | dir | from"
|
||||
" | to | link | serif | edge"
|
||||
" | height | extra | flags ]\n" ));
|
||||
AF_DUMP(( " index pos dir from to"
|
||||
" link serif edge"
|
||||
" height extra flags\n" ));
|
||||
else
|
||||
AF_DUMP(( " (none)\n" ));
|
||||
|
||||
for ( seg = segments; seg < limit; seg++ )
|
||||
AF_DUMP(( " [ %5d | %5.2g | %5s | %4d"
|
||||
" | %4d | %4d | %5d | %4d"
|
||||
" | %6d | %5d | %11s ]\n",
|
||||
AF_DUMP(( " %5d %5.2g %5s %4d %4d"
|
||||
" %4s %5s %4s"
|
||||
" %6d %5d %11s\n",
|
||||
AF_INDEX_NUM( seg, segments ),
|
||||
dimension == AF_DIMENSION_HORZ
|
||||
? (int)seg->first->ox / 64.0
|
||||
|
@ -328,9 +410,11 @@
|
|||
af_dir_str( (AF_Direction)seg->dir ),
|
||||
AF_INDEX_NUM( seg->first, points ),
|
||||
AF_INDEX_NUM( seg->last, points ),
|
||||
AF_INDEX_NUM( seg->link, segments ),
|
||||
AF_INDEX_NUM( seg->serif, segments ),
|
||||
AF_INDEX_NUM( seg->edge, edges ),
|
||||
|
||||
af_print_idx( buf1, AF_INDEX_NUM( seg->link, segments ) ),
|
||||
af_print_idx( buf2, AF_INDEX_NUM( seg->serif, segments ) ),
|
||||
af_print_idx( buf3, AF_INDEX_NUM( seg->edge, edges ) ),
|
||||
|
||||
seg->height,
|
||||
seg->height - ( seg->max_coord - seg->min_coord ),
|
||||
af_edge_flags_to_string( seg->flags ) ));
|
||||
|
@ -435,6 +519,8 @@
|
|||
AF_Edge limit = edges + axis->num_edges;
|
||||
AF_Edge edge;
|
||||
|
||||
char buf1[16], buf2[16];
|
||||
|
||||
|
||||
/*
|
||||
* note: AF_DIMENSION_HORZ corresponds to _vertical_ edges
|
||||
|
@ -444,19 +530,20 @@
|
|||
dimension == AF_DIMENSION_HORZ ? "vertical"
|
||||
: "horizontal" ));
|
||||
if ( axis->num_edges )
|
||||
AF_DUMP(( " [ index | pos | dir | link"
|
||||
" | serif | blue | opos | pos | flags ]\n" ));
|
||||
AF_DUMP(( " index pos dir link serif"
|
||||
" blue opos pos flags\n" ));
|
||||
else
|
||||
AF_DUMP(( " (none)\n" ));
|
||||
|
||||
for ( edge = edges; edge < limit; edge++ )
|
||||
AF_DUMP(( " [ %5d | %5.2g | %5s | %4d"
|
||||
" | %5d | %c | %5.2f | %5.2f | %11s ]\n",
|
||||
AF_DUMP(( " %5d %5.2g %5s %4s %5s"
|
||||
" %c %5.2f %5.2f %11s\n",
|
||||
AF_INDEX_NUM( edge, edges ),
|
||||
(int)edge->opos / 64.0,
|
||||
af_dir_str( (AF_Direction)edge->dir ),
|
||||
AF_INDEX_NUM( edge->link, edges ),
|
||||
AF_INDEX_NUM( edge->serif, edges ),
|
||||
af_print_idx( buf1, AF_INDEX_NUM( edge->link, edges ) ),
|
||||
af_print_idx( buf2, AF_INDEX_NUM( edge->serif, edges ) ),
|
||||
|
||||
edge->blue_edge ? 'y' : 'n',
|
||||
edge->opos / 64.0,
|
||||
edge->pos / 64.0,
|
||||
|
|
Loading…
Reference in New Issue