[autofit] Do some code cleanup.

* src/autofit/afglobal.c (af_face_globals_new): Simplify.

* src/autofit/afhints.c: Use `FT_TRACE7' instead of `printf'
everywhere.
(FT_COMPONENT): New macro.
(af_glyph_hints_done): Simplify.

* include/freetype/internal/fttrace.h: Updated.
This commit is contained in:
Werner Lemberg 2012-07-06 19:38:44 +02:00
Родитель fd5ae9599a
Коммит b6978dd0c9
6 изменённых файлов: 149 добавлений и 125 удалений

Просмотреть файл

@ -1,3 +1,16 @@
2012-07-06 Werner Lemberg <wl@gnu.org>
[autofit] Do some code cleanup.
* src/autofit/afglobal.c (af_face_globals_new): Simplify.
* src/autofit/afhints.c: Use `FT_TRACE7' instead of `printf'
everywhere.
(FT_COMPONENT): New macro.
(af_glyph_hints_done): Simplify.
* include/freetype/internal/fttrace.h: Updated.
2012-07-05 Werner Lemberg <wl@gnu.org>
[autofit] Improve output of debugging information.

Просмотреть файл

@ -4,7 +4,7 @@
/* */
/* Tracing handling (specification only). */
/* */
/* Copyright 2002, 2004-2007, 2009, 2011 by */
/* Copyright 2002, 2004-2007, 2009, 2011-2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -136,6 +136,7 @@ FT_TRACE_DEF( gxvprop )
FT_TRACE_DEF( gxvlcar )
/* autofit components */
FT_TRACE_DEF( afhints )
FT_TRACE_DEF( afcjk )
FT_TRACE_DEF( aflatin )
FT_TRACE_DEF( aflatin2 )

Просмотреть файл

@ -4,7 +4,7 @@
/* */
/* Auto-fitter routines to compute global hinting values (body). */
/* */
/* Copyright 2003-2011 by */
/* Copyright 2003-2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -82,7 +82,8 @@
FT_Face face = globals->face;
FT_CharMap old_charmap = face->charmap;
FT_Byte* gscripts = globals->glyph_scripts;
FT_UInt ss, i;
FT_UInt ss;
FT_UInt i;
/* the value AF_SCRIPT_LIST_NONE means `uncovered glyph' */
@ -112,7 +113,7 @@
continue;
/*
* Scan all unicode points in the range and set the corresponding
* Scan all Unicode points in the range and set the corresponding
* glyph script index.
*/
for ( range = clazz->script_uni_ranges; range->first != 0; range++ )
@ -187,21 +188,22 @@
memory = face->memory;
if ( !FT_ALLOC( globals, sizeof ( *globals ) +
face->num_glyphs * sizeof ( FT_Byte ) ) )
{
globals->face = face;
globals->glyph_count = face->num_glyphs;
globals->glyph_scripts = (FT_Byte*)( globals + 1 );
if ( FT_ALLOC( globals, sizeof ( *globals ) +
face->num_glyphs * sizeof ( FT_Byte ) ) )
goto Exit;
error = af_face_globals_compute_script_coverage( globals );
if ( error )
{
af_face_globals_free( globals );
globals = NULL;
}
globals->face = face;
globals->glyph_count = face->num_glyphs;
globals->glyph_scripts = (FT_Byte*)( globals + 1 );
error = af_face_globals_compute_script_coverage( globals );
if ( error )
{
af_face_globals_free( globals );
globals = NULL;
}
Exit:
*aglobals = globals;
return error;
}
@ -273,7 +275,7 @@
metrics = globals->metrics[clazz->script];
if ( metrics == NULL )
{
/* create the global metrics object when needed */
/* create the global metrics object if necessary */
FT_Memory memory = globals->face->memory;

Просмотреть файл

@ -19,6 +19,17 @@
#include "afhints.h"
#include "aferrors.h"
#include FT_INTERNAL_CALC_H
#include FT_INTERNAL_DEBUG_H
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_afhints
/* Get new segment for given axis. */
@ -70,7 +81,7 @@
FT_Int fpos,
AF_Direction dir,
FT_Memory memory,
AF_Edge *aedge )
AF_Edge *anedge )
{
FT_Error error = AF_Err_Ok;
AF_Edge edge = NULL;
@ -124,7 +135,7 @@
edge->dir = (FT_Char)dir;
Exit:
*aedge = edge;
*anedge = edge;
return error;
}
@ -175,29 +186,27 @@
AF_Point point;
printf( "Table of points:\n" );
printf( " [ index | xorg | yorg | xscale | yscale"
" | xfit | yfit | flags ]\n" );
FT_TRACE7(( "Table of points:\n"
" [ index | xorg | yorg | xscale | yscale"
" | xfit | yfit | flags ]\n" ));
for ( point = points; point < limit; point++ )
{
printf( " [ %5d | %5d | %5d | %6.2f | %6.2f"
" | %5.2f | %5.2f | %c%c%c%c%c%c ]\n",
point - points,
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->flags & AF_FLAG_INFLECTION ) ? 'i' : ' ',
( point->flags & AF_FLAG_EXTREMA_X ) ? '<' : ' ',
( point->flags & AF_FLAG_EXTREMA_Y ) ? 'v' : ' ',
( point->flags & AF_FLAG_ROUND_X ) ? '(' : ' ',
( point->flags & AF_FLAG_ROUND_Y ) ? 'u' : ' ');
}
printf( "\n" );
FT_TRACE7(( " [ %5d | %5d | %5d | %6.2f | %6.2f"
" | %5.2f | %5.2f | %c%c%c%c%c%c ]\n",
point - points,
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->flags & AF_FLAG_INFLECTION ) ? 'i' : ' ',
( point->flags & AF_FLAG_EXTREMA_X ) ? '<' : ' ',
( point->flags & AF_FLAG_EXTREMA_Y ) ? 'v' : ' ',
( point->flags & AF_FLAG_ROUND_X ) ? '(' : ' ',
( point->flags & AF_FLAG_ROUND_Y ) ? 'u' : ' '));
FT_TRACE7(( "\n" ));
}
#ifdef __cplusplus
}
@ -226,7 +235,7 @@
if ( pos == 0 )
return "normal";
temp[pos] = 0;
temp[pos] = '\0';
return temp;
}
@ -253,34 +262,34 @@
AF_Segment seg;
printf( "Table of %s segments:\n",
dimension == AF_DIMENSION_HORZ ? "vertical" : "horizontal" );
FT_TRACE7(( "Table of %s segments:\n",
dimension == AF_DIMENSION_HORZ ? "vertical"
: "horizontal" ));
if (axis->num_segments)
printf( " [ index | pos | dir | from"
" | to | link | serif | edge"
" | height | extra | flags ]\n" );
FT_TRACE7(( " [ index | pos | dir | from"
" | to | link | serif | edge"
" | height | extra | flags ]\n" ));
else
printf( " (none)\n" );
FT_TRACE7(( " (none)\n" ));
for ( seg = segments; seg < limit; seg++ )
{
printf( " [ %5d | %5.2g | %5s | %4d"
" | %4d | %4d | %5d | %4d"
" | %6d | %5d | %11s ]\n",
seg - segments,
dimension == AF_DIMENSION_HORZ ? (int)seg->first->ox / 64.0
: (int)seg->first->oy / 64.0,
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 ),
seg->height,
seg->height - ( seg->max_coord - seg->min_coord ),
af_edge_flags_to_string( (AF_Edge_Flags)seg->flags ) );
}
printf( "\n" );
FT_TRACE7(( " [ %5d | %5.2g | %5s | %4d"
" | %4d | %4d | %5d | %4d"
" | %6d | %5d | %11s ]\n",
seg - segments,
dimension == AF_DIMENSION_HORZ
? (int)seg->first->ox / 64.0
: (int)seg->first->oy / 64.0,
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 ),
seg->height,
seg->height - ( seg->max_coord - seg->min_coord ),
af_edge_flags_to_string( (AF_Edge_Flags)seg->flags ) ));
FT_TRACE7(( "\n" ));
}
}
#ifdef __cplusplus
@ -374,29 +383,28 @@
* note: AF_DIMENSION_HORZ corresponds to _vertical_ edges
* since they have a constant X coordinate.
*/
printf( "Table of %s edges:\n",
dimension == AF_DIMENSION_HORZ ? "vertical" : "horizontal" );
FT_TRACE7(( "Table of %s edges:\n",
dimension == AF_DIMENSION_HORZ ? "vertical"
: "horizontal" ));
if ( axis->num_edges )
printf( " [ index | pos | dir | link"
" | serif | blue | opos | pos | flags ]\n" );
FT_TRACE7(( " [ index | pos | dir | link"
" | serif | blue | opos | pos | flags ]\n" ));
else
printf( " (none)\n" );
FT_TRACE7(( " (none)\n" ));
for ( edge = edges; edge < limit; edge++ )
{
printf( " [ %5d | %5.2g | %5s | %4d"
" | %5d | %c | %5.2f | %5.2f | %11s ]\n",
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 ),
edge->blue_edge ? 'y' : 'n',
edge->opos / 64.0,
edge->pos / 64.0,
af_edge_flags_to_string( (AF_Edge_Flags)edge->flags ) );
}
printf( "\n" );
FT_TRACE7(( " [ %5d | %5.2g | %5s | %4d"
" | %5d | %c | %5.2f | %5.2f | %11s ]\n",
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 ),
edge->blue_edge ? 'y' : 'n',
edge->opos / 64.0,
edge->pos / 64.0,
af_edge_flags_to_string( (AF_Edge_Flags)edge->flags ) ));
FT_TRACE7(( "\n" ));
}
}
#ifdef __cplusplus
@ -530,40 +538,40 @@
FT_LOCAL_DEF( void )
af_glyph_hints_done( AF_GlyphHints hints )
{
if ( hints && hints->memory )
FT_Memory memory = hints->memory;
int dim;
if ( !( hints && hints->memory ) )
return;
/*
* note that we don't need to free the segment and edge
* buffers since they are really within the hints->points array
*/
for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
{
FT_Memory memory = hints->memory;
int dim;
AF_AxisHints axis = &hints->axis[dim];
/*
* note that we don't need to free the segment and edge
* buffers since they are really within the hints->points array
*/
for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
{
AF_AxisHints axis = &hints->axis[dim];
axis->num_segments = 0;
axis->max_segments = 0;
FT_FREE( axis->segments );
axis->num_segments = 0;
axis->max_segments = 0;
FT_FREE( axis->segments );
axis->num_edges = 0;
axis->max_edges = 0;
FT_FREE( axis->edges );
}
FT_FREE( hints->contours );
hints->max_contours = 0;
hints->num_contours = 0;
FT_FREE( hints->points );
hints->num_points = 0;
hints->max_points = 0;
hints->memory = NULL;
axis->num_edges = 0;
axis->max_edges = 0;
FT_FREE( axis->edges );
}
FT_FREE( hints->contours );
hints->max_contours = 0;
hints->num_contours = 0;
FT_FREE( hints->points );
hints->num_points = 0;
hints->max_points = 0;
hints->memory = NULL;
}
@ -759,7 +767,7 @@
/* check for weak points */
if ( point->flags & ( AF_FLAG_CONIC | AF_FLAG_CUBIC ) )
if ( point->flags & AF_FLAG_CONTROL )
{
Is_Weak_Point:
point->flags |= AF_FLAG_WEAK_INTERPOLATION;

Просмотреть файл

@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines (specification). */
/* */
/* Copyright 2003-2008, 2010-2011 by */
/* Copyright 2003-2008, 2010-2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -254,7 +254,7 @@ FT_BEGIN_HEADER
FT_Char out_dir; /* direction of outwards vector */
FT_Pos ox, oy; /* original, scaled position */
FT_Short fx, fy; /* original, unscaled position (font units) */
FT_Short fx, fy; /* original, unscaled position (in font units) */
FT_Pos x, y; /* current position */
FT_Pos u, v; /* current (x,y) or (y,x) depending on context */
@ -290,19 +290,19 @@ FT_BEGIN_HEADER
typedef struct AF_EdgeRec_
{
FT_Short fpos; /* original, unscaled position (font units) */
FT_Pos opos; /* original, scaled position */
FT_Pos pos; /* current position */
FT_Short fpos; /* original, unscaled position (in font units) */
FT_Pos opos; /* original, scaled position */
FT_Pos pos; /* current position */
FT_Byte flags; /* edge flags */
FT_Char dir; /* edge direction */
FT_Fixed scale; /* used to speed up interpolation between edges */
AF_Width blue_edge; /* non-NULL if this is a blue edge */
AF_Edge link; /* link edge */
AF_Edge serif; /* primary edge for serifs */
FT_Short num_linked; /* number of linked edges */
FT_Int score; /* used during stem matching */
AF_Width blue_edge; /* non-NULL if this is a blue edge */
AF_Edge link; /* link edge */
AF_Edge serif; /* primary edge for serifs */
FT_Short num_linked; /* number of linked edges */
FT_Int score; /* used during stem matching */
AF_Segment first; /* first segment in edge */
AF_Segment last; /* last segment in edge */

Просмотреть файл

@ -318,7 +318,7 @@
}
/* add current glyph to the base image - and prepare for another */
/* add current glyph to the base image -- and prepare for another */
FT_BASE_DEF( void )
FT_GlyphLoader_Add( FT_GlyphLoader loader )
{