other auto-hinter experiments not worthy of a Changelog entry
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
diff --git a/src/autohint/ahglyph.c b/src/autohint/ahglyph.c
index f809d7e..667f830 100644
--- a/src/autohint/ahglyph.c
+++ b/src/autohint/ahglyph.c
@@ -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;
-
- /* 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;
- }
+ dist = seg2->pos - seg1->pos;
+ if ( dist < 0 )
+ dist = -dist;
+
+ if ( len < 8 )
+ score = 300 + dist;
+ else
+ score = dist + 300/len;
+
+ if ( score < best_score )
+ {
+ best_score = score;
+ best_segment = seg2;
+ }
}
}
diff --git a/src/autohint/ahhint.c b/src/autohint/ahhint.c
index 1e2ebdb..11ace9f 100644
--- a/src/autohint/ahhint.c
+++ b/src/autohint/ahhint.c
@@ -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 )
{
diff --git a/src/autohint/ahtypes.h b/src/autohint/ahtypes.h
index ad12372..6593060 100644
--- a/src/autohint/ahtypes.h
+++ b/src/autohint/ahtypes.h
@@ -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
/*************************************************************************/
diff --git a/src/pshinter/pshalgo2.c b/src/pshinter/pshalgo2.c
index 4eb8978..95f167a 100644
--- a/src/pshinter/pshalgo2.c
+++ b/src/pshinter/pshalgo2.c
@@ -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;
diff --git a/tests/gview.c b/tests/gview.c
index 3bc214f..4c1df37 100644
--- a/tests/gview.c
+++ b/tests/gview.c
@@ -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 );
+ }
+ }
+ }
}
}
}