formatting
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
diff --git a/ChangeLog b/ChangeLog
index 83d9eb6..d6ac3bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,13 @@
2007-02-14 David Turner <david@freetype.org>
- * src/truetype/ttinterp.c: improved the FIX_BYTECODE code which is now
- the default, it seems to get rid of most known problems with my fonts,
- but more testing is needed though.
+ It seems that the following changes fix most of the known
+ interpreter problems with my fonts, but more testing is needed,
+ though.
+
+ * src/truetype/ttinterp.c (FIX_BYTECODE): Activate.
+ (TT_MulFix14): Rewrite.
+ (Ins_MD, Ins_MDRP, Ins_IP) [FIX_BYTECODE]: Improved and updated.
+ (Ins_MIRP): Ditto.
2007-02-12 Werner Lemberg <wl@gnu.org>
@@ -14,6 +19,8 @@
2007-02-12 David Turner <david@freetype.org>
+ Simplify projection and dual-projection code interface.
+
* src/truetype/ttinterp.h (TT_Project_Func): Use `FT_Pos', not
FT_Vector' as argument type.
* src/truetype/ttinterp.c (CUR_Func_project, CUR_Func_dualproj):
@@ -28,9 +35,10 @@
adjustments for the non-light auto-hinted modes. Gets rid of
`inter-letter spacing is too wide' problems.
- * src/autofit/aflatin.c: Slight optimization of the segment linker
- and better handling of serif segments to get rid of broken `9' in
- Arial at 9pt (96dpi).
+ * src/autofit/aflatin.c (af_latin_hints_link_segments,
+ af_latin_hints_compute_edges): Slight optimization of the segment
+ linker and better handling of serif segments to get rid of broken
+ `9' in Arial at 9pt (96dpi).
Introduce new string functions and the corresponding macros to get
diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c
index 608e158..3f8d099 100644
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -926,7 +926,7 @@
if ( seg1->first == seg1->last )
continue;
- for ( seg2 = seg1+1; seg2 < segment_limit; seg2++ )
+ for ( seg2 = seg1 + 1; seg2 < segment_limit; seg2++ )
if ( seg1->dir + seg2->dir == 0 )
{
FT_Pos pos1 = seg1->pos;
@@ -1057,10 +1057,10 @@
if ( seg->height < segment_length_threshold )
continue;
- /* a special case for serif edges, if they're smaller than 1.5
- * pixels, we ignore them
- */
- if ( seg->serif && 2*seg->height < 3*segment_length_threshold )
+ /* A special case for serif edges: If they are smaller than */
+ /* 1.5 pixels we ignore them. */
+ if ( seg->serif &&
+ 2 * seg->height < 3 * segment_length_threshold )
continue;
/* look for an edge corresponding to the segment */
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index ace0290..0d961b2 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -1144,34 +1144,40 @@
#if 1
+
static FT_Int32
TT_MulFix14( FT_Int32 a,
FT_Int b )
-{
- FT_Int32 sign;
- FT_UInt32 ah, al, mid, lo, hi;
+ {
+ FT_Int32 sign;
+ FT_UInt32 ah, al, mid, lo, hi;
+
- sign = a^b;
+ sign = a ^ b;
- if (a < 0) a = -a;
- if (b < 0) b = -b;
+ if ( a < 0 )
+ a = -a;
+ if ( b < 0 )
+ b = -b;
- ah = (FT_UInt32)((a >> 16) & 0xFFFFU);
- al = (FT_UInt32)( a & 0xFFFFU );
+ ah = (FT_UInt32)( ( a >> 16 ) & 0xFFFFU );
+ al = (FT_UInt32)( a & 0xFFFFU );
- lo = al*b;
- mid = ah*b;
- hi = (mid >> 16);
- mid = (mid << 16) + (1 << 13); /* rounding */
- lo += mid;
- if (lo < mid)
- hi += 1;
+ lo = al * b;
+ mid = ah * b;
+ hi = mid >> 16;
+ mid = ( mid << 16 ) + ( 1 << 13 ); /* rounding */
+ lo += mid;
+ if ( lo < mid )
+ hi += 1;
- mid = (lo >> 14) | (hi << 18);
+ mid = ( lo >> 14 ) | ( hi << 18 );
+
+ return sign >= 0 ? (FT_Int32)mid : -(FT_Int32)mid;
+ }
- return sign >= 0 ? (FT_Int32)mid : -(FT_Int32)mid;
-}
#else
+
/* compute (a*b)/2^14 with maximal accuracy and rounding */
static FT_Int32
TT_MulFix14( FT_Int32 a,
@@ -4838,8 +4844,10 @@
CUR.twilight.n_points );
/* get scaled orus coordinates */
- vec1.x = TT_MULFIX( CUR.zp0.orus[L].x - CUR.zp1.orus[K].x, CUR.metrics.x_scale );
- vec1.y = TT_MULFIX( CUR.zp0.orus[L].y - CUR.zp1.orus[L].y, CUR.metrics.y_scale );
+ vec1.x = TT_MULFIX( CUR.zp0.orus[L].x - CUR.zp1.orus[K].x,
+ CUR.metrics.x_scale );
+ vec1.y = TT_MULFIX( CUR.zp0.orus[L].y - CUR.zp1.orus[L].y,
+ CUR.metrics.y_scale );
D = CUR_fast_dualproj( &vec1 );
@@ -5920,8 +5928,10 @@
CUR.zp1.cur[point] = CUR.zp0.cur[point];
}
- org_dist = CUR_Func_dualproj( &CUR.zp1.org[point], &CUR.zp0.org[CUR.GS.rp0] );
- cur_dist = CUR_Func_project ( &CUR.zp1.cur[point], &CUR.zp0.cur[CUR.GS.rp0] );
+ org_dist = CUR_Func_dualproj( &CUR.zp1.org[point],
+ &CUR.zp0.org[CUR.GS.rp0] );
+ cur_dist = CUR_Func_project ( &CUR.zp1.cur[point],
+ &CUR.zp0.cur[CUR.GS.rp0] );
/* auto-flip test */
@@ -6154,7 +6164,9 @@
/* */
/* SOMETIMES, DUMBER CODE IS BETTER CODE */
+
#ifdef FIX_BYTECODE
+
static void
Ins_IP( INS_ARG )
{
@@ -6171,20 +6183,19 @@
return;
}
- /* We need to deal in a special way with the twilight zone. The easiest
- * solution is simply to copy the coordinates from `org' to `orus'
- * whenever someone tries to perform intersections based on some of its
- * points.
- *
- * Otherwise, by definition, value of CUR.twilight.orus[n] is (0,0),
- * whatever value of `n'.
- */
+ /*
+ * We need to deal in a special way with the twilight zone. The easiest
+ * solution is simply to copy the coordinates from `org' to `orus'
+ * whenever a font tries to perform intersections based on some of its
+ * points.
+ *
+ * Otherwise, by definition, the value of CUR.twilight.orus[n] is (0,0),
+ * whatever value of `n'.
+ */
if ( CUR.GS.gep0 == 0 || CUR.GS.gep1 == 0 || CUR.GS.gep2 == 0 )
- {
- FT_ARRAY_COPY( CUR.twilight.orus,
- CUR.twilight.org,
- CUR.twilight.n_points );
- }
+ FT_ARRAY_COPY( CUR.twilight.orus,
+ CUR.twilight.org,
+ CUR.twilight.n_points );
orus_base = &CUR.zp0.orus[CUR.GS.rp1];
cur_base = &CUR.zp0.cur[CUR.GS.rp1];
@@ -6207,9 +6218,10 @@
for ( ; CUR.GS.loop > 0; --CUR.GS.loop )
{
- FT_UInt point = (FT_UInt) CUR.stack[--CUR.args];
+ FT_UInt point = (FT_UInt)CUR.stack[--CUR.args];
FT_F26Dot6 org_dist, cur_dist, new_dist;
+
/* check point bounds */
if ( BOUNDS( point, CUR.zp2.n_points ) )
{
@@ -6223,15 +6235,18 @@
org_dist = CUR_Func_dualproj( &CUR.zp2.orus[point], orus_base );
cur_dist = CUR_Func_project ( &CUR.zp2.cur[point], cur_base );
- new_dist = (old_range != 0) ? TT_MULDIV( org_dist, cur_range, old_range )
- : cur_dist;
+ new_dist = (old_range != 0)
+ ? TT_MULDIV( org_dist, cur_range, old_range )
+ : cur_dist;
CUR_Func_move( &CUR.zp2, point, new_dist - cur_dist );
}
CUR.GS.loop = 1;
CUR.new_top = CUR.args;
}
-#else /* OLD CODE */
+
+#else /* !FIX_BYTECODE */
+
static void
Ins_IP( INS_ARG )
{
@@ -6314,7 +6329,9 @@
CUR.GS.loop = 1;
CUR.new_top = CUR.args;
}
-#endif
+
+#endif /* !FIX_BYTECODE */
+
/*************************************************************************/
/* */