[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:
parent
fd5ae9599a
commit
b6978dd0c9
13
ChangeLog
13
ChangeLog
|
@ -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>
|
2012-07-05 Werner Lemberg <wl@gnu.org>
|
||||||
|
|
||||||
[autofit] Improve output of debugging information.
|
[autofit] Improve output of debugging information.
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
/* */
|
/* */
|
||||||
/* Tracing handling (specification only). */
|
/* 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. */
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of the FreeType project, and may only be used, */
|
/* 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 )
|
FT_TRACE_DEF( gxvlcar )
|
||||||
|
|
||||||
/* autofit components */
|
/* autofit components */
|
||||||
|
FT_TRACE_DEF( afhints )
|
||||||
FT_TRACE_DEF( afcjk )
|
FT_TRACE_DEF( afcjk )
|
||||||
FT_TRACE_DEF( aflatin )
|
FT_TRACE_DEF( aflatin )
|
||||||
FT_TRACE_DEF( aflatin2 )
|
FT_TRACE_DEF( aflatin2 )
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
/* */
|
/* */
|
||||||
/* Auto-fitter routines to compute global hinting values (body). */
|
/* Auto-fitter routines to compute global hinting values (body). */
|
||||||
/* */
|
/* */
|
||||||
/* Copyright 2003-2011 by */
|
/* Copyright 2003-2012 by */
|
||||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of the FreeType project, and may only be used, */
|
/* This file is part of the FreeType project, and may only be used, */
|
||||||
|
@ -82,7 +82,8 @@
|
||||||
FT_Face face = globals->face;
|
FT_Face face = globals->face;
|
||||||
FT_CharMap old_charmap = face->charmap;
|
FT_CharMap old_charmap = face->charmap;
|
||||||
FT_Byte* gscripts = globals->glyph_scripts;
|
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' */
|
/* the value AF_SCRIPT_LIST_NONE means `uncovered glyph' */
|
||||||
|
@ -112,7 +113,7 @@
|
||||||
continue;
|
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.
|
* glyph script index.
|
||||||
*/
|
*/
|
||||||
for ( range = clazz->script_uni_ranges; range->first != 0; range++ )
|
for ( range = clazz->script_uni_ranges; range->first != 0; range++ )
|
||||||
|
@ -187,9 +188,10 @@
|
||||||
|
|
||||||
memory = face->memory;
|
memory = face->memory;
|
||||||
|
|
||||||
if ( !FT_ALLOC( globals, sizeof ( *globals ) +
|
if ( FT_ALLOC( globals, sizeof ( *globals ) +
|
||||||
face->num_glyphs * sizeof ( FT_Byte ) ) )
|
face->num_glyphs * sizeof ( FT_Byte ) ) )
|
||||||
{
|
goto Exit;
|
||||||
|
|
||||||
globals->face = face;
|
globals->face = face;
|
||||||
globals->glyph_count = face->num_glyphs;
|
globals->glyph_count = face->num_glyphs;
|
||||||
globals->glyph_scripts = (FT_Byte*)( globals + 1 );
|
globals->glyph_scripts = (FT_Byte*)( globals + 1 );
|
||||||
|
@ -200,8 +202,8 @@
|
||||||
af_face_globals_free( globals );
|
af_face_globals_free( globals );
|
||||||
globals = NULL;
|
globals = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
Exit:
|
||||||
*aglobals = globals;
|
*aglobals = globals;
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -273,7 +275,7 @@
|
||||||
metrics = globals->metrics[clazz->script];
|
metrics = globals->metrics[clazz->script];
|
||||||
if ( metrics == NULL )
|
if ( metrics == NULL )
|
||||||
{
|
{
|
||||||
/* create the global metrics object when needed */
|
/* create the global metrics object if necessary */
|
||||||
FT_Memory memory = globals->face->memory;
|
FT_Memory memory = globals->face->memory;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,17 @@
|
||||||
#include "afhints.h"
|
#include "afhints.h"
|
||||||
#include "aferrors.h"
|
#include "aferrors.h"
|
||||||
#include FT_INTERNAL_CALC_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. */
|
/* Get new segment for given axis. */
|
||||||
|
@ -70,7 +81,7 @@
|
||||||
FT_Int fpos,
|
FT_Int fpos,
|
||||||
AF_Direction dir,
|
AF_Direction dir,
|
||||||
FT_Memory memory,
|
FT_Memory memory,
|
||||||
AF_Edge *aedge )
|
AF_Edge *anedge )
|
||||||
{
|
{
|
||||||
FT_Error error = AF_Err_Ok;
|
FT_Error error = AF_Err_Ok;
|
||||||
AF_Edge edge = NULL;
|
AF_Edge edge = NULL;
|
||||||
|
@ -124,7 +135,7 @@
|
||||||
edge->dir = (FT_Char)dir;
|
edge->dir = (FT_Char)dir;
|
||||||
|
|
||||||
Exit:
|
Exit:
|
||||||
*aedge = edge;
|
*anedge = edge;
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,13 +186,12 @@
|
||||||
AF_Point point;
|
AF_Point point;
|
||||||
|
|
||||||
|
|
||||||
printf( "Table of points:\n" );
|
FT_TRACE7(( "Table of points:\n"
|
||||||
printf( " [ index | xorg | yorg | xscale | yscale"
|
" [ index | xorg | yorg | xscale | yscale"
|
||||||
" | xfit | yfit | flags ]\n" );
|
" | xfit | yfit | flags ]\n" ));
|
||||||
|
|
||||||
for ( point = points; point < limit; point++ )
|
for ( point = points; point < limit; point++ )
|
||||||
{
|
FT_TRACE7(( " [ %5d | %5d | %5d | %6.2f | %6.2f"
|
||||||
printf( " [ %5d | %5d | %5d | %6.2f | %6.2f"
|
|
||||||
" | %5.2f | %5.2f | %c%c%c%c%c%c ]\n",
|
" | %5.2f | %5.2f | %c%c%c%c%c%c ]\n",
|
||||||
point - points,
|
point - points,
|
||||||
point->fx,
|
point->fx,
|
||||||
|
@ -195,9 +205,8 @@
|
||||||
( point->flags & AF_FLAG_EXTREMA_X ) ? '<' : ' ',
|
( point->flags & AF_FLAG_EXTREMA_X ) ? '<' : ' ',
|
||||||
( point->flags & AF_FLAG_EXTREMA_Y ) ? 'v' : ' ',
|
( point->flags & AF_FLAG_EXTREMA_Y ) ? 'v' : ' ',
|
||||||
( point->flags & AF_FLAG_ROUND_X ) ? '(' : ' ',
|
( point->flags & AF_FLAG_ROUND_X ) ? '(' : ' ',
|
||||||
( point->flags & AF_FLAG_ROUND_Y ) ? 'u' : ' ');
|
( point->flags & AF_FLAG_ROUND_Y ) ? 'u' : ' '));
|
||||||
}
|
FT_TRACE7(( "\n" ));
|
||||||
printf( "\n" );
|
|
||||||
}
|
}
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -226,7 +235,7 @@
|
||||||
if ( pos == 0 )
|
if ( pos == 0 )
|
||||||
return "normal";
|
return "normal";
|
||||||
|
|
||||||
temp[pos] = 0;
|
temp[pos] = '\0';
|
||||||
|
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
@ -253,22 +262,23 @@
|
||||||
AF_Segment seg;
|
AF_Segment seg;
|
||||||
|
|
||||||
|
|
||||||
printf( "Table of %s segments:\n",
|
FT_TRACE7(( "Table of %s segments:\n",
|
||||||
dimension == AF_DIMENSION_HORZ ? "vertical" : "horizontal" );
|
dimension == AF_DIMENSION_HORZ ? "vertical"
|
||||||
|
: "horizontal" ));
|
||||||
if (axis->num_segments)
|
if (axis->num_segments)
|
||||||
printf( " [ index | pos | dir | from"
|
FT_TRACE7(( " [ index | pos | dir | from"
|
||||||
" | to | link | serif | edge"
|
" | to | link | serif | edge"
|
||||||
" | height | extra | flags ]\n" );
|
" | height | extra | flags ]\n" ));
|
||||||
else
|
else
|
||||||
printf( " (none)\n" );
|
FT_TRACE7(( " (none)\n" ));
|
||||||
|
|
||||||
for ( seg = segments; seg < limit; seg++ )
|
for ( seg = segments; seg < limit; seg++ )
|
||||||
{
|
FT_TRACE7(( " [ %5d | %5.2g | %5s | %4d"
|
||||||
printf( " [ %5d | %5.2g | %5s | %4d"
|
|
||||||
" | %4d | %4d | %5d | %4d"
|
" | %4d | %4d | %5d | %4d"
|
||||||
" | %6d | %5d | %11s ]\n",
|
" | %6d | %5d | %11s ]\n",
|
||||||
seg - segments,
|
seg - segments,
|
||||||
dimension == AF_DIMENSION_HORZ ? (int)seg->first->ox / 64.0
|
dimension == AF_DIMENSION_HORZ
|
||||||
|
? (int)seg->first->ox / 64.0
|
||||||
: (int)seg->first->oy / 64.0,
|
: (int)seg->first->oy / 64.0,
|
||||||
af_dir_str( (AF_Direction)seg->dir ),
|
af_dir_str( (AF_Direction)seg->dir ),
|
||||||
AF_INDEX_NUM( seg->first, points ),
|
AF_INDEX_NUM( seg->first, points ),
|
||||||
|
@ -278,9 +288,8 @@
|
||||||
AF_INDEX_NUM( seg->edge, edges ),
|
AF_INDEX_NUM( seg->edge, edges ),
|
||||||
seg->height,
|
seg->height,
|
||||||
seg->height - ( seg->max_coord - seg->min_coord ),
|
seg->height - ( seg->max_coord - seg->min_coord ),
|
||||||
af_edge_flags_to_string( (AF_Edge_Flags)seg->flags ) );
|
af_edge_flags_to_string( (AF_Edge_Flags)seg->flags ) ));
|
||||||
}
|
FT_TRACE7(( "\n" ));
|
||||||
printf( "\n" );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -374,17 +383,17 @@
|
||||||
* note: AF_DIMENSION_HORZ corresponds to _vertical_ edges
|
* note: AF_DIMENSION_HORZ corresponds to _vertical_ edges
|
||||||
* since they have a constant X coordinate.
|
* since they have a constant X coordinate.
|
||||||
*/
|
*/
|
||||||
printf( "Table of %s edges:\n",
|
FT_TRACE7(( "Table of %s edges:\n",
|
||||||
dimension == AF_DIMENSION_HORZ ? "vertical" : "horizontal" );
|
dimension == AF_DIMENSION_HORZ ? "vertical"
|
||||||
|
: "horizontal" ));
|
||||||
if ( axis->num_edges )
|
if ( axis->num_edges )
|
||||||
printf( " [ index | pos | dir | link"
|
FT_TRACE7(( " [ index | pos | dir | link"
|
||||||
" | serif | blue | opos | pos | flags ]\n" );
|
" | serif | blue | opos | pos | flags ]\n" ));
|
||||||
else
|
else
|
||||||
printf( " (none)\n" );
|
FT_TRACE7(( " (none)\n" ));
|
||||||
|
|
||||||
for ( edge = edges; edge < limit; edge++ )
|
for ( edge = edges; edge < limit; edge++ )
|
||||||
{
|
FT_TRACE7(( " [ %5d | %5.2g | %5s | %4d"
|
||||||
printf( " [ %5d | %5.2g | %5s | %4d"
|
|
||||||
" | %5d | %c | %5.2f | %5.2f | %11s ]\n",
|
" | %5d | %c | %5.2f | %5.2f | %11s ]\n",
|
||||||
edge - edges,
|
edge - edges,
|
||||||
(int)edge->opos / 64.0,
|
(int)edge->opos / 64.0,
|
||||||
|
@ -394,9 +403,8 @@
|
||||||
edge->blue_edge ? 'y' : 'n',
|
edge->blue_edge ? 'y' : 'n',
|
||||||
edge->opos / 64.0,
|
edge->opos / 64.0,
|
||||||
edge->pos / 64.0,
|
edge->pos / 64.0,
|
||||||
af_edge_flags_to_string( (AF_Edge_Flags)edge->flags ) );
|
af_edge_flags_to_string( (AF_Edge_Flags)edge->flags ) ));
|
||||||
}
|
FT_TRACE7(( "\n" ));
|
||||||
printf( "\n" );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -529,13 +537,14 @@
|
||||||
|
|
||||||
FT_LOCAL_DEF( void )
|
FT_LOCAL_DEF( void )
|
||||||
af_glyph_hints_done( AF_GlyphHints hints )
|
af_glyph_hints_done( AF_GlyphHints hints )
|
||||||
{
|
|
||||||
if ( hints && hints->memory )
|
|
||||||
{
|
{
|
||||||
FT_Memory memory = hints->memory;
|
FT_Memory memory = hints->memory;
|
||||||
int dim;
|
int dim;
|
||||||
|
|
||||||
|
|
||||||
|
if ( !( hints && hints->memory ) )
|
||||||
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* note that we don't need to free the segment and edge
|
* note that we don't need to free the segment and edge
|
||||||
* buffers since they are really within the hints->points array
|
* buffers since they are really within the hints->points array
|
||||||
|
@ -564,7 +573,6 @@
|
||||||
|
|
||||||
hints->memory = NULL;
|
hints->memory = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Reset metrics. */
|
/* Reset metrics. */
|
||||||
|
@ -759,7 +767,7 @@
|
||||||
|
|
||||||
/* check for weak points */
|
/* check for weak points */
|
||||||
|
|
||||||
if ( point->flags & ( AF_FLAG_CONIC | AF_FLAG_CUBIC ) )
|
if ( point->flags & AF_FLAG_CONTROL )
|
||||||
{
|
{
|
||||||
Is_Weak_Point:
|
Is_Weak_Point:
|
||||||
point->flags |= AF_FLAG_WEAK_INTERPOLATION;
|
point->flags |= AF_FLAG_WEAK_INTERPOLATION;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
/* */
|
/* */
|
||||||
/* Auto-fitter hinting routines (specification). */
|
/* Auto-fitter hinting routines (specification). */
|
||||||
/* */
|
/* */
|
||||||
/* Copyright 2003-2008, 2010-2011 by */
|
/* Copyright 2003-2008, 2010-2012 by */
|
||||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of the FreeType project, and may only be used, */
|
/* 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_Char out_dir; /* direction of outwards vector */
|
||||||
|
|
||||||
FT_Pos ox, oy; /* original, scaled position */
|
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 x, y; /* current position */
|
||||||
FT_Pos u, v; /* current (x,y) or (y,x) depending on context */
|
FT_Pos u, v; /* current (x,y) or (y,x) depending on context */
|
||||||
|
|
||||||
|
@ -290,15 +290,15 @@ FT_BEGIN_HEADER
|
||||||
|
|
||||||
typedef struct AF_EdgeRec_
|
typedef struct AF_EdgeRec_
|
||||||
{
|
{
|
||||||
FT_Short fpos; /* original, unscaled position (font units) */
|
FT_Short fpos; /* original, unscaled position (in font units) */
|
||||||
FT_Pos opos; /* original, scaled position */
|
FT_Pos opos; /* original, scaled position */
|
||||||
FT_Pos pos; /* current position */
|
FT_Pos pos; /* current position */
|
||||||
|
|
||||||
FT_Byte flags; /* edge flags */
|
FT_Byte flags; /* edge flags */
|
||||||
FT_Char dir; /* edge direction */
|
FT_Char dir; /* edge direction */
|
||||||
FT_Fixed scale; /* used to speed up interpolation between edges */
|
FT_Fixed scale; /* used to speed up interpolation between edges */
|
||||||
AF_Width blue_edge; /* non-NULL if this is a blue edge */
|
|
||||||
|
|
||||||
|
AF_Width blue_edge; /* non-NULL if this is a blue edge */
|
||||||
AF_Edge link; /* link edge */
|
AF_Edge link; /* link edge */
|
||||||
AF_Edge serif; /* primary edge for serifs */
|
AF_Edge serif; /* primary edge for serifs */
|
||||||
FT_Short num_linked; /* number of linked edges */
|
FT_Short num_linked; /* number of linked edges */
|
||||||
|
|
|
@ -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_BASE_DEF( void )
|
||||||
FT_GlyphLoader_Add( FT_GlyphLoader loader )
|
FT_GlyphLoader_Add( FT_GlyphLoader loader )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue