other auto-hinter experiments not worthy of a Changelog entry
This commit is contained in:
parent
b92479b8c2
commit
9d7e5e8b8b
|
@ -29,7 +29,6 @@
|
|||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
#ifdef AH_DEBUG
|
||||
|
||||
void
|
||||
|
@ -40,7 +39,6 @@
|
|||
AH_Segment* segments;
|
||||
FT_Int dimension;
|
||||
|
||||
|
||||
edges = outline->horz_edges;
|
||||
edge_limit = edges + outline->num_hedges;
|
||||
segments = outline->horz_segments;
|
||||
|
@ -938,19 +936,23 @@
|
|||
AH_Segment* seg1;
|
||||
AH_Segment* seg2;
|
||||
|
||||
|
||||
/* now compare each segment to the others */
|
||||
for ( seg1 = segments; seg1 < segment_limit; seg1++ )
|
||||
{
|
||||
FT_Pos best_score = 32000;
|
||||
AH_Segment* best_segment = 0;
|
||||
|
||||
FT_Pos best_score;
|
||||
AH_Segment* best_segment;
|
||||
|
||||
/* the fake segments are introduced to hint the metrics -- */
|
||||
/* we must never link them to anything */
|
||||
if ( seg1->first == seg1->last )
|
||||
continue;
|
||||
|
||||
best_segment = seg1->link;
|
||||
if ( best_segment )
|
||||
best_score = seg1->score;
|
||||
else
|
||||
best_score = 32000;
|
||||
|
||||
for ( seg2 = segments; seg2 < segment_limit; seg2++ )
|
||||
if ( seg1 != seg2 && seg1->dir + seg2->dir == 0 )
|
||||
{
|
||||
|
@ -970,17 +972,10 @@
|
|||
if ( pos1 == pos2 || !(is_dir ^ is_pos) )
|
||||
continue;
|
||||
|
||||
/* Check the two segments. We now have a better algorithm */
|
||||
/* that doesn't rely on the segment points themselves but */
|
||||
/* on their relative position. This gets rids of many */
|
||||
/* unpleasant artefacts and incorrect stem/serifs */
|
||||
/* computations. */
|
||||
|
||||
/* first of all, compute the size of the `common' height */
|
||||
{
|
||||
FT_Pos min = seg1->min_coord;
|
||||
FT_Pos max = seg1->max_coord;
|
||||
FT_Pos len, score;
|
||||
FT_Pos len, dist, score;
|
||||
FT_Pos size1, size2;
|
||||
|
||||
|
||||
|
@ -990,22 +985,24 @@
|
|||
if ( min < seg2->min_coord )
|
||||
min = seg2->min_coord;
|
||||
|
||||
if ( max < seg2->max_coord )
|
||||
if ( max > seg2->max_coord )
|
||||
max = seg2->max_coord;
|
||||
|
||||
len = max - min;
|
||||
score = seg2->pos - seg1->pos;
|
||||
if ( score < 0 )
|
||||
score = -score;
|
||||
dist = seg2->pos - seg1->pos;
|
||||
if ( dist < 0 )
|
||||
dist = -dist;
|
||||
|
||||
/* before comparing the scores, take care that the segments */
|
||||
/* are really facing each other (often not for italics..) */
|
||||
if ( 16 * len >= size1 && 16 * len >= size2 )
|
||||
if ( score < best_score )
|
||||
{
|
||||
best_score = score;
|
||||
best_segment = seg2;
|
||||
}
|
||||
if ( len < 8 )
|
||||
score = 300 + dist;
|
||||
else
|
||||
score = dist + 300/len;
|
||||
|
||||
if ( score < best_score )
|
||||
{
|
||||
best_score = score;
|
||||
best_segment = seg2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,8 @@
|
|||
static void
|
||||
ah_align_serif_edge( AH_Hinter* hinter,
|
||||
AH_Edge* base,
|
||||
AH_Edge* serif )
|
||||
AH_Edge* serif,
|
||||
int vertical )
|
||||
{
|
||||
FT_Pos dist;
|
||||
FT_Pos sign = 1;
|
||||
|
@ -167,10 +168,10 @@
|
|||
/* do not strengthen serifs */
|
||||
if ( base->flags & ah_edge_done )
|
||||
{
|
||||
if ( dist > 64 )
|
||||
dist = ( dist + 16 ) & -64;
|
||||
if ( dist >= 64 )
|
||||
dist = ( dist + 8 ) & -64;
|
||||
|
||||
else if ( dist <= 32 )
|
||||
else if ( dist <= 32 && !vertical )
|
||||
dist = ( dist + 33 ) >> 1;
|
||||
}
|
||||
|
||||
|
@ -257,8 +258,8 @@
|
|||
|
||||
if ( !anchor )
|
||||
anchor = edge;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* now, we will align all stem edges, trying to maintain the */
|
||||
/* relative order of stems in the glyph.. */
|
||||
|
@ -343,7 +344,7 @@
|
|||
|
||||
if ( edge->serif )
|
||||
{
|
||||
ah_align_serif_edge( hinter, edge->serif, edge );
|
||||
ah_align_serif_edge( hinter, edge->serif, edge, dimension );
|
||||
}
|
||||
else if ( !anchor )
|
||||
{
|
||||
|
|
|
@ -83,7 +83,7 @@ FT_BEGIN_HEADER
|
|||
/* detected and later hinted through strong interpolation to correct */
|
||||
/* some unpleasant artefacts. */
|
||||
/* */
|
||||
#define AH_OPTION_NO_STRONG_INTERPOLATION
|
||||
#undef AH_OPTION_NO_STRONG_INTERPOLATION
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
|
|
|
@ -308,7 +308,7 @@
|
|||
|
||||
#ifdef DEBUG_HINTER
|
||||
static void
|
||||
ps_simple_scale( PSH2_Hint_Table table,
|
||||
ps2_simple_scale( PSH2_Hint_Table table,
|
||||
FT_Fixed scale,
|
||||
FT_Fixed delta,
|
||||
FT_Int vertical )
|
||||
|
@ -466,13 +466,13 @@
|
|||
|
||||
if ( ps_debug_no_vert_hints && vertical )
|
||||
{
|
||||
ps_simple_scale( table, scale, delta, vertical );
|
||||
ps2_simple_scale( table, scale, delta, vertical );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ps_debug_no_horz_hints && !vertical )
|
||||
{
|
||||
ps_simple_scale( table, scale, delta, vertical );
|
||||
ps2_simple_scale( table, scale, delta, vertical );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -1435,6 +1435,9 @@
|
|||
|
||||
memory = globals->memory;
|
||||
|
||||
FT_UNUSED(glyphrec);
|
||||
|
||||
|
||||
#ifdef DEBUG_HINTER
|
||||
if ( ps2_debug_glyph )
|
||||
{
|
||||
|
@ -1449,7 +1452,7 @@
|
|||
#else
|
||||
glyph = &glyphrec;
|
||||
#endif
|
||||
|
||||
|
||||
error = psh2_glyph_init( glyph, outline, ps_hints, globals );
|
||||
if (error) goto Exit;
|
||||
|
||||
|
|
|
@ -858,6 +858,42 @@ ah_draw_edges( void )
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( option_show_horz_hints && option_show_links )
|
||||
{
|
||||
AH_Segment* seg = glyph->horz_segments;
|
||||
FT_UInt count = glyph->num_hsegments;
|
||||
|
||||
for ( ; count > 0; count--, seg++ )
|
||||
{
|
||||
AH_Segment* seg2 = NULL;
|
||||
NV_Path link;
|
||||
NV_Vector v1, v2;
|
||||
|
||||
if ( seg->link )
|
||||
{
|
||||
if ( seg->link > seg )
|
||||
seg2 = seg->link;
|
||||
}
|
||||
else if ( seg->serif )
|
||||
seg2 = seg->serif;
|
||||
|
||||
if ( seg2 )
|
||||
{
|
||||
v1.y = seg->first->y;
|
||||
v2.y = seg2->first->y;
|
||||
v1.x = (seg->first->x + seg->last->x)/2 - pp1;
|
||||
v2.x = (seg2->first->x + seg2->last->x)/2 - pp1;
|
||||
|
||||
link = ah_link_path( &v1, &v2, 0 );
|
||||
|
||||
nv_painter_set_color( painter, seg->serif ? SERIF_LINK_COLOR : LINK_COLOR, 256 );
|
||||
nv_painter_fill_path( painter, &size_transform, 0, link );
|
||||
|
||||
nv_path_destroy( link );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue