fix bug #19565, which was caused by an incorrect segment link computation
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
diff --git a/ChangeLog b/ChangeLog
index 3e3020b..2c71503 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2007-06-11 David Turner <david@freetype.org>
+ * src/autofit/aflatin,c: fix incorrect segment linking computation,
+ this was the root cause of bug #19565.
+
+
* src/autofit/*: some very experimental changes to improve the Latin
auto-hinter. note that the new code is disabled by default since this
is not stablizied yet.
diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c
index 84c5f67..6cb670e 100644
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -843,11 +843,11 @@
{
/* the fake segments are introduced to hint the metrics -- */
/* we must never link them to anything */
- if ( seg1->first == seg1->last )
+ if ( seg1->dir != axis->major_dir || seg1->first == seg1->last )
continue;
- for ( seg2 = seg1 + 1; seg2 < segment_limit; seg2++ )
- if ( seg1->dir + seg2->dir == 0 )
+ for ( seg2 = segments; seg2 < segment_limit; seg2++ )
+ if ( seg1->dir + seg2->dir == 0 && seg2->pos > seg1->pos )
{
FT_Pos pos1 = seg1->pos;
FT_Pos pos2 = seg2->pos;
diff --git a/src/autofit/aflatin2.c b/src/autofit/aflatin2.c
index abf51c6..0f0ffc6 100644
--- a/src/autofit/aflatin2.c
+++ b/src/autofit/aflatin2.c
@@ -902,7 +902,7 @@
continue;
for ( seg2 = segments; seg2 < segment_limit; seg2++ )
- if ( seg1->dir + seg2->dir == 0 )
+ if ( seg1->dir + seg2->dir == 0 && seg2->pos > seg1->pos )
#endif
{
FT_Pos pos1 = seg1->pos;
@@ -1940,24 +1940,26 @@
/* we want to avoid the absolute worst case which is
* when the left and right edges of the span each represent
* about 50% of the gray. we'd better want to change this
- * to 25/75%, since this is much more pleasant to the eye with
+ * to 20/80%, since this is much more pleasant to the eye with
* very acceptable distortion
*/
FT_Pos frac_left = (org_left) & 63;
FT_Pos frac_right = (org_right) & 63;
- if (frac_left >= 20 && frac_left <= 44)
+ if ( frac_left >= 22 && frac_left <= 42 &&
+ frac_right >= 22 && frac_right <= 42 )
{
- FT_Pos ref = (frac_left <= 32) ? 16 : 48;
- displacements[count] = delta = ref - frac_left;
- scores[count++] = FT_ABS(delta) + 8;
- }
-
- if (frac_right >= 20 && frac_right <= 44)
- {
- FT_Pos ref = (frac_right < 32) ? 16 : 48;
- displacements[count] = delta = ref - frac_right;
- scores[count++] = FT_ABS(delta) + 8;
+ org = frac_left;
+ fit = (org <= 32) ? 13 : 51;
+ delta = FT_ABS(fit - org);
+ displacements[count] = fit - org;
+ scores[count++] = delta;
+
+ org = frac_right;
+ fit = (org <= 32) ? 13 : 51;
+ delta = FT_ABS(fit - org);
+ displacement[count] = fit - org;
+ scores[count++] = delta;
}
}