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 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369
diff --git a/ChangeLog b/ChangeLog
index 2c71503..c01e109 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,49 @@
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.
+ * src/autofit/aflatin.c (af_latin_hints_link_segments): Fix
+ incorrect segment linking computation. This was the root cause of
+ Savannah bug #19565.
+
+
+ * src/autofit/* [FT_OPTION_AUTOFIT2]: Some very experimental changes
+ to improve the Latin auto-hinter. Note that the new code is
+ disabled by default since it is not stabilized yet.
+
+ * src/autofit/aflatin2.c, src/autofit/aflatin2.h: New files
+ (disabled currently).
+
+ * src/autofit/afhints.c: Remove dead code.
+ (af_axis_hints_new_edge): Add argument to handle segment directions.
+ (af_edge_flags_to_string): New function.
+ (af_glyph_hints_dump_segments, af_glyph_hints_dump_edges): Handle
+ option flags.
+ (af_glyph_hints_reload): Add argument to handle inflections.
+ Simplify.
+ (af_direction_compute): Fine tuning.
+ (af_glyph_hints_align_edge_points): Fix logic.
+ (af_glyph_hints_align_strong_points): Do linear search for small
+ edge counts.
+ (af_glyph_hints_align_weak_points): Skip any touched neighbors.
+ (af_iup_shift): Handle zero `delta'.
+
+ * src/autofit/afhints.h: Updated.
+ (AF_SORT_SEGMENTS): New macro (disabled).
+ (AF_AxisHintsRec) [AF_SORT_SEGMENTS]: New member `mid_segments'.
+
+ * src/autofit/afglobal.c (af_face_globals_get_metrics): Add
+ argument to pass option flags for handling scripts.
+ * src/autofit/afglobal.h: Updated.
+
+ * src/autofit/afcjk.c: Updated.
+ * src/autofit/aflatin.c: Updated.
+ (af_latin_metrics_scale_dim): Don't reduce scale by 2%.
+
+ (af_latin_hints_compute_segments) [AF_HINT_METRICS]: Remove dead code.
+ (af_latin_hints_compute_edges) [AF_HINT_METRICS]: Remove dead code.
+ Don't set `edge->dir'
+ (af_latin_hint_edges): Add more logging.
+
+ * src/autofit/afloader.c: Updated.
2007-06-11 Werner Lemberg <wl@gnu.org>
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index 5f16250..a272d50 100644
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -229,10 +229,10 @@
AF_ScriptMetrics metrics = NULL;
FT_UInt gidx;
AF_ScriptClass clazz;
- FT_UInt script = (options & 15);
- const FT_UInt script_max = sizeof(af_script_classes)/
- sizeof(af_script_classes[0]);
- FT_Error error = AF_Err_Ok;
+ FT_UInt script = options & 15;
+ const FT_UInt script_max = sizeof ( af_script_classes ) /
+ sizeof ( af_script_classes[0] );
+ FT_Error error = AF_Err_Ok;
if ( gindex >= globals->glyph_count )
@@ -242,11 +242,11 @@
}
gidx = script;
- if (gidx == 0 || gidx+1 >= script_max)
+ if ( gidx == 0 || gidx + 1 >= script_max )
gidx = globals->glyph_scripts[gindex];
- clazz = af_script_classes[gidx];
- if (script == 0)
+ clazz = af_script_classes[gidx];
+ if ( script == 0 )
script = clazz->script;
metrics = globals->metrics[clazz->script];
diff --git a/src/autofit/afglobal.h b/src/autofit/afglobal.h
index b9e88fa..cf52c08 100644
--- a/src/autofit/afglobal.h
+++ b/src/autofit/afglobal.h
@@ -5,7 +5,7 @@
/* Auto-fitter routines to compute global hinting values */
/* (specification). */
/* */
-/* Copyright 2003, 2004, 2005 by */
+/* Copyright 2003, 2004, 2005, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/autofit/afhints.c b/src/autofit/afhints.c
index 865e643..4828706 100644
--- a/src/autofit/afhints.c
+++ b/src/autofit/afhints.c
@@ -101,13 +101,12 @@
while ( edge > edges )
{
- if (edge[-1].fpos < fpos)
+ if ( edge[-1].fpos < fpos )
break;
- /* we want the edge with same position and minor direction
- * to appear before those in the major one in the list
- */
- if (edge[-1].fpos == fpos && dir == axis->major_dir)
+ /* we want the edge with same position and minor direction */
+ /* to appear before those in the major one in the list */
+ if ( edge[-1].fpos == fpos && dir == axis->major_dir )
break;
edge[0] = edge[-1];
@@ -198,28 +197,31 @@
static const char*
af_edge_flags_to_string( AF_Edge_Flags flags )
{
- static char temp[32];
- int pos = 0;
+ static char temp[32];
+ int pos = 0;
+
if ( flags & AF_EDGE_ROUND )
{
- memcpy( temp+pos, "round", 5 );
+ memcpy( temp + pos, "round", 5 );
pos += 5;
}
if ( flags & AF_EDGE_SERIF )
{
- if (pos > 0)
+ if ( pos > 0 )
temp[pos++] = ' ';
- memcpy( temp+pos, "serif", 5 );
+ memcpy( temp + pos, "serif", 5 );
pos += 5;
}
- if (pos == 0)
+ if ( pos == 0 )
return "normal";
temp[pos] = 0;
+
return temp;
}
+
/* A function to dump the array of linked segments. */
void
af_glyph_hints_dump_segments( AF_GlyphHints hints )
@@ -244,13 +246,14 @@
{
printf ( " [ %5d | %5.2g | %5s | %4d | %5d | %5d | %5d | %s ]\n",
seg - segments,
- dimension == AF_DIMENSION_HORZ ? (int)seg->first->ox/64.0 : (int)seg->first->oy/64.0,
+ dimension == AF_DIMENSION_HORZ ? (int)seg->first->ox / 64.0
+ : (int)seg->first->oy / 64.0,
af_dir_str( (AF_Direction)seg->dir ),
AF_INDEX_NUM( seg->link, segments ),
AF_INDEX_NUM( seg->serif, segments ),
seg->height,
seg->height - ( seg->max_coord - seg->min_coord ),
- af_edge_flags_to_string(seg->flags));
+ af_edge_flags_to_string( seg->flags ) );
}
printf( "\n" );
}
@@ -285,14 +288,14 @@
printf ( " [ %5d | %5.2g | %5s | %4d |"
" %5d | %c | %5.2f | %5.2f | %s ]\n",
edge - edges,
- (int)edge->opos/64.0,
+ (int)edge->opos / 64.0,
af_dir_str( (AF_Direction)edge->dir ),
AF_INDEX_NUM( edge->link, edges ),
AF_INDEX_NUM( edge->serif, edges ),
edge->blue_edge ? 'y' : 'n',
edge->opos / 64.0,
edge->pos / 64.0,
- af_edge_flags_to_string(edge->flags) );
+ af_edge_flags_to_string( edge->flags ) );
}
printf( "\n" );
}
@@ -367,7 +370,7 @@
}
ss *= 14;
- if ( FT_ABS(ll) <= FT_ABS(ss) )
+ if ( FT_ABS( ll ) <= FT_ABS( ss ) )
dir = AF_DIR_NONE;
return dir;
@@ -634,13 +637,14 @@
/* compute coordinates & Bezier flags, next and prev */
{
- FT_Vector* vec = outline->points;
- char* tag = outline->tags;
- AF_Point first = points;
- AF_Point end = points + outline->contours[0];
- AF_Point prev = end;
+ FT_Vector* vec = outline->points;
+ char* tag = outline->tags;
+ AF_Point first = points;
+ AF_Point end = points + outline->contours[0];
+ AF_Point prev = end;
FT_Int contour_index = 0;
+
for ( point = points; point < point_limit; point++, vec++, tag++ )
{
point->fx = (FT_Short)vec->x;
@@ -664,7 +668,7 @@
prev->next = point;
prev = point;
- if (point == end)
+ if ( point == end )
{
if ( ++contour_index < outline->n_contours )
{
@@ -699,11 +703,13 @@
FT_Pos in_y = 0;
AF_Direction in_dir = AF_DIR_NONE;
+
for ( point = points; point < point_limit; point++ )
{
AF_Point next;
FT_Pos out_x, out_y;
+
if ( point == first )
{
prev = first->prev;
@@ -713,14 +719,14 @@
first = prev + 1;
}
- point->in_dir = (FT_Char) in_dir;
+ point->in_dir = (FT_Char)in_dir;
- next = point->next;
- out_x = next->fx - point->fx;
- out_y = next->fy - point->fy;
+ next = point->next;
+ out_x = next->fx - point->fx;
+ out_y = next->fy - point->fy;
in_dir = af_direction_compute( out_x, out_y );
- point->out_dir = (FT_Char) in_dir;
+ point->out_dir = (FT_Char)in_dir;
if ( point->flags & ( AF_FLAG_CONIC | AF_FLAG_CUBIC ) )
{
@@ -745,8 +751,9 @@
}
}
- /* compute inflection points -- disable due to no longer perceived benefits */
- if (0 && get_inflections)
+ /* compute inflection points -- */
+ /* disabled due to no longer perceived benefits */
+ if ( 0 && get_inflections )
af_glyph_hints_compute_inflections( hints );
Exit:
@@ -1021,7 +1028,7 @@
AF_Point p;
FT_Pos delta = ref->u - ref->v;
- if (delta == 0)
+ if ( delta == 0 )
return;
for ( p = p1; p < ref; p++ )
@@ -1141,7 +1148,8 @@
for ( ; contour < contour_limit; contour++ )
{
- AF_Point first_touched, last_touched;
+ AF_Point first_touched, last_touched;
+
point = *contour;
end_point = point->prev;
@@ -1164,10 +1172,11 @@
for (;;)
{
- FT_ASSERT( point <= end_point && (point->flags & touch_flag) != 0 );
+ FT_ASSERT( point <= end_point &&
+ ( point->flags & touch_flag ) != 0 );
/* skip any touched neighbhours */
- while ( point < end_point && (point[1].flags & touch_flag) != 0 )
+ while ( point < end_point && ( point[1].flags & touch_flag ) != 0 )
point++;
last_touched = point;
@@ -1179,7 +1188,7 @@
if ( point > end_point )
goto EndContour;
- if ( (point->flags & touch_flag) != 0 )
+ if ( ( point->flags & touch_flag ) != 0 )
break;
point++;
diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c
index 6cb670e..04b4f7b 100644
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -2009,13 +2009,16 @@
FT_MulDiv( edge->opos - before->opos,
after->pos - before->pos,
after->opos - before->opos );
- AF_LOG(( "SERIF_LINK1: edge %d (opos=%.2f) snapped to (%.2f) from %d (opos=%.2f)\n",
- edge-edges, edge->opos / 64.0, edge->pos / 64.0, before - edges, before->opos / 64.0 ));
+ AF_LOG(( "SERIF_LINK1: edge %d (opos=%.2f) snapped to (%.2f) "
+ "from %d (opos=%.2f)\n",
+ edge-edges, edge->opos / 64.0,
+ edge->pos / 64.0, before - edges,
+ before->opos / 64.0 ));
}
else
{
- edge->pos = anchor->pos + (( edge->opos - anchor->opos + 16) & ~31);
-
+ edge->pos = anchor->pos +
+ ( ( edge->opos - anchor->opos + 16 ) & ~31 );
AF_LOG(( "SERIF_LINK2: edge %d (opos=%.2f) snapped to (%.2f)\n",
edge-edges, edge->opos / 64.0, edge->pos / 64.0 ));
}
diff --git a/src/autofit/afloader.c b/src/autofit/afloader.c
index 44a6f26..4e4373a 100644
--- a/src/autofit/afloader.c
+++ b/src/autofit/afloader.c
@@ -494,9 +494,10 @@
AF_ScriptMetrics metrics;
FT_UInt options = 0;
+
#ifdef FT_OPTION_AUTOFIT2
/* XXX: undocumented hook to activate the latin2 hinter */
- if (load_flags & (1UL << 20))
+ if ( load_flags & ( 1UL << 20 ) )
options = 2;
#endif