[truetype] More fixes for GX. This finally fixes the rendering of the cyclist and the lizard in the `Zycon' font. * src/truetype/ttgxvar.c (ft_var_readpackedpoints): `first' point index is always cumulative. (tt_handle_deltas): Rename to... (tt_interpolate_deltas): ... This. Add new parameter for output point array. Update caller. (TT_Vary_Apply_Glyph_Deltas): Add `points_out' array; it now holds the intermediate results of `tt_interpolate_deltas' that are to be added to `outline->points'.
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
diff --git a/ChangeLog b/ChangeLog
index 34394a4..9ae3ce6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2016-07-14 Behdad Esfahbod <behdad@behdad.org>
+
+ [truetype] More fixes for GX.
+
+ This finally fixes the rendering of the cyclist and the lizard in
+ the `Zycon' font.
+
+ * src/truetype/ttgxvar.c (ft_var_readpackedpoints): `first' point
+ index is always cumulative.
+
+ (tt_handle_deltas): Rename to...
+ (tt_interpolate_deltas): ... This.
+ Add new parameter for output point array.
+ Update caller.
+
+ (TT_Vary_Apply_Glyph_Deltas): Add `points_out' array; it now holds
+ the intermediate results of `tt_interpolate_deltas' that are to be
+ added to `outline->points'.
+
2016-07-15 Werner Lemberg <wl@gnu.org>
* src/autofit/aflatin.c (af_latin_hints_compute_segments): Thinko.
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 906ca4a..1a57153 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -163,6 +163,7 @@
*point_cnt = n;
+ first = 0;
i = 0;
while ( i < n )
{
@@ -170,7 +171,7 @@
if ( runcnt & GX_PT_POINTS_ARE_WORDS )
{
runcnt &= GX_PT_POINT_RUN_COUNT_MASK;
- first = FT_GET_USHORT();
+ first += FT_GET_USHORT();
points[i++] = first;
if ( runcnt < 1 || i + runcnt > n )
@@ -185,7 +186,7 @@
}
else
{
- first = FT_GET_BYTE();
+ first += FT_GET_BYTE();
points[i++] = first;
if ( runcnt < 1 || i + runcnt > n )
@@ -1716,12 +1717,11 @@
/* modeled after `Ins_IUP */
static void
- tt_handle_deltas( FT_Outline* outline,
- FT_Vector* in_points,
- FT_Bool* has_delta )
+ tt_interpolate_deltas( FT_Outline* outline,
+ FT_Vector* out_points,
+ FT_Vector* in_points,
+ FT_Bool* has_delta )
{
- FT_Vector* out_points;
-
FT_Int first_point;
FT_Int end_point;
@@ -1736,8 +1736,6 @@
if ( !outline->n_contours )
return;
- out_points = outline->points;
-
contour = 0;
point = 0;
@@ -1841,6 +1839,7 @@
GX_Blend blend = face->blend;
FT_Vector* points_org = NULL;
+ FT_Vector* points_out = NULL;
FT_Bool* has_delta = NULL;
FT_Error error;
@@ -1872,6 +1871,7 @@
}
if ( FT_NEW_ARRAY( points_org, n_points ) ||
+ FT_NEW_ARRAY( points_out, n_points ) ||
FT_NEW_ARRAY( has_delta, n_points ) )
goto Fail1;
@@ -2060,7 +2060,10 @@
/* we have to interpolate the missing deltas similar to the */
/* IUP bytecode instruction */
for ( j = 0; j < n_points; j++ )
+ {
has_delta[j] = FALSE;
+ points_out[j] = points_org[j];
+ }
for ( j = 0; j < point_count; j++ )
{
@@ -2072,15 +2075,22 @@
has_delta[idx] = TRUE;
- outline->points[idx].x += FT_MulFix( deltas_x[j], apply );
- outline->points[idx].y += FT_MulFix( deltas_y[j], apply );
+ points_out[idx].x += FT_MulFix( deltas_x[j], apply );
+ points_out[idx].y += FT_MulFix( deltas_y[j], apply );
}
/* no need to handle phantom points here, */
/* since solitary points can't be interpolated */
- tt_handle_deltas( outline,
- points_org,
- has_delta );
+ tt_interpolate_deltas( outline,
+ points_out,
+ points_org,
+ has_delta );
+
+ for ( j = 0; j < n_points; j++ )
+ {
+ outline->points[j].x += points_out[j].x - points_org[j].x;
+ outline->points[j].y += points_out[j].y - points_org[j].y;
+ }
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE7(( " point deltas:\n" ));
@@ -2128,6 +2138,7 @@
Fail1:
FT_FREE( points_org );
+ FT_FREE( points_out );
FT_FREE( has_delta );
return error;