Commit c740c19112373983c5ef56d653f9d19515b61f09

Werner Lemberg 2005-03-23T17:44:34

* tests/*: Removed.

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
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
diff --git a/ChangeLog b/ChangeLog
index 3545eb1..ea8ffd2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2005-03-23  Werner Lemberg  <wl@gnu.org>
 
+	* tests/*: Removed.
+
+2005-03-23  Werner Lemberg  <wl@gnu.org>
+
 	* docs/CHANGES, docs/INSTALL.ANY: Updated.
 
 	* include/freetype/ftmoderr.h: Replace `Autohint' with `Autofit'.
diff --git a/tests/Jamfile b/tests/Jamfile
deleted file mode 100644
index 0470922..0000000
--- a/tests/Jamfile
+++ /dev/null
@@ -1,41 +0,0 @@
-# FreeType 2 src Jamfile (c) 2001 David Turner
-#
-
-SubDir  FT2_TOP tests ;
-
-test_programs = gview ;
-
-SubDirHdrs [ FT2_SubDir  .. nirvana include ] ;
-
-NV_TOP = [ FT2_SubDir .. .. nirvana ] ;
-
-NIRVANA_LINKLIBS = $(NV_TOP)/objs/libnirvana$(SUFLIB) ;
-
-{
-  local t ;
-
-  for t in $(test_programs)
-  {
-    Main  $(t) : $(t).c ;
-
-    LinkLibraries $(t) : $(FT2_LIB) ;
-
-    if $(WIN)
-    {
-      if $(TOOLSET) = MINGW
-      {
-        LINKKLIBS on $(t)$(SUFEXE) = "-luser32 -lgdi32" ;
-      }
-      else
-      {
-        LINKLIBS on $(t)$(SUFEXE) = user32.lib gdi32.lib ;
-      }
-    }
-    else
-    {
-      LINKLIBS on $(t)$(SUFEXE) = -L/usr/X11R6/lib -lX11 -lm ;
-    }
-
-    NEEDLIBS on $(t)$(SUFEXE) += $(NIRVANA_LINKLIBS) ;
-  }
-}
diff --git a/tests/gview.c b/tests/gview.c
deleted file mode 100644
index f685985..0000000
--- a/tests/gview.c
+++ /dev/null
@@ -1,1292 +0,0 @@
-#include <nirvana.h>
-#include NV_VIEWPORT_H
-#include <stdio.h>
-
-#include <ft2build.h>
-#include FT_FREETYPE_H
-
-/* include FreeType internals to debug hints */
-#include <../src/pshinter/pshrec.h>
-#include <../src/pshinter/pshalgo.h>
-
-#include <../src/autohint/ahtypes.h>
-
- /************************************************************************/
- /************************************************************************/
- /*****                                                              *****/
- /*****                     ROOT DEFINITIONS                         *****/
- /*****                                                              *****/
- /************************************************************************/
- /************************************************************************/
-
-
-#include <time.h>    /* for clock() */
-
-  /* SunOS 4.1.* does not define CLOCKS_PER_SEC, so include <sys/param.h> */
-  /* to get the HZ macro which is the equivalent.                         */
-#if defined( __sun__ ) && !defined( SVR4 ) && !defined( __SVR4 )
-#include <sys/param.h>
-#define CLOCKS_PER_SEC HZ
-#endif
-
-static int  first_glyph = 0;
-
-static NV_Renderer   renderer;
-static NV_Painter    painter;
-static NV_Pixmap     target;
-static NV_Error      error;
-static NV_Memory     memory;
-static NVV_Display   display;
-static NVV_Surface   surface;
-
-static FT_Library    freetype;
-static FT_Face       face;
-
-
-static  NV_Pos        glyph_scale;
-static  NV_Pos        glyph_org_x;
-static  NV_Pos        glyph_org_y;
-static  NV_Transform  glyph_transform;  /* font units -> device pixels */
-static  NV_Transform  size_transform;   /* subpixels  -> device pixels */
-
-static  NV_Scale      grid_scale = 1.0;
-
-static  int   glyph_index;
-static  int   pixel_size = 12;
-
-
- /************************************************************************/
- /************************************************************************/
- /*****                                                              *****/
- /*****                 OPTIONS, COLORS and OTHERS                   *****/
- /*****                                                              *****/
- /************************************************************************/
- /************************************************************************/
-
-static  int   option_show_axis     = 1;
-static  int   option_show_dots     = 1;
-static  int   option_show_stroke   = 0;
-static  int   option_show_glyph    = 1;
-static  int   option_show_grid     = 1;
-static  int   option_show_em       = 0;
-static  int   option_show_smooth   = 1;
-static  int   option_show_blues    = 0;
-static  int   option_show_edges    = 0;
-static  int   option_show_segments = 1;
-static  int   option_show_links    = 1;
-static  int   option_show_indices  = 0;
-
-static  int   option_show_ps_hints   = 1;
-static  int   option_show_horz_hints = 1;
-static  int   option_show_vert_hints = 1;
-
-
-static  int   option_hinting = 1;
-
-static  char  temp_message[1024];
-
-static  NV_Path   symbol_dot     = NULL;
-static  NV_Path   symbol_circle  = NULL;
-static  NV_Path   symbol_square  = NULL;
-static  NV_Path   symbol_rect_h  = NULL;
-static  NV_Path   symbol_rect_v  = NULL;
-
-
-
-#define  AXIS_COLOR        0xFFFF0000
-#define  GRID_COLOR        0xFFD0D0D0
-#define  ON_COLOR          0xFFFF2000
-#define  OFF_COLOR         0xFFFF0080
-#define  STRONG_COLOR      0xFF404040
-#define  INTERP_COLOR      0xFF206040
-#define  SMOOTH_COLOR      0xF000B040
-#define  BACKGROUND_COLOR  0xFFFFFFFF
-#define  TEXT_COLOR        0xFF000000
-#define  EM_COLOR          0x80008000
-#define  BLUES_TOP_COLOR   0x4000008F
-#define  BLUES_BOT_COLOR   0x40008F00
-
-#define  GHOST_HINT_COLOR  0xE00000FF
-#define  STEM_HINT_COLOR   0xE02020FF
-#define  STEM_JOIN_COLOR   0xE020FF20
-
-#define  EDGE_COLOR        0xF0704070
-#define  SEGMENT_COLOR     0xF0206040
-#define  LINK_COLOR        0xF0FFFF00
-#define  SERIF_LINK_COLOR  0xF0FF808F
-
-
-/* print message and abort program */
-static void
-Panic( const char*  message )
-{
-  fprintf( stderr, "PANIC: %s\n", message );
-  exit(1);
-}
-
-
-static void
-init_symbols( void )
-{
-  nv_path_new_rectangle( renderer, -1, -1, 3, 3, 0, 0, &symbol_square );
-  nv_path_new_rectangle( renderer, -1, -6, 2, 12, 0, 0, &symbol_rect_v );
-  nv_path_new_rectangle( renderer, -6, -1, 12, 2, 0, 0, &symbol_rect_h );
-
-  nv_path_new_circle( renderer, 0, 0, 3., &symbol_dot );
-
-  nv_path_stroke( symbol_dot, 0.6,
-                  nv_path_linecap_butt,
-                  nv_path_linejoin_miter, 1.,
-                  &symbol_circle );
-
-  nv_path_destroy( symbol_dot );
-
-  nv_path_new_circle( renderer, 0, 0, 2., &symbol_dot );
- }
-
-
-static void
-done_symbols( void )
-{
-  nv_path_destroy( symbol_circle );
-  nv_path_destroy( symbol_dot );
-  nv_path_destroy( symbol_rect_v );
-  nv_path_destroy( symbol_rect_h );
-  nv_path_destroy( symbol_square );
-}
-
-
-  /************************************************************************/
-  /************************************************************************/
-  /*****                                                              *****/
-  /*****               COMMON GRID DRAWING ROUTINES                   *****/
-  /*****                                                              *****/
-  /************************************************************************/
-  /************************************************************************/
-
-static void
-reset_scale( NV_Scale  scale )
-{
-  /* compute font units -> grid pixels scale factor */
-  glyph_scale = target->width*0.75 / face->units_per_EM * scale;
-
-  /* setup font units -> grid pixels transform */
-  nv_transform_set_scale( &glyph_transform, glyph_scale, -glyph_scale );
-  glyph_org_x = glyph_transform.delta.x = target->width*0.125;
-  glyph_org_y = glyph_transform.delta.y = target->height*0.875;
-
-  /* setup subpixels -> grid pixels transform */
-  nv_transform_set_scale(
-    &size_transform,
-    glyph_scale / nv_fromfixed( face->size->metrics.x_scale ),
-    -glyph_scale / nv_fromfixed( face->size->metrics.y_scale ) );
-
-  size_transform.delta = glyph_transform.delta;
-}
-
-
-static void
-reset_size( int       pixel_size,
-            NV_Scale  scale )
-{
-  FT_Set_Pixel_Sizes( face, pixel_size, pixel_size );
-  reset_scale( scale );
-}
-
-
-static void
-clear_background( void )
-{
-  nv_pixmap_fill_rect( target, 0, 0, target->width, target->height,
-                       BACKGROUND_COLOR );
-}
-
-
-static void
-draw_grid( void )
-{
-  int  x = (int)glyph_org_x;
-  int  y = (int)glyph_org_y;
-
-
-  /* draw grid */
-  if ( option_show_grid )
-  {
-    NV_Scale  min, max, x, step;
-
-
-    /* draw vertical grid bars */
-    step = 64. * size_transform.matrix.xx;
-    if ( step > 1. )
-    {
-      min = max = glyph_org_x;
-      while ( min - step >= 0 )             min -= step;
-      while ( max + step < target->width )  max += step;
-
-      for ( x = min; x <= max; x += step )
-        nv_pixmap_fill_rect( target, (NV_Int)(x + .5), 0,
-                             1, target->height, GRID_COLOR );
-    }
-
-    /* draw horizontal grid bars */
-    step = -64. * size_transform.matrix.yy;
-    if ( step > 1. )
-    {
-      min = max = glyph_org_y;
-      while ( min - step >= 0 )              min -= step;
-      while ( max + step < target->height )  max += step;
-
-      for ( x = min; x <= max; x += step )
-        nv_pixmap_fill_rect( target, 0, (NV_Int)(x + .5),
-                             target->width, 1, GRID_COLOR );
-    }
-  }
-
-  /* draw axis */
-  if ( option_show_axis )
-  {
-    nv_pixmap_fill_rect( target, x, 0, 1, target->height, AXIS_COLOR );
-    nv_pixmap_fill_rect( target, 0, y, target->width, 1, AXIS_COLOR );
-  }
-
-  if ( option_show_em )
-  {
-    NV_Path  path;
-    NV_Path  stroke;
-    NV_UInt  units = (NV_UInt)face->units_per_EM;
-
-
-    nv_path_new_rectangle( renderer, 0, 0, units, units, 0, 0, &path );
-    nv_path_transform( path, &glyph_transform );
-
-    nv_path_stroke( path, 1.5, nv_path_linecap_butt, nv_path_linejoin_miter,
-                    4.0, &stroke );
-
-    nv_painter_set_color( painter, EM_COLOR, 256 );
-    nv_painter_fill_path( painter, NULL, 0, stroke );
-
-    nv_path_destroy( stroke );
-    nv_path_destroy( path );
-  }
-
-}
-
-
-  /************************************************************************/
-  /************************************************************************/
-  /*****                                                              *****/
-  /*****                 POSTSCRIPT GLOBALS ROUTINES                  *****/
-  /*****                                                              *****/
-  /************************************************************************/
-  /************************************************************************/
-
-#include <../src/pshinter/pshglob.h>
-
-static void
-draw_ps_blue_zones( void )
-{
-  if ( option_show_blues && ps_debug_globals )
-  {
-    PSH_Blues       blues = &ps_debug_globals->blues;
-    PSH_Blue_Table  table;
-    NV_Vector       v;
-    FT_Int          y1, y2;
-    FT_UInt         count;
-    PSH_Blue_Zone   zone;
-
-
-    /* draw top zones */
-    table = &blues->normal_top;
-    count = table->count;
-    zone  = table->zones;
-
-    for ( ; count > 0; count--, zone++ )
-    {
-      v.x = 0;
-      if ( !ps_debug_no_horz_hints )
-      {
-        v.y = zone->cur_ref + zone->cur_delta;
-        nv_vector_transform( &v, &size_transform );
-      }
-      else
-      {
-        v.y = zone->org_ref + zone->org_delta;
-        nv_vector_transform( &v, &glyph_transform );
-      }
-      y1  = (int)(v.y + 0.5);
-
-      v.x = 0;
-      if ( !ps_debug_no_horz_hints )
-      {
-        v.y = zone->cur_ref;
-        nv_vector_transform( &v, &size_transform );
-      }
-      else
-      {
-        v.y = zone->org_ref;
-        nv_vector_transform( &v, &glyph_transform );
-      }
-      y2 = (int)(v.y + 0.5);
-
-      nv_pixmap_fill_rect( target, 0, y1,
-                           target->width, y2-y1+1,
-                           BLUES_TOP_COLOR );
-
-#if 0
-      printf( "top [%.3f %.3f]\n", zone->cur_bottom/64.0, zone->cur_top/64.0 );
-#endif
-    }
-
-
-    /* draw bottom zones */
-    table = &blues->normal_bottom;
-    count = table->count;
-    zone  = table->zones;
-
-    for ( ; count > 0; count--, zone++ )
-    {
-      v.x = 0;
-      v.y = zone->cur_ref;
-      nv_vector_transform( &v, &size_transform );
-      y1  = (int)(v.y + 0.5);
-
-      v.x = 0;
-      v.y = zone->cur_ref + zone->cur_delta;
-      nv_vector_transform( &v, &size_transform );
-      y2 = (int)(v.y + 0.5);
-
-      nv_pixmap_fill_rect( target, 0, y1,
-                           target->width, y2 - y1 + 1,
-                           BLUES_BOT_COLOR );
-
-#if 0
-      printf( "bot [%.3f %.3f]\n", zone->cur_bottom/64.0, zone->cur_top/64.0 );
-#endif
-    }
-  }
-}
-
-
- /************************************************************************/
- /************************************************************************/
- /*****                                                              *****/
- /*****            POSTSCRIPT HINTER ALGORITHM ROUTINES              *****/
- /*****                                                              *****/
- /************************************************************************/
- /************************************************************************/
-
-#include <../src/pshinter/pshalgo.h>
-
-static void
-draw_ps_hint( PSH_Hint  hint, 
-              FT_Bool   vertical )
-{
-  int        x1, x2;
-  NV_Vector  v;
-
-
-  if ( pshint_vertical != vertical )
-  {
-    if ( vertical )
-      pshint_cpos = 40;
-    else
-      pshint_cpos = 10;
-
-    pshint_vertical = vertical;
-  }
-
-  if ( !vertical )
-  {
-    if ( !option_show_vert_hints )
-      return;
-
-    v.x = hint->cur_pos;
-    v.y = 0;
-    nv_vector_transform( &v, &size_transform );
-    x1 = (int)(v.x + 0.5);
-
-    v.x = hint->cur_pos + hint->cur_len;
-    v.y = 0;
-    nv_vector_transform( &v, &size_transform );
-    x2 = (int)(v.x + 0.5);
-
-    nv_pixmap_fill_rect( target, x1, 0, 1, target->height,
-                         psh_hint_is_ghost( hint )
-                         ? GHOST_HINT_COLOR : STEM_HINT_COLOR );
-
-    if ( psh_hint_is_ghost( hint ) )
-    {
-      x1 --;
-      x2 = x1 + 2;
-    }
-    else
-      nv_pixmap_fill_rect( target, x2, 0, 1, target->height,
-                           psh_hint_is_ghost( hint )
-                           ? GHOST_HINT_COLOR : STEM_HINT_COLOR );
-
-    nv_pixmap_fill_rect( target, x1, pshint_cpos, x2 + 1 - x1, 1,
-                         STEM_JOIN_COLOR );
-  }
-  else
-  {
-    if ( !option_show_horz_hints )
-      return;
-
-    v.y = hint->cur_pos;
-    v.x = 0;
-    nv_vector_transform( &v, &size_transform );
-    x1 = (int)(v.y + 0.5);
-
-    v.y = hint->cur_pos + hint->cur_len;
-    v.x = 0;
-    nv_vector_transform( &v, &size_transform );
-    x2 = (int)(v.y + 0.5);
-
-    nv_pixmap_fill_rect( target, 0, x1, target->width, 1,
-                         psh_hint_is_ghost( hint )
-                         ? GHOST_HINT_COLOR : STEM_HINT_COLOR );
-
-    if ( psh_hint_is_ghost( hint ) )
-    {
-      x1 --;
-      x2 = x1 + 2;
-    }
-    else
-      nv_pixmap_fill_rect( target, 0, x2, target->width, 1,
-                           psh_hint_is_ghost(hint)
-                           ? GHOST_HINT_COLOR : STEM_HINT_COLOR );
-
-    nv_pixmap_fill_rect( target, pshint_cpos, x2, 1, x1 + 1 - x2,
-                         STEM_JOIN_COLOR );
-  }
-
-#if 0
-  printf( "[%7.3f %7.3f] %c\n", hint->cur_pos/64.0, (hint->cur_pos+hint->cur_len)/64.0, vertical ? 'v' : 'h' );
-#endif
-
-  pshint_cpos += 10;
-}
-
-
-static void
-ps_draw_control_points( void )
-{
-  if ( ps_debug_glyph )
-  {
-    PSH_Glyph     glyph = ps_debug_glyph;
-    PSH_Point     point = glyph->points;
-    FT_UInt       count = glyph->num_points;
-    NV_Transform  transform, *trans = &transform;
-    NV_Path       vert_rect;
-    NV_Path       horz_rect;
-    NV_Path       dot, circle;
-
-
-    for ( ; count > 0; count--, point++ )
-    {
-      NV_Vector  vec;
-
-
-      vec.x = point->cur_x;
-      vec.y = point->cur_y;
-      nv_vector_transform( &vec, &size_transform );
-
-      nv_transform_set_translate( trans, vec.x, vec.y );
-
-      if ( option_show_smooth && !psh_point_is_smooth(point) )
-      {
-        nv_painter_set_color( painter, SMOOTH_COLOR, 256 );
-        nv_painter_fill_path( painter, trans, 0, symbol_circle );
-      }
-
-      if ( option_show_horz_hints )
-      {
-        if ( point->flags_y & PSH_POINT_STRONG )
-        {
-          nv_painter_set_color( painter, STRONG_COLOR, 256 );
-          nv_painter_fill_path( painter, trans, 0, symbol_rect_h );
-        }
-      }
-
-      if ( option_show_vert_hints )
-      {
-        if ( point->flags_x & PSH_POINT_STRONG )
-        {
-          nv_painter_set_color( painter, STRONG_COLOR, 256 );
-          nv_painter_fill_path( painter, trans, 0, symbol_rect_v );
-        }
-      }
-    }
-  }
-}
-
-
-static void
-ps_print_hints( void )
-{
-  if ( ps_debug_hints )
-  {
-    FT_Int         dimension;
-
-
-    for ( dimension = 1; dimension >= 0; dimension-- )
-    {
-      PS_Dimension  dim   = &ps_debug_hints->dimension[ dimension ];
-      PS_Mask       mask  = dim->masks.masks;
-      FT_UInt       count = dim->masks.num_masks;
-
-
-      printf( "%s hints -------------------------\n",
-              dimension ? "vertical" : "horizontal" );
-
-      for ( ; count > 0; count--, mask++ )
-      {
-        FT_UInt  index;
-
-
-        printf( "mask -> %d\n", mask->end_point );
-        for ( index = 0; index < mask->num_bits; index++ )
-        {
-          if ( mask->bytes[ index >> 3 ] & (0x80 >> (index & 7)) )
-          {
-            PS_Hint  hint = dim->hints.hints + index;
-
-
-            printf( "%c [%3d %3d (%4d)]\n", dimension ? "v" : "h",
-                    hint->pos, hint->pos + hint->len, hint->len );
-          }
-        }
-      }
-    }
-  }
-}
-
-
-  /************************************************************************/
-  /************************************************************************/
-  /*****                                                              *****/
-  /*****            AUTOHINTER DRAWING ROUTINES                       *****/
-  /*****                                                              *****/
-  /************************************************************************/
-  /************************************************************************/
-
-static NV_Path
-ah_link_path( NV_Vector*  p1,
-              NV_Vector*  p4,
-              NV_Bool     vertical )
-{
-  NV_PathWriter  writer;
-  NV_Vector      p2, p3;
-  NV_Path        path, stroke;
-
-
-  if ( vertical )
-  {
-    p2.x = p4->x;
-    p2.y = p1->y;
-
-    p3.x = p1->x;
-    p3.y = p4->y;
-  }
-  else
-  {
-    p2.x = p1->x;
-    p2.y = p4->y;
-
-    p3.x = p4->x;
-    p3.y = p1->y;
-  }
-
-  nv_path_writer_new( renderer, &writer );
-  nv_path_writer_moveto( writer, p1 );
-  nv_path_writer_cubicto( writer, &p2, &p3, p4 );
-  nv_path_writer_end( writer );
-
-  path = nv_path_writer_get_path( writer );
-  nv_path_writer_destroy( writer );
-
-  nv_path_stroke( path, 1.,
-                  nv_path_linecap_butt, nv_path_linejoin_round,
-                  1., &stroke );
-
-  nv_path_destroy( path );
-
-  return stroke;
-}
-
-
-static void
-ah_draw_smooth_points( void )
-{
-  if ( ah_debug_hinter && option_show_smooth )
-  {
-    AH_Outline   glyph = ah_debug_hinter->glyph;
-    FT_UInt      count = glyph->num_points;
-    AH_Point     point = glyph->points;
-
-
-    nv_painter_set_color( painter, SMOOTH_COLOR, 256 );
-
-    for ( ; count > 0; count--, point++ )
-    {
-      if ( !( point->flags & AH_FLAG_WEAK_INTERPOLATION ) )
-      {
-        NV_Transform  transform, *trans = &transform;
-        NV_Vector     vec;
-
-
-        vec.x = point->x - ah_debug_hinter->pp1.x;
-        vec.y = point->y;
-        nv_vector_transform( &vec, &size_transform );
-
-        nv_transform_set_translate( &transform, vec.x, vec.y );
-        nv_painter_fill_path( painter, trans, 0, symbol_circle );
-      }
-    }
-  }
-}
-
-
-static void
-ah_draw_edges( void )
-{
-  if ( ah_debug_hinter )
-  {
-    AH_Outline  glyph = ah_debug_hinter->glyph;
-    FT_UInt     count;
-    AH_Edge     edge;
-    FT_Pos      pp1 = ah_debug_hinter->pp1.x;
-
-
-    nv_painter_set_color( painter, EDGE_COLOR, 256 );
-
-    if ( option_show_edges )
-    {
-      /* draw vertical edges */
-      if ( option_show_vert_hints )
-      {
-        count = glyph->num_vedges;
-        edge  = glyph->vert_edges;
-        for ( ; count > 0; count--, edge++ )
-        {
-          NV_Vector  vec;
-          NV_Pos     x;
-
-
-          vec.x = edge->pos - pp1;
-          vec.y = 0;
-
-          nv_vector_transform( &vec, &size_transform );
-          x = (FT_Pos)( vec.x + 0.5 );
-
-          nv_pixmap_fill_rect( target, x, 0, 1, target->height, EDGE_COLOR );
-        }
-      }
-
-      /* draw horizontal edges */
-      if ( option_show_horz_hints )
-      {
-        count = glyph->num_hedges;
-        edge  = glyph->horz_edges;
-        for ( ; count > 0; count--, edge++ )
-        {
-          NV_Vector  vec;
-          NV_Pos     x;
-
-
-          vec.x = 0;
-          vec.y = edge->pos;
-
-          nv_vector_transform( &vec, &size_transform );
-          x = (FT_Pos)( vec.y + 0.5 );
-
-          nv_pixmap_fill_rect( target, 0, x, target->width, 1, EDGE_COLOR );
-        }
-      }
-    }
-
-    if ( option_show_segments )
-    {
-      /* draw vertical segments */
-      if ( option_show_vert_hints )
-      {
-        AH_Segment  seg   = glyph->vert_segments;
-        FT_UInt     count = glyph->num_vsegments;
-
-
-        for ( ; count > 0; count--, seg++ )
-        {
-          AH_PointRec  *first, *last;
-          NV_Vector  v1, v2;
-          NV_Pos     y1, y2, x;
-
-
-          first = seg->first;
-          last  = seg->last;
-
-          v1.x = v2.x = first->x - pp1;
-
-          if ( first->y <= last->y )
-          {
-            v1.y = first->y;
-            v2.y = last->y;
-          }
-          else
-          {
-            v1.y = last->y;
-            v2.y = first->y;
-          }
-
-          nv_vector_transform( &v1, &size_transform );
-          nv_vector_transform( &v2, &size_transform );
-
-          y1 = (NV_Pos)( v1.y + 0.5 );
-          y2 = (NV_Pos)( v2.y + 0.5 );
-          x  = (NV_Pos)( v1.x + 0.5 );
-
-          nv_pixmap_fill_rect( target, x - 1, y2, 3,
-                               FT_ABS( y1 - y2 ) + 1, SEGMENT_COLOR );
-        }
-      }
-
-      /* draw horizontal segments */
-      if ( option_show_horz_hints )
-      {
-        AH_Segment  seg   = glyph->horz_segments;
-        FT_UInt     count = glyph->num_hsegments;
-
-
-        for ( ; count > 0; count--, seg++ )
-        {
-          AH_PointRec  *first, *last;
-          NV_Vector    v1, v2;
-          NV_Pos       y1, y2, x;
-
-
-          first = seg->first;
-          last  = seg->last;
-
-          v1.y = v2.y = first->y;
-
-          if ( first->x <= last->x )
-          {
-            v1.x = first->x - pp1;
-            v2.x = last->x - pp1;
-          }
-          else
-          {
-            v1.x = last->x - pp1;
-            v2.x = first->x - pp1;
-          }
-
-          nv_vector_transform( &v1, &size_transform );
-          nv_vector_transform( &v2, &size_transform );
-
-          y1 = (NV_Pos)( v1.x + 0.5 );
-          y2 = (NV_Pos)( v2.x + 0.5 );
-          x  = (NV_Pos)( v1.y + 0.5 );
-
-          nv_pixmap_fill_rect( target, y1, x - 1,
-                               FT_ABS( y1 - y2 ) + 1, 3, SEGMENT_COLOR );
-        }
-      }
-
-      if ( option_show_vert_hints && option_show_links )
-      {
-        AH_Segment  seg   = glyph->vert_segments;
-        FT_UInt     count = glyph->num_vsegments;
-
-
-        for ( ; count > 0; count--, seg++ )
-        {
-          AH_Segment  seg2 = NULL;
-          NV_Path     link;
-          NV_Vector   v1, v2;
-
-
-          if ( seg->link )
-          {
-            if ( seg->link > seg )
-              seg2 = seg->link;
-          }
-          else if ( seg->serif )
-            seg2 = seg->serif;
-
-          if ( seg2 )
-          {
-            v1.x = seg->first->x  - pp1;
-            v2.x = seg2->first->x - pp1;
-            v1.y = ( seg->first->y + seg->last->y ) / 2;
-            v2.y = ( seg2->first->y + seg2->last->y ) / 2;
-
-            link = ah_link_path( &v1, &v2, 1 );
-
-            nv_painter_set_color( painter,
-                                  seg->serif ? SERIF_LINK_COLOR : LINK_COLOR,
-                                  256 );
-            nv_painter_fill_path( painter, &size_transform, 0, link );
-
-            nv_path_destroy( link );
-          }
-        }
-      }
-
-      if ( option_show_horz_hints && option_show_links )
-      {
-        AH_Segment  seg   = glyph->horz_segments;
-        FT_UInt     count = glyph->num_hsegments;
-
-
-        for ( ; count > 0; count--, seg++ )
-        {
-          AH_Segment  seg2 = NULL;
-          NV_Path     link;
-          NV_Vector   v1, v2;
-
-
-          if ( seg->link )
-          {
-            if ( seg->link > seg )
-              seg2 = seg->link;
-          }
-          else if ( seg->serif )
-            seg2 = seg->serif;
-
-          if ( seg2 )
-          {
-            v1.y = seg->first->y;
-            v2.y = seg2->first->y;
-            v1.x = ( seg->first->x + seg->last->x ) / 2 - pp1;
-            v2.x = ( seg2->first->x + seg2->last->x ) / 2 - pp1;
-
-            link = ah_link_path( &v1, &v2, 0 );
-
-            nv_painter_set_color( painter,
-                                  seg->serif ? SERIF_LINK_COLOR : LINK_COLOR,
-                                  256 );
-            nv_painter_fill_path( painter, &size_transform, 0, link );
-
-            nv_path_destroy( link );
-          }
-        }
-      }
-    }
-  }
-}
-
-
-  /************************************************************************/
-  /************************************************************************/
-  /*****                                                              *****/
-  /*****                        MAIN LOOP(S)                          *****/
-  /*****                                                              *****/
-  /************************************************************************/
-  /************************************************************************/
-
-static void
-draw_glyph( int  glyph_index )
-{
-  NV_Path   path;
-
-
-  pshint_vertical = -1;
-
-  ps_debug_hint_func = option_show_ps_hints ? draw_ps_hint : 0;
-
-  ah_debug_hinter = NULL;
-
-  error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_BITMAP );
-  if ( error )
-    Panic( "could not load glyph" );
-
-  if ( face->glyph->format != FT_GLYPH_FORMAT_OUTLINE )
-    Panic( "could not load glyph outline" );
-
-  error = nv_path_new_from_outline( renderer,
-                                    (NV_Outline*)&face->glyph->outline,
-                                    &size_transform,
-                                    &path );
-  if ( error )
-    Panic( "could not create glyph path" );
-
-  /* tracé du glyphe plein */
-  if ( option_show_glyph )
-  {
-    nv_painter_set_color( painter, 0xFF404080, 128 );
-    nv_painter_fill_path( painter, 0, 0, path );
-  }
-
-  if ( option_show_stroke )
-  {
-    NV_Path  stroke;
-
-
-    error = nv_path_stroke( path, 0.6,
-                            nv_path_linecap_butt,
-                            nv_path_linejoin_miter,
-                            1.0, &stroke );
-    if ( error )
-      Panic( "could not stroke glyph path" );
-
-    nv_painter_set_color( painter, 0xFF000040, 256 );
-    nv_painter_fill_path( painter, 0, 0, stroke );
-
-    nv_path_destroy( stroke );
-  }
-
-  /* tracé des points de controle */
-  if ( option_show_dots )
-  {
-    NV_Path     plot;
-    NV_Outline  out;
-    NV_Scale    r = 2;
-    NV_Int      n, first, last;
-
-
-    nv_path_get_outline( path, NULL, memory, &out );
-
-    first = 0;
-    for ( n = 0; n < out.n_contours; n++ )
-    {
-      int            m;
-      NV_Transform   trans;
-      NV_Color       color;
-      NV_SubVector*  vec;
-
-
-      last  = out.contours[n];
-
-      for ( m = first; m <= last; m++ )
-      {
-        color = (out.tags[m] & FT_CURVE_TAG_ON)
-              ? ON_COLOR
-              : OFF_COLOR;
-
-        vec = out.points + m;
-
-        nv_transform_set_translate( &trans, vec->x / 64.0, vec->y / 64.0 );
-
-        nv_painter_set_color( painter, color, 256 );
-        nv_painter_fill_path( painter, &trans, 0, symbol_dot );
-
-        if ( option_show_indices )
-        {
-          char  temp[5];
-
-
-          sprintf( temp, "%d", m );
-          nv_pixmap_cell_text( target, vec->x / 64 + 4, vec->y / 64 - 4,
-                               temp, TEXT_COLOR );
-        }
-      }
-
-      first = last + 1;
-    }
-  }
-
-  ah_draw_smooth_points();
-  ah_draw_edges();
-
-  nv_path_destroy( path );
-
-  /* autre infos */
-  {
-    char  temp[1024];
-    char  temp2[64];
-
-
-    sprintf( temp, "font name : %s (%s)", face->family_name,
-                                          face->style_name );
-    nv_pixmap_cell_text( target, 0, 0, temp, TEXT_COLOR );
-
-    FT_Get_Glyph_Name( face, glyph_index, temp2, 63 );
-    temp2[63] = 0;
-
-    sprintf( temp, "glyph %4d: %s", glyph_index, temp2 );
-    nv_pixmap_cell_text( target, 0, 8, temp, TEXT_COLOR );
-
-    if ( temp_message[0] )
-    {
-      nv_pixmap_cell_text( target, 0, 16, temp_message, TEXT_COLOR );
-      temp_message[0] = 0;
-    }
-  }
-}
-
-
-#define  TOGGLE_OPTION(var,prefix)                           \
-            do                                               \
-            {                                                \
-              var = !var;                                    \
-              sprintf( temp_message, prefix " is now %s",    \
-                       var ? "on" : "off" );                 \
-            }                                                \
-            while()
-
-
-#define  TOGGLE_OPTION_NEG(var,prefix)                       \
-            do                                               \
-            {                                                \
-              var = !var;                                    \
-              sprintf( temp_message, prefix " is now %s",    \
-                       !var ? "on" : "off" );                \
-            }                                                \
-            while
-
-
-static void
-handle_event( NVV_EventRec*  ev )
-{
-  switch ( ev->key )
-  {
-  case NVV_Key_Left:
-    if ( glyph_index > 0 )
-      glyph_index--;
-    break;
-
-  case NVV_Key_Right:
-    if ( glyph_index + 1 < face->num_glyphs )
-      glyph_index++;
-    break;
-
-  case NVV_KEY( 'x' ):
-    TOGGLE_OPTION( option_show_axis, "grid axis display" );
-    break;
-
-  case NVV_KEY( 's' ):
-    TOGGLE_OPTION( option_show_stroke, "glyph stroke display" );
-    break;
-
-  case NVV_KEY( 'g' ):
-    TOGGLE_OPTION( option_show_glyph, "glyph fill display" );
-    break;
-
-  case NVV_KEY( 'd' ):
-    TOGGLE_OPTION( option_show_dots, "control points display" );
-    break
-
-  case NVV_KEY( 'e' ):
-    TOGGLE_OPTION( option_show_em, "EM square display" );
-    break;
-
-  case NVV_KEY( '+' ):
-    grid_scale *= 1.2;
-    reset_scale( grid_scale );
-    break;
-
-  case NVV_KEY( '-' ):
-    if ( grid_scale > 0.3 )
-    {
-      grid_scale /= 1.2;
-      reset_scale( grid_scale );
-    }
-    break;
-
-  case NVV_Key_Up:
-    pixel_size++;
-    reset_size( pixel_size, grid_scale );
-    sprintf( temp_message, "pixel size = %d", pixel_size );
-    break;
-
-  case NVV_Key_Down:
-    if ( pixel_size > 1 )
-    {
-      pixel_size--;
-      reset_size( pixel_size, grid_scale );
-      sprintf( temp_message, "pixel size = %d", pixel_size );
-    }
-    break;
-
-  case NVV_KEY( 'z' ):
-    TOGGLE_OPTION_NEG( ps_debug_no_vert_hints, "vertical hints processing" );
-    break;
-
-  case NVV_KEY( 'a' ):
-    TOGGLE_OPTION_NEG( ps_debug_no_horz_hints, "horizontal hints processing" );
-    break;
-
-  case NVV_KEY( 'Z' ):
-    TOGGLE_OPTION( option_show_vert_hints, "vertical hints display" );
-    break;
-
-  case NVV_KEY( 'A' ):
-    TOGGLE_OPTION( option_show_horz_hints, "horizontal hints display" );
-    break;
-
-  case NVV_KEY( 'S' ):
-    TOGGLE_OPTION( option_show_smooth, "smooth points display" );
-    break;
-
-  case NVV_KEY( 'i' ):
-    TOGGLE_OPTION( option_show_indices, "point index display" );
-    break;
-
-  case NVV_KEY( 'b' ):
-    TOGGLE_OPTION( option_show_blues, "blue zones display" );
-    break;
-
-  case NVV_KEY( 'h' ):
-    ps_debug_no_horz_hints = option_hinting;
-    ps_debug_no_vert_hints = option_hinting;
-
-    TOGGLE_OPTION( option_hinting, "hinting" );
-    break;
-
-  case NVV_KEY( 'H' ):
-    ps_print_hints();
-    break;
-
-  default:
-    ;
-  }
-}
-
-
-static void
-usage()
-{
-  Panic( "no usage" );
-}
-
-
-#define  OPTION1(n,code)   \
-           case n :        \
-             code          \
-             argc--;       \
-             argv++;       \
-             break;
-
-#define  OPTION2(n,code)     \
-           case n :          \
-             code            \
-             argc -= 2;      \
-             argv += 2;      \
-             break;
-
-
-static void
-parse_options( int*     argc_p,
-               char***  argv_p )
-{
-  int     argc = *argc_p;
-  char**  argv = *argv_p;
-
-
-  while ( argc > 2 && argv[1][0] == '-' )
-  {
-    switch ( argv[1][1] )
-    {
-      OPTION2( 'f', first_glyph = atoi( argv[2] ); )
-
-      OPTION2( 's', pixel_size = atoi( argv[2] ); )
-
-      default:
-        usage();
-    }
-  }
-
-  *argc_p = argc;
-  *argv_p = argv;
-}
-
-
-int
-main( int     argc,
-      char**  argv )
-{
-  char*  filename = "/winnt/fonts/arial.ttf";
-
-
-  parse_options( &argc, &argv );
-
-  if ( argc >= 2 )
-    filename = argv[1];
-
-
-  /* create library */
-  error = nv_renderer_new( 0, &renderer );
-  if ( error )
-    Panic( "could not create Nirvana renderer" );
-
-  memory = nv_renderer_get_memory( renderer );
-  init_symbols();
-
-  error = nvv_display_new( renderer, &display );
-  if ( error )
-    Panic( "could not create display" );
-
-  error = nvv_surface_new( display, 460, 460, nv_pixmap_type_argb, &surface );
-  if ( error )
-    Panic( "could not create surface" );
-
-  target = nvv_surface_get_pixmap( surface );
-
-  error = nv_painter_new( renderer, &painter );
-  if ( error )
-    Panic( "could not create painter" );
-
-  nv_painter_set_target( painter, target );
-
-  clear_background();
-
-  error = FT_Init_FreeType( &freetype );
-  if ( error )
-    Panic( "could not initialize FreeType" );
-
-  error = FT_New_Face( freetype, filename, 0, &face );
-  if ( error )
-    Panic( "could not open font face" );
-
-  reset_size( pixel_size, grid_scale );
-
-  nvv_surface_set_title( surface, "FreeType Glyph Viewer" );
-
-  {
-    NVV_EventRec  event;
-
-
-    glyph_index = first_glyph;
-    for ( ;; )
-    {
-      clear_background();
-      draw_grid();
-
-      ps_debug_hints  = 0;
-      ah_debug_hinter = 0;
-
-      ah_debug_disable_vert = ps_debug_no_vert_hints;
-      ah_debug_disable_horz = ps_debug_no_horz_hints;
-
-      draw_ps_blue_zones();
-      draw_glyph( glyph_index );
-      ps_draw_control_points();
-
-      nvv_surface_refresh( surface, NULL );
-
-      nvv_surface_listen( surface, 0, &event );
-      if ( event.key == NVV_Key_Esc )
-        break;
-
-      handle_event( &event );
-      switch ( event.key )
-      {
-      case NVV_Key_Esc:
-        goto Exit;
-
-      default:
-        ;
-      }
-    }
-  }
-
-Exit:
-  /* wait for escape */
-
-  /* destroy display (and surface) */
-  nvv_display_unref( display );
-
-  done_symbols();
-  nv_renderer_unref( renderer );
-
-  return 0;
-}