Commit 6874d85ba0cb281aa977dfaf1964229879437715

Werner Lemberg 2008-09-20T11:50:47

* src/base/ftoutln.c: Include FT_INTERNAL_DEBUG_H. (FT_Outline_Decompose): Decorate with tracing messages. * src/smooth/ftgrays.c [DEBUG_GRAYS]: Replace with FT_DEBUG_LEVEL_TRACE. [_STANDALONE_ && FT_DEBUG_LEVEL_TRACE]: Include stdio.h and stdarg.h. (FT_TRACE) [_STANDALONE_]: Remove. (FT_Message) [_STANDALONE_ && FT_DEBUG_LEVEL_TRACE]: New function. (FT_TRACE5, FT_TRACE7) [_STANDALONE_]: New macros. (FT_ERROR) [_STANDALONE_]: Updated. (gray_hline) [FT_DEBUG_LEVEL_TRACE]: Fix condition. Use FT_TRACE7. (gray_dump_cells): Make it `static void'. (graay_convert_glyph): Use FT_TRACE7. (FT_Outline_Decompose) [_STANDALONE_]: Synchronize with version in ftoutln.c. * src/base/ftadvanc.c (FT_Get_Advance, FT_Get_Advances): Use FT_ERROR_BASE. Other minor modifications.

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
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
diff --git a/ChangeLog b/ChangeLog
index 16e464e..3232716 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2008-09-20  Werner Lemberg  <wl@gnu.org>
+
+	* src/base/ftoutln.c: Include FT_INTERNAL_DEBUG_H.
+	(FT_Outline_Decompose): Decorate with tracing messages.
+
+	* src/smooth/ftgrays.c [DEBUG_GRAYS]: Replace with
+	FT_DEBUG_LEVEL_TRACE.
+	[_STANDALONE_ && FT_DEBUG_LEVEL_TRACE]: Include stdio.h and
+	stdarg.h.
+
+	(FT_TRACE) [_STANDALONE_]: Remove.
+	(FT_Message) [_STANDALONE_ && FT_DEBUG_LEVEL_TRACE]: New function.
+	(FT_TRACE5, FT_TRACE7) [_STANDALONE_]: New macros.
+	(FT_ERROR) [_STANDALONE_]: Updated.
+
+	(gray_hline) [FT_DEBUG_LEVEL_TRACE]: Fix condition.
+	Use FT_TRACE7.
+	(gray_dump_cells): Make it `static void'.
+	(graay_convert_glyph): Use FT_TRACE7.
+
+	(FT_Outline_Decompose) [_STANDALONE_]: Synchronize with version in
+	ftoutln.c.
+
+	* src/base/ftadvanc.c (FT_Get_Advance, FT_Get_Advances): Use
+	FT_ERROR_BASE.
+
 2008-09-19  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
 
 	* src/base/ftmac.c: Import sfnt-wrapped Type1 and sfnt-wrapped
diff --git a/include/freetype/ftoutln.h b/include/freetype/ftoutln.h
index 6a0f95b..4855072 100644
--- a/include/freetype/ftoutln.h
+++ b/include/freetype/ftoutln.h
@@ -92,7 +92,7 @@ FT_BEGIN_HEADER
   /* <Input>                                                               */
   /*    outline        :: A pointer to the source target.                  */
   /*                                                                       */
-  /*    func_interface :: A table of `emitters', i.e,. function pointers   */
+  /*    func_interface :: A table of `emitters', i.e., function pointers   */
   /*                      called during decomposition to indicate path     */
   /*                      operations.                                      */
   /*                                                                       */
diff --git a/src/base/ftadvanc.c b/src/base/ftadvanc.c
index dec3735..db975ca 100644
--- a/src/base/ftadvanc.c
+++ b/src/base/ftadvanc.c
@@ -91,7 +91,7 @@
       if ( !error )
         return _ft_face_scale_advances( face, padvance, 1, flags );
 
-      if ( error != FT_Err_Unimplemented_Feature )
+      if ( error != FT_ERROR_BASE( FT_Err_Unimplemented_Feature ) )
         return error;
     }
 
@@ -131,7 +131,7 @@
       if ( !error )
         goto Exit;
 
-      if ( error != FT_Err_Unimplemented_Feature )
+      if ( error != FT_ERROR_BASE( FT_Err_Unimplemented_Feature ) )
         return error;
     }
 
diff --git a/src/base/ftmac.c b/src/base/ftmac.c
index 4a52d76..92c3469 100644
--- a/src/base/ftmac.c
+++ b/src/base/ftmac.c
@@ -788,10 +788,10 @@
       face_index = 0;
 
     error = FT_Open_Face( library, &args, face_index, aface );
-    if ( error == FT_Err_Ok )
-      (*aface)->face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;
-    else
+    if ( error )
       FT_Stream_Free( stream, 0 );
+    else
+      (*aface)->face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;
 
     return error;
   }
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index fa9ae7f..26ab737 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -197,6 +197,12 @@
   }
 
 
+  /*************************************************************************/
+  /*                                                                       */
+  /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
+  /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
+  /* messages during execution.                                            */
+  /*                                                                       */
 #undef  FT_COMPONENT
 #define FT_COMPONENT  trace_objs
 
@@ -1280,13 +1286,13 @@
 
     error = FT_Open_Face( library, &args, face_index, aface );
 
-    if ( error == FT_Err_Ok )
-      (*aface)->face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;
-    else
+    if ( error )
     {
       FT_Stream_Close( stream );
       FT_FREE( stream );
     }
+    else
+      (*aface)->face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;
 
     return error;
   }
diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c
index 2bae857..48be18c 100644
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType outline management (body).                                  */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by             */
+/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by       */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -26,6 +26,7 @@
 #include <ft2build.h>
 #include FT_OUTLINE_H
 #include FT_INTERNAL_OBJECTS_H
+#include FT_INTERNAL_DEBUG_H
 #include FT_TRIGONOMETRY_H
 
 
@@ -83,21 +84,25 @@
       FT_Int  last;  /* index of last point in contour */
 
 
+      FT_TRACE5(( "FT_Outline_Decompose: Outline %d\n", n ));
+
       last = outline->contours[n];
       if ( last < 0 )
         goto Invalid_Outline;
       limit = outline->points + last;
 
-      v_start = outline->points[first];
-      v_last  = outline->points[last];
+      v_start   = outline->points[first];
+      v_start.x = SCALED( v_start.x );
+      v_start.y = SCALED( v_start.y );
 
-      v_start.x = SCALED( v_start.x ); v_start.y = SCALED( v_start.y );
-      v_last.x  = SCALED( v_last.x );  v_last.y  = SCALED( v_last.y );
+      v_last   = outline->points[last];
+      v_last.x = SCALED( v_last.x );
+      v_last.y = SCALED( v_last.y );
 
       v_control = v_start;
 
       point = outline->points + first;
-      tags  = outline->tags  + first;
+      tags  = outline->tags   + first;
       tag   = FT_CURVE_TAG( tags[0] );
 
       /* A contour cannot start with a cubic control point! */
@@ -128,6 +133,8 @@
         tags--;
       }
 
+      FT_TRACE5(( "  move to (%.2f, %.2f)\n",
+                  v_start.x / 64.0, v_start.y / 64.0 ));
       error = func_interface->move_to( &v_start, user );
       if ( error )
         goto Exit;
@@ -148,6 +155,8 @@
             vec.x = SCALED( point->x );
             vec.y = SCALED( point->y );
 
+            FT_TRACE5(( "  line to (%.2f, %.2f)\n",
+                        vec.x / 64.0, vec.y / 64.0 ));
             error = func_interface->line_to( &vec, user );
             if ( error )
               goto Exit;
@@ -174,6 +183,10 @@
 
             if ( tag == FT_CURVE_TAG_ON )
             {
+              FT_TRACE5(( "  conic to (%.2f, %.2f)"
+                          " with control (%.2f, %.2f)\n",
+                          vec.x / 64.0, vec.y / 64.0,
+                          v_control.x / 64.0, v_control.y / 64.0 ));
               error = func_interface->conic_to( &v_control, &vec, user );
               if ( error )
                 goto Exit;
@@ -186,6 +199,10 @@
             v_middle.x = ( v_control.x + vec.x ) / 2;
             v_middle.y = ( v_control.y + vec.y ) / 2;
 
+            FT_TRACE5(( "  conic to (%.2f, %.2f)"
+                        " with control (%.2f, %.2f)\n",
+                        v_middle.x / 64.0, v_middle.y / 64.0,
+                        v_control.x / 64.0, v_control.y / 64.0 ));
             error = func_interface->conic_to( &v_control, &v_middle, user );
             if ( error )
               goto Exit;
@@ -194,6 +211,10 @@
             goto Do_Conic;
           }
 
+          FT_TRACE5(( "  conic to (%.2f, %.2f)"
+                      " with control (%.2f, %.2f)\n",
+                      v_start.x / 64.0, v_start.y / 64.0,
+                      v_control.x / 64.0, v_control.y / 64.0 ));
           error = func_interface->conic_to( &v_control, &v_start, user );
           goto Close;
 
@@ -209,8 +230,11 @@
             point += 2;
             tags  += 2;
 
-            vec1.x = SCALED( point[-2].x ); vec1.y = SCALED( point[-2].y );
-            vec2.x = SCALED( point[-1].x ); vec2.y = SCALED( point[-1].y );
+            vec1.x = SCALED( point[-2].x );
+            vec1.y = SCALED( point[-2].y );
+
+            vec2.x = SCALED( point[-1].x );
+            vec2.y = SCALED( point[-1].y );
 
             if ( point <= limit )
             {
@@ -220,12 +244,22 @@
               vec.x = SCALED( point->x );
               vec.y = SCALED( point->y );
 
+              FT_TRACE5(( "  cubic to (%.2f, %.2f)"
+                          " with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
+                          vec.x / 64.0, vec.y / 64.0,
+                          vec1.x / 64.0, vec1.y / 64.0,
+                          vec2.x / 64.0, vec2.y / 64.0 ));
               error = func_interface->cubic_to( &vec1, &vec2, &vec, user );
               if ( error )
                 goto Exit;
               continue;
             }
 
+            FT_TRACE5(( "  cubic to (%.2f, %.2f)"
+                        " with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
+                        v_start.x / 64.0, v_start.y / 64.0,
+                        vec1.x / 64.0, vec1.y / 64.0,
+                        vec2.x / 64.0, vec2.y / 64.0 ));
             error = func_interface->cubic_to( &vec1, &vec2, &v_start, user );
             goto Close;
           }
@@ -233,6 +267,8 @@
       }
 
       /* close the contour with a line segment */
+      FT_TRACE5(( "  line to (%.2f, %.2f)\n",
+                  v_start.x / 64.0, v_start.y / 64.0 ));
       error = func_interface->line_to( &v_start, user );
 
     Close:
@@ -242,9 +278,11 @@
       first = last + 1;
     }
 
-    return 0;
+    FT_TRACE5(( "FT_Outline_Decompose: Done\n", n ));
+    return FT_Err_Ok;
 
   Exit:
+    FT_TRACE5(( "FT_Outline_Decompose: Error %d\n", error ));
     return error;
 
   Invalid_Outline:
@@ -558,7 +596,7 @@
                      FT_Raster_Params*  params )
   {
     FT_Error     error;
-    FT_Bool      update = 0;
+    FT_Bool      update = FALSE;
     FT_Renderer  renderer;
     FT_ListNode  node;
 
@@ -589,7 +627,7 @@
       /* format                                                */
       renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE,
                                      &node );
-      update   = 1;
+      update   = TRUE;
     }
 
     /* if we changed the current renderer for the glyph image format */
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 320e5d8..a409562 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    A new `perfect' anti-aliasing renderer (body).                       */
 /*                                                                         */
-/*  Copyright 2000-2001, 2002, 2003, 2005, 2006, 2007 by                   */
+/*  Copyright 2000-2001, 2002, 2003, 2005, 2006, 2007, 2008 by             */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -91,11 +91,19 @@
 #define FT_COMPONENT  trace_smooth
 
 
+#ifdef _STANDALONE_
 
 
-#ifdef _STANDALONE_
+  /* define this to dump debugging information */
+/* #define FT_DEBUG_LEVEL_TRACE */
+
 
-#include <string.h>             /* for ft_memcpy() */
+#ifdef FT_DEBUG_LEVEL_TRACE
+#include <stdio.h>
+#include <stdarg.h>
+#endif
+
+#include <string.h>
 #include <setjmp.h>
 #include <limits.h>
 #define FT_UINT_MAX  UINT_MAX
@@ -118,24 +126,53 @@
 #include "ftimage.h"
 #include "ftgrays.h"
 
+
   /* This macro is used to indicate that a function parameter is unused. */
   /* Its purpose is simply to reduce compiler warnings.  Note also that  */
   /* simply defining it as `(void)x' doesn't avoid warnings with certain */
   /* ANSI compilers (e.g. LCC).                                          */
 #define FT_UNUSED( x )  (x) = (x)
 
-  /* Disable the tracing mechanism for simplicity -- developers can      */
-  /* activate it easily by redefining these two macros.                  */
+
+  /* we only use level 5 & 7 tracing messages; cf. ftdebug.h */
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+
+  void
+  FT_Message( const char*  fmt,
+              ... )
+  {
+    va_list  ap;
+
+
+    va_start( ap, fmt );
+    vfprintf( stderr, fmt, ap );
+    va_end( ap );
+  }
+
+  /* we don't handle tracing levels in stand-alone mode; */
+#ifndef FT_TRACE5
+#define FT_TRACE5( varformat )  FT_Message varformat
+#endif
+#ifndef FT_TRACE7
+#define FT_TRACE7( varformat )  FT_Message varformat
+#endif
 #ifndef FT_ERROR
-#define FT_ERROR( x )  do ; while ( 0 )     /* nothing */
+#define FT_ERROR( varformat )   FT_Message varformat
 #endif
 
-#ifndef FT_TRACE
-#define FT_TRACE( x )  do ; while ( 0 )     /* nothing */
-#endif
+#else /* !FT_DEBUG_LEVEL_TRACE */
+
+#define FT_TRACE5( x )  do ; while ( 0 )     /* nothing */
+#define FT_TRACE7( x )  do ; while ( 0 )     /* nothing */
+#define FT_ERROR( x )   do ; while ( 0 )     /* nothing */
+
+#endif /* !FT_DEBUG_LEVEL_TRACE */
+
 
 #else /* !_STANDALONE_ */
 
+
 #include <ft2build.h>
 #include "ftgrays.h"
 #include FT_INTERNAL_OBJECTS_H
@@ -160,10 +197,6 @@
 #define FT_MEM_ZERO( dest, count )  FT_MEM_SET( dest, 0, count )
 #endif
 
-  /* define this to dump debugging information */
-#define xxxDEBUG_GRAYS
-
-
   /* as usual, for the speed hungry :-) */
 
 #ifndef FT_STATIC_RASTER
@@ -1229,24 +1262,23 @@
         if ( ras.render_span && count > 0 )
           ras.render_span( ras.span_y, count, ras.gray_spans,
                            ras.render_span_data );
-        /* ras.render_span( span->y, ras.gray_spans, count ); */
 
-#ifdef DEBUG_GRAYS
+#ifdef FT_DEBUG_LEVEL_TRACE
 
-        if ( ras.span_y >= 0 )
+        if ( count > 0 )
         {
           int  n;
 
 
-          fprintf( stderr, "y=%3d ", ras.span_y );
+          FT_TRACE7(( "y = %3d ", ras.span_y ));
           span = ras.gray_spans;
           for ( n = 0; n < count; n++, span++ )
-            fprintf( stderr, "[%d..%d]:%02x ",
-                     span->x, span->x + span->len - 1, span->coverage );
-          fprintf( stderr, "\n" );
+            FT_TRACE7(( "[%d..%d]:%02x ",
+                        span->x, span->x + span->len - 1, span->coverage ));
+          FT_TRACE7(( "\n" ));
         }
 
-#endif /* DEBUG_GRAYS */
+#endif /* FT_DEBUG_LEVEL_TRACE */
 
         ras.num_gray_spans = 0;
         ras.span_y         = y;
@@ -1267,9 +1299,11 @@
   }
 
 
-#ifdef DEBUG_GRAYS
+#ifdef FT_DEBUG_LEVEL_TRACE
 
-  /* to be called while in the debugger */
+  /* to be called while in the debugger --                                */
+  /* this function causes a compiler warning since it is unused otherwise */
+  static void
   gray_dump_cells( RAS_ARG )
   {
     int  yindex;
@@ -1288,7 +1322,7 @@
     }
   }
 
-#endif /* DEBUG_GRAYS */
+#endif /* FT_DEBUG_LEVEL_TRACE */
 
 
   static void
@@ -1344,7 +1378,7 @@
 
   /*************************************************************************/
   /*                                                                       */
-  /*  The following function should only compile in stand_alone mode,      */
+  /*  The following function should only compile in stand-alone mode,      */
   /*  i.e., when building this component without the rest of FreeType.     */
   /*                                                                       */
   /*************************************************************************/
@@ -1355,18 +1389,19 @@
   /*    FT_Outline_Decompose                                               */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    Walks over an outline's structure to decompose it into individual  */
-  /*    segments and Bezier arcs.  This function is also able to emit      */
+  /*    Walk over an outline's structure to decompose it into individual   */
+  /*    segments and Bézier arcs.  This function is also able to emit      */
   /*    `move to' and `close to' operations to indicate the start and end  */
   /*    of new contours in the outline.                                    */
   /*                                                                       */
   /* <Input>                                                               */
   /*    outline        :: A pointer to the source target.                  */
   /*                                                                       */
-  /*    func_interface :: A table of `emitters', i.e,. function pointers   */
+  /*    func_interface :: A table of `emitters', i.e., function pointers   */
   /*                      called during decomposition to indicate path     */
   /*                      operations.                                      */
   /*                                                                       */
+  /* <InOut>                                                               */
   /*    user           :: A typeless pointer which is passed to each       */
   /*                      emitter during the decomposition.  It can be     */
   /*                      used to store the state during the               */
@@ -1375,17 +1410,13 @@
   /* <Return>                                                              */
   /*    Error code.  0 means success.                                      */
   /*                                                                       */
-  static
-  int  FT_Outline_Decompose( const FT_Outline*        outline,
-                             const FT_Outline_Funcs*  func_interface,
-                             void*                    user )
+  static int
+  FT_Outline_Decompose( const FT_Outline*        outline,
+                        const FT_Outline_Funcs*  func_interface,
+                        void*                    user )
   {
 #undef SCALED
-#if 0
 #define SCALED( x )  ( ( (x) << shift ) - delta )
-#else
-#define SCALED( x )  (x)
-#endif
 
     FT_Vector   v_last;
     FT_Vector   v_control;
@@ -1395,17 +1426,21 @@
     FT_Vector*  limit;
     char*       tags;
 
+    int         error;
+
     int   n;         /* index of contour in outline     */
     int   first;     /* index of first point in contour */
-    int   error;
     char  tag;       /* current point's state           */
 
-#if 0
-    int   shift = func_interface->shift;
-    TPos  delta = func_interface->delta;
-#endif
+    int   shift;
+    TPos  delta;
 
 
+    if ( !outline || !func_interface )
+      return ErrRaster_Invalid_Argument;
+
+    shift = func_interface->shift;
+    delta = func_interface->delta;
     first = 0;
 
     for ( n = 0; n < outline->n_contours; n++ )
@@ -1413,22 +1448,25 @@
       int  last;  /* index of last point in contour */
 
 
+      FT_TRACE5(( "FT_Outline_Decompose: Outline %d\n", n ));
+
       last  = outline->contours[n];
+      if ( last < 0 )
+        goto Invalid_Outline;
       limit = outline->points + last;
 
-      v_start = outline->points[first];
-      v_last  = outline->points[last];
-
+      v_start   = outline->points[first];
       v_start.x = SCALED( v_start.x );
       v_start.y = SCALED( v_start.y );
 
-      v_last.x  = SCALED( v_last.x );
-      v_last.y  = SCALED( v_last.y );
+      v_last   = outline->points[last];
+      v_last.x = SCALED( v_last.x );
+      v_last.y = SCALED( v_last.y );
 
       v_control = v_start;
 
       point = outline->points + first;
-      tags  = outline->tags  + first;
+      tags  = outline->tags   + first;
       tag   = FT_CURVE_TAG( tags[0] );
 
       /* A contour cannot start with a cubic control point! */
@@ -1459,6 +1497,8 @@
         tags--;
       }
 
+      FT_TRACE5(( "  move to (%.2f, %.2f)\n",
+                  v_start.x / 64.0, v_start.y / 64.0 ));
       error = func_interface->move_to( &v_start, user );
       if ( error )
         goto Exit;
@@ -1479,6 +1519,8 @@
             vec.x = SCALED( point->x );
             vec.y = SCALED( point->y );
 
+            FT_TRACE5(( "  line to (%.2f, %.2f)\n",
+                        vec.x / 64.0, vec.y / 64.0 ));
             error = func_interface->line_to( &vec, user );
             if ( error )
               goto Exit;
@@ -1486,53 +1528,60 @@
           }
 
         case FT_CURVE_TAG_CONIC:  /* consume conic arcs */
-          {
-            v_control.x = SCALED( point->x );
-            v_control.y = SCALED( point->y );
+          v_control.x = SCALED( point->x );
+          v_control.y = SCALED( point->y );
 
-          Do_Conic:
-            if ( point < limit )
-            {
-              FT_Vector  vec;
-              FT_Vector  v_middle;
-
-
-              point++;
-              tags++;
-              tag = FT_CURVE_TAG( tags[0] );
-
-              vec.x = SCALED( point->x );
-              vec.y = SCALED( point->y );
+        Do_Conic:
+          if ( point < limit )
+          {
+            FT_Vector  vec;
+            FT_Vector  v_middle;
 
-              if ( tag == FT_CURVE_TAG_ON )
-              {
-                error = func_interface->conic_to( &v_control, &vec,
-                                                  user );
-                if ( error )
-                  goto Exit;
-                continue;
-              }
 
-              if ( tag != FT_CURVE_TAG_CONIC )
-                goto Invalid_Outline;
+            point++;
+            tags++;
+            tag = FT_CURVE_TAG( tags[0] );
 
-              v_middle.x = ( v_control.x + vec.x ) / 2;
-              v_middle.y = ( v_control.y + vec.y ) / 2;
+            vec.x = SCALED( point->x );
+            vec.y = SCALED( point->y );
 
-              error = func_interface->conic_to( &v_control, &v_middle,
-                                                user );
+            if ( tag == FT_CURVE_TAG_ON )
+            {
+              FT_TRACE5(( "  conic to (%.2f, %.2f)"
+                          " with control (%.2f, %.2f)\n",
+                          vec.x / 64.0, vec.y / 64.0,
+                          v_control.x / 64.0, v_control.y / 64.0 ));
+              error = func_interface->conic_to( &v_control, &vec, user );
               if ( error )
                 goto Exit;
-
-              v_control = vec;
-              goto Do_Conic;
+              continue;
             }
 
-            error = func_interface->conic_to( &v_control, &v_start,
-                                              user );
-            goto Close;
+            if ( tag != FT_CURVE_TAG_CONIC )
+              goto Invalid_Outline;
+
+            v_middle.x = ( v_control.x + vec.x ) / 2;
+            v_middle.y = ( v_control.y + vec.y ) / 2;
+
+            FT_TRACE5(( "  conic to (%.2f, %.2f)"
+                        " with control (%.2f, %.2f)\n",
+                        v_middle.x / 64.0, v_middle.y / 64.0,
+                        v_control.x / 64.0, v_control.y / 64.0 ));
+            error = func_interface->conic_to( &v_control, &v_middle, user );
+            if ( error )
+              goto Exit;
+
+            v_control = vec;
+            goto Do_Conic;
           }
 
+          FT_TRACE5(( "  conic to (%.2f, %.2f)"
+                      " with control (%.2f, %.2f)\n",
+                      v_start.x / 64.0, v_start.y / 64.0,
+                      v_control.x / 64.0, v_control.y / 64.0 ));
+          error = func_interface->conic_to( &v_control, &v_start, user );
+          goto Close;
+
         default:  /* FT_CURVE_TAG_CUBIC */
           {
             FT_Vector  vec1, vec2;
@@ -1559,12 +1608,22 @@
               vec.x = SCALED( point->x );
               vec.y = SCALED( point->y );
 
+              FT_TRACE5(( "  cubic to (%.2f, %.2f)"
+                          " with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
+                          vec.x / 64.0, vec.y / 64.0,
+                          vec1.x / 64.0, vec1.y / 64.0,
+                          vec2.x / 64.0, vec2.y / 64.0 ));
               error = func_interface->cubic_to( &vec1, &vec2, &vec, user );
               if ( error )
                 goto Exit;
               continue;
             }
 
+            FT_TRACE5(( "  cubic to (%.2f, %.2f)"
+                        " with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
+                        v_start.x / 64.0, v_start.y / 64.0,
+                        vec1.x / 64.0, vec1.y / 64.0,
+                        vec2.x / 64.0, vec2.y / 64.0 ));
             error = func_interface->cubic_to( &vec1, &vec2, &v_start, user );
             goto Close;
           }
@@ -1572,6 +1631,8 @@
       }
 
       /* close the contour with a line segment */
+      FT_TRACE5(( "  line to (%.2f, %.2f)\n",
+                  v_start.x / 64.0, v_start.y / 64.0 ));
       error = func_interface->line_to( &v_start, user );
 
    Close:
@@ -1581,9 +1642,11 @@
       first = last + 1;
     }
 
+    FT_TRACE5(( "FT_Outline_Decompose: Done\n", n ));
     return 0;
 
   Exit:
+    FT_TRACE5(( "FT_Outline_Decompose: Error %d\n", error ));
     return error;
 
   Invalid_Outline:
@@ -1665,7 +1728,7 @@
     ras.cubic_level = 16;
 
     {
-      int level = 0;
+      int  level = 0;
 
 
       if ( ras.count_ex > 24 || ras.count_ey > 24 )
@@ -1761,8 +1824,8 @@
         /* be some problems.                                     */
         if ( middle == bottom )
         {
-#ifdef DEBUG_GRAYS
-          fprintf( stderr, "Rotten glyph!\n" );
+#ifdef FT_DEBUG_LEVEL_TRACE
+          FT_TRACE7(( "gray_convert_glyph: Rotten glyph!\n" ));
 #endif
           return 1;
         }
@@ -1876,8 +1939,8 @@
   }
 
 
-  /**** RASTER OBJECT CREATION: In standalone mode, we simply use *****/
-  /****                         a static object.                  *****/
+  /**** RASTER OBJECT CREATION: In stand-alone mode, we simply use *****/
+  /****                         a static object.                   *****/
 
 #ifdef _STANDALONE_
 
@@ -1985,3 +2048,8 @@
 
 
 /* END */
+
+
+/* Local Variables: */
+/* coding: utf-8    */
+/* End:             */