* src/pshinter/pshalgo3.c (psh3_glyph_compute_inflections,

psh3_glyph_compute_extrema, psh3_hint_table_find_strong_point): Fix
compiler warnings and resolve shadowing of local variables.
This commit is contained in:
Werner Lemberg 2002-08-22 06:04:32 +00:00
parent 0ca0d9773e
commit b6cdf566df
3 changed files with 132 additions and 78 deletions

View File

@ -1,3 +1,9 @@
2002-08-21 Werner Lemberg <wl@gnu.org>
* src/pshinter/pshalgo3.c (psh3_glyph_compute_inflections,
psh3_glyph_compute_extrema, psh3_hint_table_find_strong_point): Fix
compiler warnings and resolve shadowing of local variables.
2002-08-21 David Turner <david@freetype.org>
* src/pshinter/pshalgo3.c, src/autohint/ahangles.c,
@ -32,11 +38,41 @@
src/autohint/ahmodule.c [DEBUG_HINTER]: Removing compiler warnings
(only used in development builds anyway).
* src/pshinter/pshalgo3.h, src/pshinter/pshalgo3.c: Removing
compiler warnings, and improving the support of local extrema
and stem edge points.
Improve support of local extrema and stem edge points.
* src/pshinter/pshalgo3.h (PSH3_Hint_TableRec): Use PSH3_ZoneRec
for `zones'.
(PSH3_DIR_UP, PSH3_DIR_DOWN): Exchange values.
(PSH3_DIR_HORIZONTAL, PSH3_DIR_VERTICAL): New macros.
(PSH3_DIR_COMPARE, PSH3_DIR_IS_HORIZONTAL, PSH3_IS_VERTICAL): New
macros.
(PSH3_POINT_INFLEX): New enum.
(psh3_point_{is,set}_{off,inflex}): New macros.
(PSH3_POINT_{EXTREMUM,POSITIVE,NEGATIVE,EDGE_MIN,EDGE_MAX): New
enum values.
(psh3_point_{is,set}_{extremum,positive,negative,edge_min,edge_max}):
New macros.
(PSH3_PointRec): New members `flags2' and `org_v'.
(PSH3_POINT_EQUAL_ARG, PSH3_POINT_ANGLE): New macros.
* src/pshinter/pshalgo3.c [DEBUG_HINTER]: Removing compiler
warnings.
(COMPUTE_INFLEXS): New macro.
(psh3_hint_align): Simplify some basic arithmetic computations.
(psh3_point_is_extremum): Removed.
(psh3_glyph_compute_inflections) [COMPUTE_INFLEXS]: New function.
(psh3_glyph_init) [COMPUTE_INFLEXS]: Use it.
(psh3_glyph_compute_extrema): New function.
(PSH3_STRONG_THRESHOLD): Increased to 30.
(psh3_hint_table_find_strong_point): Improved.
(psh3_glyph_find_strong_points,
psh3_glyph_interpolate_strong_points): Updated.
(psh3_hints_apply): Use psh3_glyph_compute_extrema.
* test/gview.c (draw_ps3_hint, ps3_draw_control_points): New
functions.
Other small updates.
* test/gview.c: Small updates to the hinting debugger.
* Jamfile: Small updates.
2002-08-18 Arkadiusz Miskiewicz <misiek@pld.ORG.PL>

View File

@ -665,12 +665,14 @@
/*************************************************************************/
#ifdef COMPUTE_INFLEXS
/* compute all inflex points in a given glyph */
/* compute all inflex points in a given glyph */
static void
psh3_glyph_compute_inflections( PSH3_Glyph glyph )
{
FT_UInt n;
for ( n = 0; n < glyph->num_contours; n++ )
{
PSH3_Point first, start, end, before, after;
@ -678,12 +680,13 @@
FT_Angle diff_in, diff_out;
FT_Int finished = 0;
/* we need at least 4 points to create an inflection point */
if ( glyph->contours[n].count < 4 )
continue;
/* compute first segment in contour */
first = glyph->contours[n].start;
first = glyph->contours[n].start;
start = end = first;
do
@ -691,8 +694,8 @@
end = end->next;
if ( end == first )
goto Skip;
}
while ( PSH3_POINT_EQUAL_ORG( end, first ) );
} while ( PSH3_POINT_EQUAL_ORG( end, first ) );
angle_seg = PSH3_POINT_ANGLE( start, end );
@ -706,12 +709,12 @@
before = before->prev;
if ( before == first )
goto Skip;
}
while ( PSH3_POINT_EQUAL_ORG( before, start ) );
} while ( PSH3_POINT_EQUAL_ORG( before, start ) );
angle_in = PSH3_POINT_ANGLE( before, start );
}
while ( angle_in == angle_seg );
} while ( angle_in == angle_seg );
first = start;
diff_in = FT_Angle_Diff( angle_in, angle_seg );
@ -729,12 +732,12 @@
after = after->next;
if ( after == first )
finished = 1;
}
while ( PSH3_POINT_EQUAL_ORG( end, after ) );
} while ( PSH3_POINT_EQUAL_ORG( end, after ) );
angle_out = PSH3_POINT_ANGLE( end, after );
}
while ( angle_out == angle_seg );
} while ( angle_out == angle_seg );
diff_out = FT_Angle_Diff( angle_seg, angle_out );
@ -757,15 +760,17 @@
end = after;
angle_seg = angle_out;
diff_in = diff_out;
}
while ( !finished );
} while ( !finished );
Skip:
;
}
}
#endif /* COMPUTE_INFLEXS */
static void
psh3_glyph_done( PSH3_Glyph glyph )
{
@ -1037,13 +1042,12 @@
}
/* compute all extrema in a glyph for a given dimension */
/* compute all extrema in a glyph for a given dimension */
static void
psh3_glyph_compute_extrema( PSH3_Glyph glyph )
{
FT_UInt n;
FT_UInt n;
/* first of all, compute all local extrema */
for ( n = 0; n < glyph->num_contours; n++ )
@ -1051,6 +1055,7 @@
PSH3_Point first = glyph->contours[n].start;
PSH3_Point point, before, after;
point = first;
before = point;
after = point;
@ -1073,8 +1078,8 @@
after = after->next;
if ( after == first )
goto Next;
}
while ( after->org_u == point->org_u );
} while ( after->org_u == point->org_u );
if ( before->org_u < point->org_u )
{
@ -1094,8 +1099,8 @@
{
psh3_point_set_extremum( point );
point = point->next;
}
while ( point != after );
} while ( point != after );
}
}
@ -1108,16 +1113,17 @@
;
}
/* for each extrema, determine its direction along the */
/* orthogonal axis */
/* for each extrema, determine its direction along the */
/* orthogonal axis */
for ( n = 0; n < glyph->num_points; n++ )
{
PSH3_Point point, before, after;
point = &glyph->points[n];
before = point;
after = point;
if ( psh3_point_is_extremum( point ) )
{
do
@ -1125,16 +1131,16 @@
before = before->prev;
if ( before == point )
goto Skip;
}
while ( before->org_v == point->org_v );
} while ( before->org_v == point->org_v );
do
{
after = after->next;
if ( after == point )
goto Skip;
}
while ( after->org_v == point->org_v );
} while ( after->org_v == point->org_v );
}
if ( before->org_v < point->org_v &&
@ -1147,29 +1153,29 @@
{
psh3_point_set_negative( point );
}
Skip:
;
}
}
#define PSH3_STRONG_THRESHOLD 30
/* major_dir is the direction for points on the bottom/left of the stem;
* Points on the top/right of the stem will have a direction of
* -major_dir.
*/
/* major_dir is the direction for points on the bottom/left of the stem; */
/* Points on the top/right of the stem will have a direction of */
/* -major_dir. */
static void
psh3_hint_table_find_strong_point( PSH3_Hint_Table table,
PSH3_Point point,
FT_Int major_dir )
{
PSH3_Hint* sort = table->sort;
FT_UInt num_hints = table->num_hints;
FT_Int point_dir = 0;
PSH3_Hint* sort = table->sort;
FT_UInt num_hints = table->num_hints;
FT_Int point_dir = 0;
if ( PSH3_DIR_COMPARE( point->dir_in, major_dir ) )
point_dir = point->dir_in;
@ -1181,15 +1187,18 @@
{
FT_UInt flag;
for ( ; num_hints > 0; num_hints--, sort++ )
{
PSH3_Hint hint = sort[0];
FT_Pos d;
if ( point_dir == major_dir )
{
flag = PSH3_POINT_EDGE_MIN;
d = point->org_u - hint->org_pos;
if ( ABS( d ) < PSH3_STRONG_THRESHOLD )
{
Is_Strong:
@ -1203,17 +1212,20 @@
{
flag = PSH3_POINT_EDGE_MAX;
d = point->org_u - hint->org_pos - hint->org_len;
if ( ABS( d ) < PSH3_STRONG_THRESHOLD )
goto Is_Strong;
}
}
}
#if 1
else if ( psh3_point_is_extremum( point ) )
{
/* treat extrema as special cases for stem edge alignment */
FT_UInt min_flag, max_flag;
if ( major_dir == PSH3_DIR_HORIZONTAL )
{
min_flag = PSH3_POINT_POSITIVE;
@ -1230,10 +1242,12 @@
PSH3_Hint hint = sort[0];
FT_Pos d, flag;
if ( point->flags2 & min_flag )
{
flag = PSH3_POINT_EDGE_MIN;
d = point->org_u - hint->org_pos;
if ( ABS( d ) < PSH3_STRONG_THRESHOLD )
{
Is_Strong2:
@ -1247,6 +1261,7 @@
{
flag = PSH3_POINT_EDGE_MAX;
d = point->org_u - hint->org_pos - hint->org_len;
if ( ABS( d ) < PSH3_STRONG_THRESHOLD )
goto Is_Strong2;
}
@ -1258,7 +1273,8 @@
}
}
}
#endif
#endif /* 1 */
}
@ -1358,6 +1374,7 @@
{
FT_Pos delta;
if ( psh3_point_is_edge_min( point ) )
{
point->cur_u = hint->cur_pos;
@ -1375,11 +1392,12 @@
else if ( delta >= hint->org_len )
point->cur_u = hint->cur_pos + hint->cur_len +
FT_MulFix( delta - hint->org_len, scale );
FT_MulFix( delta - hint->org_len, scale );
else if ( hint->org_len > 0 )
point->cur_u = hint->cur_pos +
FT_MulDiv( delta, hint->cur_len, hint->org_len );
FT_MulDiv( delta, hint->cur_len,
hint->org_len );
else
point->cur_u = hint->cur_pos;
}

View File

@ -28,10 +28,10 @@
FT_BEGIN_HEADER
/* handle to Hint structure */
/* handle to Hint structure */
typedef struct PSH3_HintRec_* PSH3_Hint;
/* hint bit-flags */
/* hint bit-flags */
typedef enum
{
PSH3_HINT_GHOST = PS_HINT_FLAG_GHOST,
@ -50,7 +50,7 @@ FT_BEGIN_HEADER
#define psh3_hint_deactivate( x ) (x)->flags &= ~PSH3_HINT_ACTIVE
#define psh3_hint_set_fitted( x ) (x)->flags |= PSH3_HINT_FITTED
/* hint structure */
/* hint structure */
typedef struct PSH3_HintRec_
{
FT_Int org_pos;
@ -105,12 +105,12 @@ FT_BEGIN_HEADER
PSH3_DIR_RIGHT = 2
};
#define PSH3_DIR_HORIZONTAL 2
#define PSH3_DIR_VERTICAL 1
#define PSH3_DIR_HORIZONTAL 2
#define PSH3_DIR_VERTICAL 1
#define PSH3_DIR_COMPARE(d1,d2) ( (d1) == (d2) || (d1) == -(d2) )
#define PSH3_DIR_IS_HORIZONTAL(d) PSH3_DIR_COMPARE(d,PSH3_DIR_HORIZONTAL)
#define PSH3_DIR_IS_VERTICAL(d) PSH3_DIR_COMPARE(d,PSH3_DIR_VERTICAL)
#define PSH3_DIR_COMPARE( d1, d2 ) ( (d1) == (d2) || (d1) == -(d2) )
#define PSH3_DIR_IS_HORIZONTAL( d ) PSH3_DIR_COMPARE( d, PSH3_DIR_HORIZONTAL )
#define PSH3_DIR_IS_VERTICAL( d ) PSH3_DIR_COMPARE( d, PSH3_DIR_VERTICAL )
/* the following bit-flags are computed once by the glyph */
@ -122,33 +122,33 @@ FT_BEGIN_HEADER
PSH3_POINT_INFLEX = 4 /* point is inflection */
};
#define psh3_point_is_smooth( p ) ( (p)->flags & PSH3_POINT_SMOOTH )
#define psh3_point_is_off( p ) ( (p)->flags & PSH3_POINT_OFF )
#define psh3_point_is_inflection( p ) ( (p)->flags & PSH3_POINT_INFLEX )
#define psh3_point_is_smooth( p ) ( (p)->flags & PSH3_POINT_SMOOTH )
#define psh3_point_is_off( p ) ( (p)->flags & PSH3_POINT_OFF )
#define psh3_point_is_inflex( p ) ( (p)->flags & PSH3_POINT_INFLEX )
#define psh3_point_set_smooth( p ) (p)->flags |= PSH3_POINT_SMOOTH
#define psh3_point_set_off( p ) (p)->flags |= PSH3_POINT_OFF
#define psh3_point_set_inflex( p ) (p)->flags |= PSH3_POINT_INFLEX
#define psh3_point_set_smooth( p ) (p)->flags |= PSH3_POINT_SMOOTH
#define psh3_point_set_off( p ) (p)->flags |= PSH3_POINT_OFF
#define psh3_point_set_inflex( p ) (p)->flags |= PSH3_POINT_INFLEX
/* the following bit-flags are re-computed for each dimension */
/* the following bit-flags are re-computed for each dimension */
enum
{
PSH3_POINT_STRONG = 16, /* point is strong */
PSH3_POINT_FITTED = 32, /* point is already fitted */
PSH3_POINT_EXTREMUM = 64, /* point is local extremum */
PSH3_POINT_POSITIVE = 128, /* extremum has positive contour flow */
PSH3_POINT_NEGATIVE = 256, /* extremum has negative contour flow */
PSH3_POINT_EDGE_MIN = 512, /* point is aligned to left/bottom stem edge */
PSH3_POINT_EDGE_MAX = 1024 /* point is aligned to top/right stem edge */
PSH3_POINT_STRONG = 16, /* point is strong */
PSH3_POINT_FITTED = 32, /* point is already fitted */
PSH3_POINT_EXTREMUM = 64, /* point is local extremum */
PSH3_POINT_POSITIVE = 128, /* extremum has positive contour flow */
PSH3_POINT_NEGATIVE = 256, /* extremum has negative contour flow */
PSH3_POINT_EDGE_MIN = 512, /* point is aligned to left/bottom stem edge */
PSH3_POINT_EDGE_MAX = 1024 /* point is aligned to top/right stem edge */
};
#define psh3_point_is_strong( p ) ( (p)->flags2 & PSH3_POINT_STRONG )
#define psh3_point_is_fitted( p ) ( (p)->flags2 & PSH3_POINT_FITTED )
#define psh3_point_is_extremum( p ) ( (p)->flags2 & PSH3_POINT_EXTREMUM )
#define psh3_point_is_positive( p ) ( (p)->flags2 & PSH3_POINT_POSITIVE )
#define psh3_point_is_negative( p ) ( (p)->flags2 & PSH3_POINT_NEGATIVE )
#define psh3_point_is_edge_min( p ) ( (p)->flags2 & PSH3_POINT_EDGE_MIN )
#define psh3_point_is_edge_max( p ) ( (p)->flags2 & PSH3_POINT_EDGE_MAX )
#define psh3_point_is_strong( p ) ( (p)->flags2 & PSH3_POINT_STRONG )
#define psh3_point_is_fitted( p ) ( (p)->flags2 & PSH3_POINT_FITTED )
#define psh3_point_is_extremum( p ) ( (p)->flags2 & PSH3_POINT_EXTREMUM )
#define psh3_point_is_positive( p ) ( (p)->flags2 & PSH3_POINT_POSITIVE )
#define psh3_point_is_negative( p ) ( (p)->flags2 & PSH3_POINT_NEGATIVE )
#define psh3_point_is_edge_min( p ) ( (p)->flags2 & PSH3_POINT_EDGE_MIN )
#define psh3_point_is_edge_max( p ) ( (p)->flags2 & PSH3_POINT_EDGE_MAX )
#define psh3_point_set_strong( p ) (p)->flags2 |= PSH3_POINT_STRONG
#define psh3_point_set_fitted( p ) (p)->flags2 |= PSH3_POINT_FITTED
@ -186,11 +186,11 @@ FT_BEGIN_HEADER
} PSH3_PointRec;
#define PSH3_POINT_EQUAL_ORG(a,b) ( (a)->org_u == (b)->org_u && \
(a)->org_v == (b)->org_v )
#define PSH3_POINT_EQUAL_ORG( a, b ) ( (a)->org_u == (b)->org_u && \
(a)->org_v == (b)->org_v )
#define PSH3_POINT_ANGLE(a,b) FT_Atan2( (b)->org_u - (a)->org_u, \
(b)->org_v - (a)->org_v )
#define PSH3_POINT_ANGLE( a, b ) FT_Atan2( (b)->org_u - (a)->org_u, \
(b)->org_v - (a)->org_v )
typedef struct PSH3_ContourRec_
{