* src/autofit/afhints.c, src/autofit/afhints.h, src/autofit/aflatin.c,
src/autofit/afloader.c, src/types.h: grave bugs were fixed. The auto-fitter works, doesn't crashes, but still produces unexpected results !!
This commit is contained in:
parent
4cb09724a3
commit
1029ed26af
|
@ -4,54 +4,51 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
static const char* af_dir_str( AF_Direction dir )
|
||||
{
|
||||
const char* result;
|
||||
|
||||
switch (dir)
|
||||
{
|
||||
case AF_DIR_UP: result = "up"; break;
|
||||
case AF_DIR_DOWN: result = "down"; break;
|
||||
case AF_DIR_LEFT: result = "left"; break;
|
||||
case AF_DIR_RIGHT: result = "right"; break;
|
||||
default: result = "none";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#define AF_INDEX_NUM(ptr,base) ( (ptr) ? ((ptr)-(base)) : -1 )
|
||||
|
||||
void
|
||||
af_glyph_hints_dump_edges( AF_GlyphHints hints )
|
||||
af_glyph_hints_dump_points( AF_GlyphHints hints )
|
||||
{
|
||||
AF_Edge edges;
|
||||
AF_Edge edge_limit;
|
||||
AF_Segment segments;
|
||||
FT_Int dimension;
|
||||
AF_Point points = hints->points;
|
||||
AF_Point limit = points + hints->num_points;
|
||||
AF_Point point;
|
||||
|
||||
|
||||
edges = hints->horz_edges;
|
||||
edge_limit = edges + hints->num_hedges;
|
||||
segments = hints->horz_segments;
|
||||
|
||||
for ( dimension = 1; dimension >= 0; dimension-- )
|
||||
printf( "Table of points:\n" );
|
||||
printf( " [ index | xorg | yorg | xscale | yscale | xfit | yfit | flags ]\n" );
|
||||
for ( point = points; point < limit; point++ )
|
||||
{
|
||||
AF_Edge edge;
|
||||
|
||||
|
||||
printf ( "Table of %s edges:\n",
|
||||
!dimension ? "vertical" : "horizontal" );
|
||||
printf ( " [ index | pos | dir | link |"
|
||||
" serif | blue | opos | pos ]\n" );
|
||||
|
||||
for ( edge = edges; edge < edge_limit; edge++ )
|
||||
{
|
||||
printf ( " [ %5d | %4d | %5s | %4d | %5d | %c | %5.2f | %5.2f ]\n",
|
||||
edge - edges,
|
||||
(int)edge->fpos,
|
||||
edge->dir == AF_DIR_UP
|
||||
? "up"
|
||||
: ( edge->dir == AF_DIR_DOWN
|
||||
? "down"
|
||||
: ( edge->dir == AF_DIR_LEFT
|
||||
? "left"
|
||||
: ( edge->dir == AF_DIR_RIGHT
|
||||
? "right"
|
||||
: "none" ) ) ),
|
||||
edge->link ? ( edge->link - edges ) : -1,
|
||||
edge->serif ? ( edge->serif - edges ) : -1,
|
||||
edge->blue_edge ? 'y' : 'n',
|
||||
edge->opos / 64.0,
|
||||
edge->pos / 64.0 );
|
||||
}
|
||||
|
||||
edges = hints->vert_edges;
|
||||
edge_limit = edges + hints->num_vedges;
|
||||
segments = hints->vert_segments;
|
||||
printf( " [ %5d | %5d | %5d | %-5.2f | %-5.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" );
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,52 +56,78 @@
|
|||
void
|
||||
af_glyph_hints_dump_segments( AF_GlyphHints hints )
|
||||
{
|
||||
AF_Segment segments;
|
||||
AF_Segment segment_limit;
|
||||
AF_Point points;
|
||||
AF_Point points = hints->points;
|
||||
FT_Int dimension;
|
||||
|
||||
|
||||
points = hints->points;
|
||||
segments = hints->horz_segments;
|
||||
segment_limit = segments + hints->num_hsegments;
|
||||
|
||||
for ( dimension = 1; dimension >= 0; dimension-- )
|
||||
{
|
||||
AF_AxisHints axis = &hints->axis[dimension];
|
||||
AF_Segment segments = axis->segments;
|
||||
AF_Segment limit = segments + axis->num_segments;
|
||||
AF_Segment seg;
|
||||
|
||||
|
||||
printf ( "Table of %s segments:\n",
|
||||
!dimension ? "vertical" : "horizontal" );
|
||||
dimension == AF_DIMENSION_HORZ ? "vertical" : "horizontal" );
|
||||
printf ( " [ index | pos | dir | link | serif |"
|
||||
" numl | first | start ]\n" );
|
||||
|
||||
for ( seg = segments; seg < segment_limit; seg++ )
|
||||
for ( seg = segments; seg < limit; seg++ )
|
||||
{
|
||||
printf ( " [ %5d | %4d | %5s | %4d | %5d | %4d | %5d | %5d ]\n",
|
||||
seg - segments,
|
||||
(int)seg->pos,
|
||||
seg->dir == AF_DIR_UP
|
||||
? "up"
|
||||
: ( seg->dir == AF_DIR_DOWN
|
||||
? "down"
|
||||
: ( seg->dir == AF_DIR_LEFT
|
||||
? "left"
|
||||
: ( seg->dir == AF_DIR_RIGHT
|
||||
? "right"
|
||||
: "none" ) ) ),
|
||||
seg->link ? ( seg->link - segments ) : -1,
|
||||
seg->serif ? ( seg->serif - segments ) : -1,
|
||||
af_dir_str( seg->dir ),
|
||||
AF_INDEX_NUM( seg->link, segments ),
|
||||
AF_INDEX_NUM( seg->serif, segments ),
|
||||
(int)seg->num_linked,
|
||||
seg->first - points,
|
||||
seg->last - points );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
segments = hints->vert_segments;
|
||||
segment_limit = segments + hints->num_vsegments;
|
||||
|
||||
void
|
||||
af_glyph_hints_dump_edges( AF_GlyphHints hints )
|
||||
{
|
||||
FT_Int dimension;
|
||||
|
||||
for ( dimension = 1; dimension >= 0; dimension-- )
|
||||
{
|
||||
AF_AxisHints axis = &hints->axis[ dimension ];
|
||||
AF_Edge edges = axis->edges;
|
||||
AF_Edge limit = edges + axis->num_edges;
|
||||
AF_Edge edge;
|
||||
|
||||
/* note: AF_DIMENSION_HORZ corresponds to _vertical_ edges
|
||||
* since they have constant X coordinate
|
||||
*/
|
||||
printf ( "Table of %s edges:\n",
|
||||
dimension == AF_DIMENSION_HORZ ? "vertical" : "horizontal" );
|
||||
printf ( " [ index | pos | dir | link |"
|
||||
" serif | blue | opos | pos ]\n" );
|
||||
|
||||
for ( edge = edges; edge < limit; edge++ )
|
||||
{
|
||||
printf ( " [ %5d | %4d | %5s | %4d | %5d | %c | %5.2f | %5.2f ]\n",
|
||||
edge - edges,
|
||||
(int)edge->fpos,
|
||||
af_dir_str( 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 );
|
||||
}
|
||||
|
||||
printf( "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* AF_DEBUG */
|
||||
|
||||
|
||||
|
@ -294,6 +317,7 @@
|
|||
FT_LOCAL_DEF( FT_Error )
|
||||
af_glyph_hints_reset( AF_GlyphHints hints,
|
||||
AF_Scaler scaler,
|
||||
AF_ScriptMetrics metrics,
|
||||
FT_Outline* outline )
|
||||
{
|
||||
FT_Error error = FT_Err_Ok;
|
||||
|
@ -305,6 +329,8 @@
|
|||
FT_Pos y_delta = scaler->y_delta;
|
||||
FT_Memory memory = hints->memory;
|
||||
|
||||
hints->metrics = metrics;
|
||||
|
||||
hints->scaler_flags = scaler->flags;
|
||||
hints->other_flags = 0;
|
||||
|
||||
|
@ -351,12 +377,16 @@
|
|||
|
||||
new_max = ( new_max + 2 + 7 ) & ~7;
|
||||
|
||||
#define OFF_PAD2(x,y) (((x)+(y)-1) & ~((y)-1))
|
||||
#define OFF_PADX(x,y) ((((x)+(y)-1)/(y))*(y))
|
||||
#define OFF_PAD(x,y) ( ((y) & ((y)-1)) ? OFF_PADX(x,y) : OFF_PAD2(x,y) )
|
||||
|
||||
#undef OFF_INCREMENT
|
||||
#define OFF_INCREMENT( _off, _type, _count ) \
|
||||
( FT_PAD_CEIL( _off, sizeof(_type) ) + (_count)*sizeof(_type))
|
||||
( OFF_PAD( _off, sizeof(_type) ) + (_count)*sizeof(_type))
|
||||
|
||||
off1 = OFF_INCREMENT( 0, AF_PointRec, new_max );
|
||||
off2 = OFF_INCREMENT( off1, AF_SegmentRec, new_max );
|
||||
off2 = OFF_INCREMENT( off1, AF_SegmentRec, new_max*2 );
|
||||
off3 = OFF_INCREMENT( off2, AF_EdgeRec, new_max*2 );
|
||||
|
||||
FT_FREE( hints->points );
|
||||
|
@ -549,6 +579,28 @@
|
|||
}
|
||||
|
||||
|
||||
FT_LOCAL_DEF( void )
|
||||
af_glyph_hints_save( AF_GlyphHints hints,
|
||||
FT_Outline* outline )
|
||||
{
|
||||
AF_Point point = hints->points;
|
||||
AF_Point limit = point + hints->num_points;
|
||||
FT_Vector* vec = outline->points;
|
||||
char* tag = outline->tags;
|
||||
|
||||
for ( ; point < limit; point++, vec++, tag++ )
|
||||
{
|
||||
vec->x = (FT_Pos) point->x;
|
||||
vec->y = (FT_Pos) point->y;
|
||||
|
||||
if ( point->flags & AF_FLAG_CONIC )
|
||||
tag[0] = FT_CURVE_TAG_CONIC;
|
||||
else if ( point->flags & AF_FLAG_CUBIC )
|
||||
tag[0] = FT_CURVE_TAG_CUBIC;
|
||||
else
|
||||
tag[0] = FT_CURVE_TAG_ON;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -217,6 +217,11 @@ FT_BEGIN_HEADER
|
|||
FT_LOCAL( FT_Error )
|
||||
af_glyph_hints_reset( AF_GlyphHints hints,
|
||||
AF_Scaler scaler,
|
||||
AF_ScriptMetrics metrics,
|
||||
FT_Outline* outline );
|
||||
|
||||
FT_LOCAL( void )
|
||||
af_glyph_hints_save( AF_GlyphHints hints,
|
||||
FT_Outline* outline );
|
||||
|
||||
FT_LOCAL( void )
|
||||
|
|
|
@ -42,7 +42,9 @@
|
|||
scaler->render_mode = 0;
|
||||
scaler->flags = 0;
|
||||
|
||||
error = af_glyph_hints_reset( hints, scaler, &face->glyph->outline );
|
||||
error = af_glyph_hints_reset( hints, scaler,
|
||||
(AF_ScriptMetrics) metrics,
|
||||
&face->glyph->outline );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
|
@ -143,7 +145,7 @@
|
|||
FT_Pos* blue_ref;
|
||||
FT_Pos* blue_shoot;
|
||||
|
||||
AF_LOG(( "blue %3d: ", blue ));
|
||||
AF_LOG(( "blue %3d: ", bb ));
|
||||
|
||||
num_flats = 0;
|
||||
num_rounds = 0;
|
||||
|
@ -329,7 +331,7 @@
|
|||
}
|
||||
|
||||
|
||||
static FT_Error
|
||||
FT_LOCAL_DEF( FT_Error )
|
||||
af_latin_metrics_init( AF_LatinMetrics metrics,
|
||||
FT_Face face )
|
||||
{
|
||||
|
@ -868,7 +870,7 @@
|
|||
edge_limit++;
|
||||
|
||||
/* clear all edge fields */
|
||||
FT_MEM_ZERO( edge, sizeof ( *edge ) );
|
||||
FT_ZERO( edge );
|
||||
|
||||
/* add the segment to the new edge's list */
|
||||
edge->first = seg;
|
||||
|
@ -1144,7 +1146,9 @@
|
|||
FT_Error error;
|
||||
FT_Render_Mode mode;
|
||||
|
||||
error = af_glyph_hints_reset( hints, &metrics->scaler, outline );
|
||||
error = af_glyph_hints_reset( hints, &metrics->scaler,
|
||||
(AF_ScriptMetrics) metrics,
|
||||
outline );
|
||||
if (error)
|
||||
goto Exit;
|
||||
|
||||
|
@ -1733,6 +1737,7 @@
|
|||
|
||||
static FT_Error
|
||||
af_latin_hints_apply( AF_GlyphHints hints,
|
||||
FT_Outline* outline,
|
||||
AF_LatinMetrics metrics )
|
||||
{
|
||||
AF_Dimension dim;
|
||||
|
@ -1750,6 +1755,8 @@
|
|||
af_glyph_hints_align_weak_points( hints, dim );
|
||||
}
|
||||
}
|
||||
af_glyph_hints_save( hints, outline );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,9 +34,10 @@
|
|||
FT_Error error = 0;
|
||||
|
||||
loader->face = face;
|
||||
loader->gloader = face->glyph->internal->loader;
|
||||
loader->globals = (AF_FaceGlobals) face->autohint.data;
|
||||
|
||||
FT_GlyphLoader_Rewind( loader->gloader );
|
||||
|
||||
if ( loader->globals == NULL )
|
||||
{
|
||||
error = af_face_globals_new( face, &loader->globals );
|
||||
|
@ -124,6 +125,10 @@
|
|||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
FT_ARRAY_COPY( gloader->current.outline.points,
|
||||
slot->outline.points,
|
||||
slot->outline.n_points );
|
||||
|
||||
FT_ARRAY_COPY( gloader->current.extra_points,
|
||||
slot->outline.points,
|
||||
slot->outline.n_points );
|
||||
|
@ -367,12 +372,12 @@
|
|||
slot->metrics.horiAdvance = FT_PIX_ROUND( slot->metrics.horiAdvance );
|
||||
|
||||
/* now copy outline into glyph slot */
|
||||
FT_GlyphLoader_Rewind( loader->gloader );
|
||||
error = FT_GlyphLoader_CopyPoints( loader->gloader, gloader );
|
||||
FT_GlyphLoader_Rewind( internal->loader );
|
||||
error = FT_GlyphLoader_CopyPoints( internal->loader, gloader );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
slot->outline = slot->internal->loader->base.outline;
|
||||
slot->outline = internal->loader->base.outline;
|
||||
slot->format = FT_GLYPH_FORMAT_OUTLINE;
|
||||
}
|
||||
|
||||
|
@ -419,6 +424,8 @@
|
|||
error = af_face_globals_get_metrics( loader->globals, gindex, &metrics );
|
||||
if ( !error )
|
||||
{
|
||||
loader->metrics = metrics;
|
||||
|
||||
metrics->clazz->script_metrics_scale( metrics, &scaler );
|
||||
|
||||
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM;
|
||||
|
|
|
@ -17,12 +17,12 @@ FT_BEGIN_HEADER
|
|||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#define xxAF_DEBUG
|
||||
#define AF_DEBUG
|
||||
|
||||
#ifdef AF_DEBUG
|
||||
|
||||
# include <stdio.h>
|
||||
# define AF_LOG( x ) printf ## x
|
||||
# define AF_LOG( x ) printf x
|
||||
|
||||
#else
|
||||
|
||||
|
|
Loading…
Reference in New Issue