* src/base/ftcalc.c: Don't use `long long' but `FT_Int64'.

Formatting
This commit is contained in:
Werner Lemberg 2006-11-03 09:40:12 +00:00
parent 91b44e65c2
commit 111b5aefca
10 changed files with 140 additions and 67 deletions

View File

@ -1,14 +1,53 @@
2006-11-03 Werner Lemberg <wl@gnu.org>
* src/base/ftcalc.c: Don't use `long long' but `FT_Int64'.
2006-11-02 David Turner <david@freetype.org>
* src/autofit/aflatin.c: adding a few tweaks to better handle
serif fonts (we now ignore vertical segments that are less than
1 pixels in height, which get rids of *many* corner cases with
serifs)
Add a few tweaks to better handle serif fonts.
Add more debugging messages.
* src/autofit/afhints.c, src/autofit/afmodule.c,
src/autofit/aftypes.h: adding more debug messages and fixing a small
bug in af_compute_direction which produced garbage by missing lots of
segments
* src/autofit/aflatin.c (af_latin_hints_compute_edges): Ignore
segments that are less than 1.5 pixels high. This gets rid of
*many* corner cases with serifs.
(af_latin_align_linked_edge): Add logging message.
(af_latin_hint_edges): Use AF_HINTS_DO_BLUES.
Add logging messages.
Handle AF_EDGE_FLAG flag specially.
* src/autofit/afmodule.c [AF_DEBUG]: Add _af_debug,
_af_debug_disable_blue_hints, and _af_debug_hints variables.
* src/autofit/aftypes.h (AF_LOG) [AF_DEBUG]: Use _af_debug.
Update external declarations.
(af_corner_orientation, af_corner_is_flat): Replaced by...
* include/freetype/internal/ftcalc.h (ft_corner_orientation,
ft_corner_is_flat): These declarations.
* src/autofit/afangles.c (af_corner_orientation, af_corner_is_flat):
Comment out. Replaced by...
* src/base/ftcalc.h (ft_corner_orientation, ft_corner_is_flat):
These functions. Update all callers.
(FT_Add64) [!FT_LONG64]: Simplify.
* src/autofit/afhints.c: Include FT_INTERNAL_CALC_H.
(af_direction_compute): Add a missing FT_ABS call. This bug caused
production of garbage by missing lots of segments.
* src/autofit/afhints.h (AF_HINTS_DO_BLUES): New macro.
* src/autofit/afloader.c (af_loader_init, af_loader_done)
[AF_DEBUG]: Set _af_debug_hints.
* src/pshinter/pshalgo.c: Include FT_INTERNAL_CALC_H.
(psh_corner_is_flat, psh_corner_orientation): Use ft_corner_is_flat
and ft_corner_orientation.
* src/gzip/inftrees.c (huft_build): Remove compiler warning.
2006-10-24 Werner Lemberg <wl@gnu.org>

View File

@ -110,17 +110,18 @@ FT_BEGIN_HEADER
#endif /* TT_USE_BYTECODE_INTERPRETER */
/*
* Return -1, 0, or +1, depending on the orientation of a given corner.
* We use the Cartesian coordinate system, with positive vertical values
* going upwards. The function returns +1 when the corner turns to the
* left, -1 to the right, and 0 for undecided.
* going upwards. The function returns +1 if the corner turns to the
* left, -1 to the right, and 0 for undecidable cases.
*/
FT_BASE( FT_Int )
ft_corner_orientation( FT_Pos in_x,
FT_Pos in_y,
FT_Pos out_x,
FT_Pos out_y );
ft_corner_orientation( FT_Pos in_x,
FT_Pos in_y,
FT_Pos out_x,
FT_Pos out_y );
/*
* Return TRUE if a corner is flat or nearly flat. This is equivalent to
@ -128,10 +129,11 @@ FT_BEGIN_HEADER
* very small.
*/
FT_BASE( FT_Int )
ft_corner_is_flat( FT_Pos in_x,
FT_Pos in_y,
FT_Pos out_x,
FT_Pos out_y );
ft_corner_is_flat( FT_Pos in_x,
FT_Pos in_y,
FT_Pos out_x,
FT_Pos out_y );
#define INT_TO_F26DOT6( x ) ( (FT_Long)(x) << 6 )
#define INT_TO_F2DOT14( x ) ( (FT_Long)(x) << 14 )

View File

@ -19,7 +19,9 @@
#include "aftypes.h"
#if 0
FT_LOCAL_DEF( FT_Int )
af_corner_is_flat( FT_Pos x_in,
FT_Pos y_in,
@ -74,8 +76,10 @@
else
return 1 - 2 * ( delta < 0 );
}
#endif
/*
* We are not using `af_angle_atan' anymore, but we keep the source
* code below just in case...

View File

@ -20,6 +20,7 @@
#include "aferrors.h"
#include FT_INTERNAL_CALC_H
FT_LOCAL_DEF( FT_Error )
af_axis_hints_new_segment( AF_AxisHints axis,
FT_Memory memory,

View File

@ -227,7 +227,7 @@ FT_BEGIN_HEADER
#define AF_HINTS_DO_ADVANCE( h ) \
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_ADVANCE )
#define AF_HINTS_DO_BLUES( h ) ( !_af_debug_disable_blue_hints )
#define AF_HINTS_DO_BLUES( h ) ( !_af_debug_disable_blue_hints )
#else /* !AF_DEBUG */
@ -240,7 +240,7 @@ FT_BEGIN_HEADER
#define AF_HINTS_DO_ADVANCE( h ) \
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_ADVANCE )
#define AF_HINTS_DO_BLUES( h ) 1
#define AF_HINTS_DO_BLUES( h ) 1
#endif /* !AF_DEBUG */

View File

@ -960,10 +960,10 @@
up_dir = ( dim == AF_DIMENSION_HORZ ) ? AF_DIR_UP
: AF_DIR_RIGHT;
/* we want to ignore all segments that are less than 1.5
* pixels in length, to avoid many problems with serif
* fonts. we compute the corresponding threshold in font
* units
/*
* We ignore all segments that are less than 1.5 pixels in length,
* to avoid many problems with serif fonts. We compute the
* corresponding threshold in font units.
*/
if ( dim == AF_DIMENSION_VERT )
segment_length_threshold = FT_DivFix( 64, hints->y_scale );
@ -999,6 +999,7 @@
AF_Edge found = 0;
FT_Int ee;
if ( seg->max_coord - seg->min_coord < segment_length_threshold )
continue;
@ -1119,10 +1120,11 @@
/* check for links -- if seg->serif is set, then seg->link must */
/* be ignored */
is_serif = (FT_Bool)( seg->serif && seg->serif->edge &&
is_serif = (FT_Bool)( seg->serif &&
seg->serif->edge &&
seg->serif->edge != edge );
if ( (seg->link && seg->link->edge != NULL) || is_serif )
if ( ( seg->link && seg->link->edge != NULL ) || is_serif )
{
AF_Edge edge2;
AF_Segment seg2;
@ -1600,11 +1602,13 @@
(AF_Edge_Flags)base_edge->flags,
(AF_Edge_Flags)stem_edge->flags );
stem_edge->pos = base_edge->pos + fitted_width;
AF_LOG(( "LINK: edge %d (opos=%.2f) linked to (%.2f), dist was %.2f now %.2f\n",
stem_edge-hints->axis[dim].edges, stem_edge->opos/64.0,
stem_edge->pos/64.0, dist/64., fitted_width/64. ));
AF_LOG(( "LINK: edge %d (opos=%.2f) linked to (%.2f), "
"dist was %.2f, now %.2f\n",
stem_edge-hints->axis[dim].edges, stem_edge->opos / 64.0,
stem_edge->pos / 64.0, dist / 64.0, fitted_width / 64.0 ));
}
@ -1646,7 +1650,7 @@
/* we begin by aligning all stems relative to the blue zone */
/* if needed -- that's only for horizontal edges */
if ( dim == AF_DIMENSION_VERT && AF_HINTS_DO_BLUES(hints) )
if ( dim == AF_DIMENSION_VERT && AF_HINTS_DO_BLUES( hints ) )
{
for ( edge = edges; edge < edge_limit; edge++ )
{
@ -1675,8 +1679,11 @@
if ( !edge1 )
continue;
AF_LOG(( "BLUE: edge %d (opos=%.2f) snapped to (%.2f) was (%.2f)\n",
edge1-edges, edge1->opos/64., blue->fit/64., edge1->pos/64.0 ));
AF_LOG(( "BLUE: edge %d (opos=%.2f) snapped to (%.2f), "
"was (%.2f)\n",
edge1-edges, edge1->opos / 64.0, blue->fit / 64.0,
edge1->pos / 64.0 ));
edge1->pos = blue->fit;
edge1->flags |= AF_EDGE_DONE;
@ -1714,7 +1721,8 @@
/* this should not happen, but it's better to be safe */
if ( edge2->blue_edge || edge2 < edge )
{
AF_LOG(( "ASSERT FAILED for edge %d\n", edge2-edges ));
AF_LOG(( "ASSERTION FAILED for edge %d\n", edge2-edges ));
af_latin_align_linked_edge( hints, dim, edge2, edge );
edge->flags |= AF_EDGE_DONE;
continue;
@ -1766,7 +1774,7 @@
edge->pos = FT_PIX_ROUND( edge->opos );
AF_LOG(( "ANCHOR: edge %d (opos=%.2f) snapped to (%.2f)\n",
edge-edges, edge->opos/64., edge->pos/64. ));
edge-edges, edge->opos / 64.0, edge->pos / 64.0 ));
anchor = edge;
edge->flags |= AF_EDGE_DONE;
@ -1789,9 +1797,8 @@
(AF_Edge_Flags)edge2->flags );
if ( edge2->flags & AF_EDGE_DONE )
{
edge->pos = edge2->pos - cur_len;
}
edge->pos = edge2->pos - cur_len;
else if ( cur_len < 96 )
{
FT_Pos u_off, d_off;
@ -1822,10 +1829,14 @@
edge->pos = cur_pos1 - cur_len / 2;
edge2->pos = cur_pos1 + cur_len / 2;
AF_LOG(( "STEM: %d (opos=%.2f) to %d (opos=%.2f) snapped to (%.2f) and (%.2f)\n",
edge-edges, edge->opos/64., edge2-edges, edge2->opos/64.,
edge->pos/64., edge2->pos/64. ));
AF_LOG(( "STEM: %d (opos=%.2f) to %d (opos=%.2f) "
"snapped to (%.2f) and (%.2f)\n",
edge-edges, edge->opos / 64.0,
edge2-edges, edge2->opos / 64.0,
edge->pos / 64.0, edge2->pos / 64.0 ));
}
else
{
org_pos = anchor->pos + ( edge->opos - anchor->opos );
@ -1850,9 +1861,11 @@
edge->pos = ( delta1 < delta2 ) ? cur_pos1 : cur_pos2;
edge2->pos = edge->pos + cur_len;
AF_LOG(( "STEM: %d (opos=%.2f) to %d (opos=%.2f) snapped to (%.2f) and (%.2f)\n",
edge-edges, edge->opos/64., edge2-edges, edge2->opos/64.,
edge->pos/64., edge2->pos/64. ));
AF_LOG(( "STEM: %d (opos=%.2f) to %d (opos=%.2f) "
"snapped to (%.2f) and (%.2f)\n",
edge-edges, edge->opos / 64.0,
edge2-edges, edge2->opos / 64.0,
edge->pos / 64.0, edge2->pos / 64.0 ));
}
edge->flags |= AF_EDGE_DONE;
@ -1860,8 +1873,8 @@
if ( edge > edges && edge->pos < edge[-1].pos )
{
AF_LOG(( "BOUND: %d (pos=%.2f) to (%.2f)\n", edge-edges,
edge->pos/64., edge[-1].pos/64. ));
AF_LOG(( "BOUND: %d (pos=%.2f) to (%.2f)\n",
edge-edges, edge->pos / 64.0, edge[-1].pos / 64.0 ));
edge->pos = edge[-1].pos;
}
}

View File

@ -4,7 +4,7 @@
/* */
/* Auto-fitter module implementation (body). */
/* */
/* Copyright 2003, 2004, 2005 by */
/* Copyright 2003, 2004, 2005, 2006 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -20,10 +20,10 @@
#include "afloader.h"
#ifdef AF_DEBUG
int _af_debug;
int _af_debug_disable_horz_hints;
int _af_debug_disable_vert_hints;
int _af_debug_disable_blue_hints;
int _af_debug;
int _af_debug_disable_horz_hints;
int _af_debug_disable_vert_hints;
int _af_debug_disable_blue_hints;
void* _af_debug_hints;
#endif

View File

@ -58,18 +58,18 @@ FT_BEGIN_HEADER
#ifdef AF_DEBUG
# include <stdio.h>
# define AF_LOG( x ) do { if (_af_debug) printf x ; } while (0)
#include <stdio.h>
#define AF_LOG( x ) do { if ( _af_debug ) printf x; } while ( 0 )
extern int _af_debug;
extern int _af_debug_disable_horz_hints;
extern int _af_debug_disable_vert_hints;
extern int _af_debug_disable_blue_hints;
extern int _af_debug;
extern int _af_debug_disable_horz_hints;
extern int _af_debug_disable_vert_hints;
extern int _af_debug_disable_blue_hints;
extern void* _af_debug_hints;
#else /* !AF_DEBUG */
# define AF_LOG( x ) do ; while ( 0 ) /* nothing */
#define AF_LOG( x ) do ; while ( 0 ) /* nothing */
#endif /* !AF_DEBUG */

View File

@ -228,7 +228,7 @@
}
#else /* FT_LONG64 */
#else /* !FT_LONG64 */
static void
@ -305,8 +305,8 @@
register FT_UInt32 lo, hi;
lo = x->lo + y->lo;
hi = x->hi + y->hi + ( lo < x->lo );
lo = x->lo + y->lo;
hi = x->hi + y->hi + ( lo < x->lo );
z->lo = lo;
z->hi = hi;
@ -684,12 +684,13 @@
}
/* documentation is in ftcalc.h */
FT_BASE_DEF( FT_Int )
ft_corner_orientation( FT_Pos in_x,
FT_Pos in_y,
FT_Pos out_x,
FT_Pos out_y )
ft_corner_orientation( FT_Pos in_x,
FT_Pos in_y,
FT_Pos out_x,
FT_Pos out_y )
{
FT_Int result;
@ -725,15 +726,21 @@
}
else /* general case */
{
#ifdef FT_LONG64
FT_Int64 delta = (long long)in_x * out_y - (long long)in_y * out_x;
FT_Int64 delta = (FT_Int64)in_x * out_y - (FT_Int64)in_y * out_x;
if ( delta == 0 )
result = 0;
else
result = 1 - 2 * ( delta < 0 );
#else
FT_Int64 z1, z2;
FT_Int64 z1, z2;
ft_multo64( in_x, out_y, &z1 );
ft_multo64( in_y, out_x, &z2 );
@ -748,6 +755,7 @@
result = -1;
else
result = 0;
#endif
}
@ -755,6 +763,8 @@
}
/* documentation is in ftcalc.h */
FT_BASE_DEF( FT_Int )
ft_corner_is_flat( FT_Pos in_x,
FT_Pos in_y,
@ -791,4 +801,6 @@
return ( d_in + d_out - d_corner ) < ( d_corner >> 4 );
}
/* END */

View File

@ -886,6 +886,7 @@
#define psh_corner_orientation ft_corner_orientation
#else
FT_LOCAL_DEF( FT_Int )
psh_corner_is_flat( FT_Pos x_in,
FT_Pos y_in,
@ -974,7 +975,8 @@
return result;
}
#endif
#endif /* !1 */
#ifdef COMPUTE_INFLEXS