Commit ec810f8c6ac41d2ee20505b00fc8033d098d99a1

Werner Lemberg 2002-08-22T06:04:32

* src/pshinter/pshalgo3.c (psh3_glyph_compute_inflections, psh3_glyph_compute_extrema, psh3_hint_table_find_strong_point): Fix compiler warnings and resolve shadowing of local variables.

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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
diff --git a/ChangeLog b/ChangeLog
index 8bdd4ad..7345a46 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2002-08-21  Werner Lemberg  <wl@gnu.org>
+
+	* src/pshinter/pshalgo3.c (psh3_glyph_compute_inflections,
+	psh3_glyph_compute_extrema, psh3_hint_table_find_strong_point): Fix
+	compiler warnings and resolve shadowing of local variables.
+
 2002-08-21  David Turner  <david@freetype.org>
 
         * src/pshinter/pshalgo3.c, src/autohint/ahangles.c,
@@ -32,11 +38,41 @@
 	src/autohint/ahmodule.c [DEBUG_HINTER]: Removing compiler warnings
 	(only used in development builds anyway).
 
-	* src/pshinter/pshalgo3.h, src/pshinter/pshalgo3.c: Removing
-	compiler warnings, and improving the support of local extrema
-	and stem edge points.
+	Improve support of local extrema and stem edge points.
+
+	* src/pshinter/pshalgo3.h (PSH3_Hint_TableRec): Use PSH3_ZoneRec
+	for `zones'.
+	(PSH3_DIR_UP, PSH3_DIR_DOWN): Exchange values.
+	(PSH3_DIR_HORIZONTAL, PSH3_DIR_VERTICAL): New macros.
+	(PSH3_DIR_COMPARE, PSH3_DIR_IS_HORIZONTAL, PSH3_IS_VERTICAL): New
+	macros.
+	(PSH3_POINT_INFLEX): New enum.
+	(psh3_point_{is,set}_{off,inflex}): New macros.
+	(PSH3_POINT_{EXTREMUM,POSITIVE,NEGATIVE,EDGE_MIN,EDGE_MAX): New
+	enum values.
+	(psh3_point_{is,set}_{extremum,positive,negative,edge_min,edge_max}):
+	New macros.
+	(PSH3_PointRec): New members `flags2' and `org_v'.
+	(PSH3_POINT_EQUAL_ARG, PSH3_POINT_ANGLE): New macros.
+
+	* src/pshinter/pshalgo3.c [DEBUG_HINTER]: Removing compiler
+	warnings.
+	(COMPUTE_INFLEXS): New macro.
+	(psh3_hint_align): Simplify some basic arithmetic computations.
+	(psh3_point_is_extremum): Removed.
+	(psh3_glyph_compute_inflections) [COMPUTE_INFLEXS]: New function.
+	(psh3_glyph_init) [COMPUTE_INFLEXS]: Use it.
+	(psh3_glyph_compute_extrema): New function.
+	(PSH3_STRONG_THRESHOLD): Increased to 30.
+	(psh3_hint_table_find_strong_point): Improved.
+	(psh3_glyph_find_strong_points,
+	psh3_glyph_interpolate_strong_points): Updated.
+	(psh3_hints_apply): Use psh3_glyph_compute_extrema.
+
+	* test/gview.c (draw_ps3_hint, ps3_draw_control_points): New
+	functions.
+	Other small updates.
 
-	* test/gview.c: Small updates to the hinting debugger.
 	* Jamfile: Small updates.
 
 2002-08-18  Arkadiusz Miskiewicz  <misiek@pld.ORG.PL>
diff --git a/src/pshinter/pshalgo3.c b/src/pshinter/pshalgo3.c
index 59b4d5a..aa7b878 100644
--- a/src/pshinter/pshalgo3.c
+++ b/src/pshinter/pshalgo3.c
@@ -665,12 +665,14 @@
   /*************************************************************************/
 
 #ifdef COMPUTE_INFLEXS
- /* compute all inflex points in a given glyph */
+
+  /* compute all inflex points in a given glyph */
   static void
   psh3_glyph_compute_inflections( PSH3_Glyph  glyph )
   {
     FT_UInt  n;
 
+
     for ( n = 0; n < glyph->num_contours; n++ )
     {
       PSH3_Point  first, start, end, before, after;
@@ -678,12 +680,13 @@
       FT_Angle    diff_in, diff_out;
       FT_Int      finished = 0;
 
+
       /* we need at least 4 points to create an inflection point */
       if ( glyph->contours[n].count < 4 )
         continue;
 
       /* compute first segment in contour */
-      first  = glyph->contours[n].start;
+      first = glyph->contours[n].start;
 
       start = end = first;
       do
@@ -691,8 +694,8 @@
         end = end->next;
         if ( end == first )
           goto Skip;
-      }
-      while ( PSH3_POINT_EQUAL_ORG( end, first ) );
+
+      } while ( PSH3_POINT_EQUAL_ORG( end, first ) );
 
       angle_seg = PSH3_POINT_ANGLE( start, end );
 
@@ -706,12 +709,12 @@
           before = before->prev;
           if ( before == first )
             goto Skip;
-        }
-        while ( PSH3_POINT_EQUAL_ORG( before, start ) );
+
+        } while ( PSH3_POINT_EQUAL_ORG( before, start ) );
 
         angle_in = PSH3_POINT_ANGLE( before, start );
-      }
-      while ( angle_in == angle_seg );
+
+      } while ( angle_in == angle_seg );
 
       first   = start;
       diff_in = FT_Angle_Diff( angle_in, angle_seg );
@@ -729,12 +732,12 @@
             after = after->next;
             if ( after == first )
               finished = 1;
-          }
-          while ( PSH3_POINT_EQUAL_ORG( end, after ) );
+
+          } while ( PSH3_POINT_EQUAL_ORG( end, after ) );
 
           angle_out = PSH3_POINT_ANGLE( end, after );
-        }
-        while ( angle_out == angle_seg );
+
+        } while ( angle_out == angle_seg );
 
         diff_out = FT_Angle_Diff( angle_seg, angle_out );
 
@@ -757,15 +760,17 @@
         end       = after;
         angle_seg = angle_out;
         diff_in   = diff_out;
-      }
-      while ( !finished );
+
+      } while ( !finished );
 
     Skip:
       ;
     }
   }
+
 #endif /* COMPUTE_INFLEXS */
 
+
   static void
   psh3_glyph_done( PSH3_Glyph  glyph )
   {
@@ -1037,13 +1042,12 @@
   }
 
 
-
-
- /* compute all extrema in a glyph for a given dimension */
+  /* compute all extrema in a glyph for a given dimension */
   static void
   psh3_glyph_compute_extrema( PSH3_Glyph  glyph )
   {
-    FT_UInt   n;
+    FT_UInt  n;
+
 
     /* first of all, compute all local extrema */
     for ( n = 0; n < glyph->num_contours; n++ )
@@ -1051,6 +1055,7 @@
       PSH3_Point  first = glyph->contours[n].start;
       PSH3_Point  point, before, after;
 
+
       point  = first;
       before = point;
       after  = point;
@@ -1073,8 +1078,8 @@
           after = after->next;
           if ( after == first )
             goto Next;
-        }
-        while ( after->org_u == point->org_u );
+
+        } while ( after->org_u == point->org_u );
 
         if ( before->org_u < point->org_u )
         {
@@ -1094,8 +1099,8 @@
             {
               psh3_point_set_extremum( point );
               point = point->next;
-            }
-            while ( point != after );
+
+            } while ( point != after );
           }
         }
 
@@ -1108,16 +1113,17 @@
       ;
     }
 
-  /* for each extrema, determine its direction along the */
-  /* orthogonal axis                                     */
+    /* for each extrema, determine its direction along the */
+    /* orthogonal axis                                     */
     for ( n = 0; n < glyph->num_points; n++ )
     {
       PSH3_Point  point, before, after;
 
+
       point  = &glyph->points[n];
       before = point;
       after  = point;
-      
+
       if ( psh3_point_is_extremum( point ) )
       {
         do
@@ -1125,16 +1131,16 @@
           before = before->prev;
           if ( before == point )
             goto Skip;
-        }
-        while ( before->org_v == point->org_v );
+
+        } while ( before->org_v == point->org_v );
 
         do
         {
           after = after->next;
           if ( after == point )
             goto Skip;
-        }
-        while ( after->org_v == point->org_v );
+
+        } while ( after->org_v == point->org_v );
       }
 
       if ( before->org_v < point->org_v &&
@@ -1147,29 +1153,29 @@
       {
         psh3_point_set_negative( point );
       }
+
     Skip:
       ;
     }
   }
 
 
-
-
 #define PSH3_STRONG_THRESHOLD  30
 
 
-  /* major_dir is the direction for points on the bottom/left of the stem;
-   * Points on the top/right of the stem will have a direction of
-   * -major_dir.
-   */
+  /* major_dir is the direction for points on the bottom/left of the stem; */
+  /* Points on the top/right of the stem will have a direction of          */
+  /* -major_dir.                                                           */
+
   static void
   psh3_hint_table_find_strong_point( PSH3_Hint_Table  table,
                                      PSH3_Point       point,
                                      FT_Int           major_dir )
   {
-    PSH3_Hint*   sort      = table->sort;
-    FT_UInt      num_hints = table->num_hints;
-    FT_Int       point_dir = 0;
+    PSH3_Hint*  sort      = table->sort;
+    FT_UInt     num_hints = table->num_hints;
+    FT_Int      point_dir = 0;
+
 
     if ( PSH3_DIR_COMPARE( point->dir_in, major_dir ) )
       point_dir = point->dir_in;
@@ -1181,15 +1187,18 @@
     {
       FT_UInt  flag;
 
+
       for ( ; num_hints > 0; num_hints--, sort++ )
       {
         PSH3_Hint  hint = sort[0];
         FT_Pos     d;
 
+
         if ( point_dir == major_dir )
         {
           flag = PSH3_POINT_EDGE_MIN;
           d    = point->org_u - hint->org_pos;
+
           if ( ABS( d ) < PSH3_STRONG_THRESHOLD )
           {
           Is_Strong:
@@ -1203,17 +1212,20 @@
         {
           flag  = PSH3_POINT_EDGE_MAX;
           d     = point->org_u - hint->org_pos - hint->org_len;
+
           if ( ABS( d ) < PSH3_STRONG_THRESHOLD )
             goto Is_Strong;
         }
       }
     }
+
 #if 1
     else if ( psh3_point_is_extremum( point ) )
     {
       /* treat extrema as special cases for stem edge alignment */
       FT_UInt  min_flag, max_flag;
 
+
       if ( major_dir == PSH3_DIR_HORIZONTAL )
       {
         min_flag = PSH3_POINT_POSITIVE;
@@ -1230,10 +1242,12 @@
         PSH3_Hint  hint = sort[0];
         FT_Pos     d, flag;
 
+
         if ( point->flags2 & min_flag )
         {
           flag = PSH3_POINT_EDGE_MIN;
           d    = point->org_u - hint->org_pos;
+
           if ( ABS( d ) < PSH3_STRONG_THRESHOLD )
           {
           Is_Strong2:
@@ -1247,6 +1261,7 @@
         {
           flag = PSH3_POINT_EDGE_MAX;
           d    = point->org_u - hint->org_pos - hint->org_len;
+
           if ( ABS( d ) < PSH3_STRONG_THRESHOLD )
             goto Is_Strong2;
         }
@@ -1258,7 +1273,8 @@
         }
       }
     }
-#endif
+
+#endif /* 1 */
   }
 
 
@@ -1358,6 +1374,7 @@
         {
           FT_Pos  delta;
 
+  
           if ( psh3_point_is_edge_min( point ) )
           {
             point->cur_u = hint->cur_pos;
@@ -1375,11 +1392,12 @@
 
             else if ( delta >= hint->org_len )
               point->cur_u = hint->cur_pos + hint->cur_len +
-                            FT_MulFix( delta - hint->org_len, scale );
+                               FT_MulFix( delta - hint->org_len, scale );
 
             else if ( hint->org_len > 0 )
               point->cur_u = hint->cur_pos +
-                            FT_MulDiv( delta, hint->cur_len, hint->org_len );
+                               FT_MulDiv( delta, hint->cur_len,
+                                          hint->org_len );
             else
               point->cur_u = hint->cur_pos;
           }
diff --git a/src/pshinter/pshalgo3.h b/src/pshinter/pshalgo3.h
index f5479ff..5813dc2 100644
--- a/src/pshinter/pshalgo3.h
+++ b/src/pshinter/pshalgo3.h
@@ -28,10 +28,10 @@
 FT_BEGIN_HEADER
 
 
- /* handle to Hint structure */
+  /* handle to Hint structure */
   typedef struct PSH3_HintRec_*  PSH3_Hint;
  
- /* hint bit-flags */
+  /* hint bit-flags */
   typedef enum
   {
     PSH3_HINT_GHOST  = PS_HINT_FLAG_GHOST,
@@ -50,7 +50,7 @@ FT_BEGIN_HEADER
 #define psh3_hint_deactivate( x )  (x)->flags &= ~PSH3_HINT_ACTIVE
 #define psh3_hint_set_fitted( x )  (x)->flags |=  PSH3_HINT_FITTED
 
- /* hint structure */
+  /* hint structure */
   typedef struct  PSH3_HintRec_
   {
     FT_Int     org_pos;
@@ -105,12 +105,12 @@ FT_BEGIN_HEADER
     PSH3_DIR_RIGHT =  2
   };
 
-#define  PSH3_DIR_HORIZONTAL    2
-#define  PSH3_DIR_VERTICAL      1
+#define PSH3_DIR_HORIZONTAL  2
+#define PSH3_DIR_VERTICAL    1
 
-#define  PSH3_DIR_COMPARE(d1,d2)  ( (d1) == (d2) || (d1) == -(d2) )
-#define  PSH3_DIR_IS_HORIZONTAL(d)  PSH3_DIR_COMPARE(d,PSH3_DIR_HORIZONTAL)
-#define  PSH3_DIR_IS_VERTICAL(d)    PSH3_DIR_COMPARE(d,PSH3_DIR_VERTICAL)
+#define PSH3_DIR_COMPARE( d1, d2 )  ( (d1) == (d2) || (d1) == -(d2) )
+#define PSH3_DIR_IS_HORIZONTAL( d )  PSH3_DIR_COMPARE( d, PSH3_DIR_HORIZONTAL )
+#define PSH3_DIR_IS_VERTICAL( d )    PSH3_DIR_COMPARE( d, PSH3_DIR_VERTICAL )
 
 
  /* the following bit-flags are computed once by the glyph */
@@ -122,33 +122,33 @@ FT_BEGIN_HEADER
     PSH3_POINT_INFLEX      = 4    /* point is inflection             */
   };
 
-#define psh3_point_is_smooth( p )      ( (p)->flags  & PSH3_POINT_SMOOTH )
-#define psh3_point_is_off( p )         ( (p)->flags  & PSH3_POINT_OFF    )
-#define psh3_point_is_inflection( p )  ( (p)->flags & PSH3_POINT_INFLEX )
+#define psh3_point_is_smooth( p )  ( (p)->flags & PSH3_POINT_SMOOTH )
+#define psh3_point_is_off( p )     ( (p)->flags & PSH3_POINT_OFF    )
+#define psh3_point_is_inflex( p )  ( (p)->flags & PSH3_POINT_INFLEX )
 
-#define psh3_point_set_smooth( p )  (p)->flags  |= PSH3_POINT_SMOOTH
-#define psh3_point_set_off( p )     (p)->flags  |= PSH3_POINT_OFF
-#define psh3_point_set_inflex( p )  (p)->flags  |= PSH3_POINT_INFLEX
+#define psh3_point_set_smooth( p )  (p)->flags |= PSH3_POINT_SMOOTH
+#define psh3_point_set_off( p )     (p)->flags |= PSH3_POINT_OFF
+#define psh3_point_set_inflex( p )  (p)->flags |= PSH3_POINT_INFLEX
 
- /* the following bit-flags are re-computed for each dimension */
+  /* the following bit-flags are re-computed for each dimension */
   enum
   {
-    PSH3_POINT_STRONG      = 16,   /* point is strong                             */
-    PSH3_POINT_FITTED      = 32,   /* point is already fitted                     */
-    PSH3_POINT_EXTREMUM    = 64,   /* point is local extremum                     */
-    PSH3_POINT_POSITIVE    = 128,  /* extremum has positive contour flow          */
-    PSH3_POINT_NEGATIVE    = 256,  /* extremum has negative contour flow          */
-    PSH3_POINT_EDGE_MIN    = 512,  /* point is aligned to left/bottom stem edge   */
-    PSH3_POINT_EDGE_MAX    = 1024  /* point is aligned to top/right stem edge     */
+    PSH3_POINT_STRONG   = 16,   /* point is strong                             */
+    PSH3_POINT_FITTED   = 32,   /* point is already fitted                     */
+    PSH3_POINT_EXTREMUM = 64,   /* point is local extremum                     */
+    PSH3_POINT_POSITIVE = 128,  /* extremum has positive contour flow          */
+    PSH3_POINT_NEGATIVE = 256,  /* extremum has negative contour flow          */
+    PSH3_POINT_EDGE_MIN = 512,  /* point is aligned to left/bottom stem edge   */
+    PSH3_POINT_EDGE_MAX = 1024  /* point is aligned to top/right stem edge     */
   };
 
-#define psh3_point_is_strong( p )   ( (p)->flags2 & PSH3_POINT_STRONG )
-#define psh3_point_is_fitted( p )   ( (p)->flags2 & PSH3_POINT_FITTED )
-#define psh3_point_is_extremum( p ) ( (p)->flags2 & PSH3_POINT_EXTREMUM )
-#define psh3_point_is_positive( p ) ( (p)->flags2 & PSH3_POINT_POSITIVE )
-#define psh3_point_is_negative( p ) ( (p)->flags2 & PSH3_POINT_NEGATIVE )
-#define psh3_point_is_edge_min( p ) ( (p)->flags2 & PSH3_POINT_EDGE_MIN )
-#define psh3_point_is_edge_max( p ) ( (p)->flags2 & PSH3_POINT_EDGE_MAX )
+#define psh3_point_is_strong( p )    ( (p)->flags2 & PSH3_POINT_STRONG )
+#define psh3_point_is_fitted( p )    ( (p)->flags2 & PSH3_POINT_FITTED )
+#define psh3_point_is_extremum( p )  ( (p)->flags2 & PSH3_POINT_EXTREMUM )
+#define psh3_point_is_positive( p )  ( (p)->flags2 & PSH3_POINT_POSITIVE )
+#define psh3_point_is_negative( p )  ( (p)->flags2 & PSH3_POINT_NEGATIVE )
+#define psh3_point_is_edge_min( p )  ( (p)->flags2 & PSH3_POINT_EDGE_MIN )
+#define psh3_point_is_edge_max( p )  ( (p)->flags2 & PSH3_POINT_EDGE_MAX )
 
 #define psh3_point_set_strong( p )    (p)->flags2 |= PSH3_POINT_STRONG
 #define psh3_point_set_fitted( p )    (p)->flags2 |= PSH3_POINT_FITTED
@@ -186,11 +186,11 @@ FT_BEGIN_HEADER
   } PSH3_PointRec;
 
 
-#define PSH3_POINT_EQUAL_ORG(a,b)  ( (a)->org_u == (b)->org_u && \
-                                     (a)->org_v == (b)->org_v )
+#define PSH3_POINT_EQUAL_ORG( a, b )  ( (a)->org_u == (b)->org_u && \
+                                        (a)->org_v == (b)->org_v )
 
-#define PSH3_POINT_ANGLE(a,b)  FT_Atan2( (b)->org_u - (a)->org_u,  \
-                                         (b)->org_v - (a)->org_v )
+#define PSH3_POINT_ANGLE( a, b )  FT_Atan2( (b)->org_u - (a)->org_u,  \
+                                            (b)->org_v - (a)->org_v )
 
   typedef struct  PSH3_ContourRec_
   {