File: cgm.trm

package info (click to toggle)
gnuplot 3.7.2-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 6,212 kB
  • ctags: 4,635
  • sloc: ansic: 43,538; cpp: 970; makefile: 883; lisp: 661; sh: 578; asm: 539; objc: 379; csh: 297; pascal: 192; perl: 138
file content (1741 lines) | stat: -rw-r--r-- 54,805 bytes parent folder | download
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
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
/*
 * $Id: cgm.trm,v 1.16.2.4 2000/10/24 20:12:35 lhecking Exp $
 */

/* GNUPLOT - cgm.trm */

/*[
 * Copyright 1998
 *
 * Permission to use, copy, and distribute this software and its
 * documentation for any purpose with or without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.
 *
 * Permission to modify the software is granted, but not the right to
 * distribute the complete modified source code.  Modifications are to
 * be distributed as patches to the released version.  Permission to
 * distribute binaries produced by compiling modified sources is granted,
 * provided you
 *   1. distribute the corresponding source modifications from the
 *    released version in the form of a patch file along with the binaries,
 *   2. add special version identification to distinguish your version
 *    in addition to the base release version number,
 *   3. provide your name and address as the primary contact for the
 *    support of your modified version, and
 *   4. retain our contact information in regard to use of the base
 *    software.
 * Permission to distribute the released version of the source code along
 * with corresponding source modifications in the form of a patch file is
 * granted with same provisions 2 through 4 for binary distributions.
 *
 * This software is provided "as is" without express or implied warranty
 * to the extent permitted by applicable law.
]*/

/*
 * This file is included by ../term.c and ../docs/termdoc.c.
 *
 * This terminal driver supports:
 *   Computer Graphics Metafile
 *
 * TODO
 *   better control over plot size (never cutting off labels, correct font 
 *   sizes)

 * REFERENCES
 *
 *   ISO 8632-1:1992 Computer Graphics Metafile (CGM), Part 1,
 *   Functional Specification.
 *
 *   ISO 8632-1:1992 Computer Graphics Metafile (CGM), Part 3,
 *   Binary Encoding.
 *
 *   FIPS PUB 128 - Computer Graphics Metafile (CGM).
 *
 *   MIL-STD-2301A Computer Graphics Metafile (CGM) Implementation
 *   Standard for the National Imagery Transmission Format Standard, 5
 *   June 1998, http://164.214.2.51/ntb/baseline/docs/2301a/.  Only a
 *   subset of CGM version 1, but does include the binary format for
 *   that subset.
 *
 *   MIL-D-28003A "Digital Representation for Communication of
 *   Illustration Data: CGM Application Profile", 15 November 1991,
 *   http://www-cals.itsi.disa.mil/core/standards/28003aa1.pdf. 
 *
 *   "The computer graphics metafile", Lofton R. Henderson and Anne
 *   M. Mumford, Butterworths, London, 1990, ISBN 0-408-02680-4.
 *
 * AUTHOR
 *   Jim Van Zandt <jrv@vanzandt.mv.com>
 *
 * send your comments or suggestions to the author or
 * info-gnuplot@dartmouth.edu.
*/

#include "driver.h"

#ifdef TERM_REGISTER
register_term(cgm)
#endif

#ifdef TERM_PROTO
TERM_PUBLIC void CGM_options __PROTO((void));
TERM_PUBLIC void CGM_init __PROTO((void));
TERM_PUBLIC void CGM_reset __PROTO((void));
TERM_PUBLIC void CGM_text __PROTO((void));
TERM_PUBLIC void CGM_graphics __PROTO((void));
TERM_PUBLIC void CGM_move __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void CGM_dashed_vector __PROTO((unsigned int ux, unsigned int uy));
TERM_PUBLIC void CGM_solid_vector __PROTO((unsigned int ux, unsigned int uy));
TERM_PUBLIC void CGM_linetype __PROTO((int linetype));
TERM_PUBLIC void CGM_linecolor __PROTO((int color));
TERM_PUBLIC void CGM_dashtype __PROTO((int dashtype));
TERM_PUBLIC void CGM_linewidth __PROTO((double width));
TERM_PUBLIC void CGM_put_text __PROTO((unsigned int x, unsigned int y,
				       char *str));
TERM_PUBLIC int CGM_text_angle __PROTO((int ang));
TERM_PUBLIC int CGM_justify_text __PROTO((enum JUSTIFY mode));
TERM_PUBLIC void CGM_point __PROTO((unsigned int x, unsigned int y,
				    int number));
TERM_PUBLIC int CGM_find_font __PROTO((char *name, int len, double *relwidth));
TERM_PUBLIC int CGM_set_font __PROTO((char *font));
TERM_PUBLIC void CGM_set_pointsize __PROTO((double size));

#define CGM_LARGE 32767
#define CGM_SMALL 32767/18*13	/* aspect ratio 1:.7222 */
#define CGM_MARGIN (CGM_LARGE/180)
				/* convert from plot units to pt */
#define CGM_PT ((term->xmax + CGM_MARGIN)/cgm_plotwidth)
#define CGM_LINE_TYPES 9	/* number of line types we support */
#define CGM_COLORS 8		/* number of line colors we support in
                                   the default color table */
#define CGM_POINTS 13		/* number of markers we support */
#define CGM_MAX_SEGMENTS 104	/* maximum # polyline coordinates */
#define CGM_VCHAR (CGM_SMALL/360*12)
#define CGM_HCHAR (CGM_SMALL/360*12*5/9)
#define CGM_VTIC (CGM_LARGE/80)
#define CGM_HTIC (CGM_LARGE/80)
#endif

#ifndef TERM_PROTO_ONLY
#ifdef TERM_BODY

/*
 * on NeXTstep, id is an identifier (in ObjC) and causes a parse error
 * since some asserts below are mistaken as casts. datum is a type
 * defined in ndbm.h which also causes a parse error (ndbm.h is
 * included as part of appkit.h, I think).  Strangely enough, both
 * errors only happen with cpp-precomp -smart, not with the regular
 * cpp. (AL)
 */

#ifdef NEXT
#define id id_
#define datum datum_
#endif

#include <ctype.h>		/* for isspace() */

#ifndef assert
#define assert(x) 0		/* defeat assertions */
#endif

/* uncomment the following to enable assertions for this module only,
   regardless of compiler switches
#ifdef NDEBUG
#define DEFEAT_ASSERTIONS
#endif
#undef NDEBUG
#include <assert.h>
 */

#define CGM_ADJ (sizeof(int)/sizeof(short))

static unsigned int cgm_posx;
static unsigned int cgm_posy;
static unsigned int cgm_linetype = 1;
static unsigned int cgm_dashtype = 0;
static unsigned int cgm_color = 0;
static int cgm_polyline[CGM_MAX_SEGMENTS]; /* stored polyline coordinates */
static int cgm_coords = 0;	/* # polyline coordinates saved */
/* static enum JUSTIFY cgm_justify = LEFT; */ /* unused */
static int cgm_step_sizes[8];	/* array of currently used dash
				   lengths in plot units */
static int cgm_step_index = 0;	/* index into cgm_step_sizes[] */
static int cgm_step = 0;	/* amount of current dash not yet
				   drawn, in plot units */
static int cgm_tic, cgm_tic707, cgm_tic866, cgm_tic500, cgm_tic1241, cgm_tic1077, cgm_tic621;	/* marker dimensions */
static struct cgm_properties {
  double angle;			/* angle of text baseline (radians
                                   counter-clockwise from horizontal) */
  int font_index;		/* font index */
  int char_height;		/* character height in picture units */
  enum JUSTIFY justify_mode;	/* how text is justified */

  int edge_visibility;		/* nonzero if edge is visible */
  int edge_color;
  int fill_color;
} cgm_current={-1,-1,-1,(enum JUSTIFY)-1,-1,-1,-1}, /* written to file */
 cgm_next={0,-2,-2,LEFT,-2,-2,-2}, /* needed for next text string/marker */
 cgm_reset={-1,-1,-1,(enum JUSTIFY)-1,-1,-1,-1}; /* invalid entries */

static int cgm_user_color_count[] = { 0 };
static int cgm_user_color_max = 0;
static int cgm_maximum_color_index[] = { CGM_COLORS };
static int GPFAR *cgm_user_color_table;
static int GPFAR cgm_default_color_table[] =
{
     0,				/* starting index */
     255,255,255,		/* white (the background color) */
     0,0,0,			/* black */
     255,0,0,			/* red */
     0,255,0,			/* green */
     0,0,255,			/* blue */
     255,165,0,			/* orange */
     255,0,255,			/* magenta */
     0,255,255,			/* cyan */
     190,190,190		/* gray75 (which Windows calls "gray 25%") */
};

struct fontdata {
  char *name;			/* the name of the font */
  double width;			/* the width of the font, relative to
                                   Times Bold Italic.  The width
                                   adjustment can only be approximate.
                                   Of the standard fonts, only the
                                   four versions of "Courier" are
                                   monospaced. Also, metrics of the
                                   same font from different foundaries
                                   are sometimes different.  */
}  
  cgm_basic_font_data[]={

    /* these are WebCGM recommended fonts */
    {"Helvetica",1.039},
    {"Helvetica Oblique",1.099},
    {"Helvetica Bold",1.083},
    {"Helvetica Bold Oblique",1.011},
    {"Times Roman",.981},
    {"Times Bold",.985},
    {"Times Italic",.959},
    {"Times Bold Italic",1.0},
    {"Courier",1.327},
    {"Courier Bold",1.327},
    {"Courier Oblique",1.218},
    {"Courier Bold Oblique",1.341},
    {"Symbol",.897},

    /* These are basic public domain fonts required by MIL-D-28003A */
    {"Hershey/Cartographic_Roman",1.2404},
    {"Hershey/Cartographic_Greek",.9094},
    {"Hershey/Simplex_Roman",1.2369},
    {"Hershey/Simplex_Greek",.9129},
    {"Hershey/Simplex_Script",1.4181},
    {"Hershey/Complex_Roman",1.1150},
    {"Hershey/Complex_Greek",.9059},
    {"Hershey/Complex_Script",1.3868},
    {"Hershey/Complex_Italic",1.4146},
    {"Hershey/Complex_Cyrillic",1.2056},
    {"Hershey/Duplex_Roman",1.1707},
    {"Hershey/Triplex_Roman",1.3240},
    {"Hershey/Triplex_Italic",1.3310},
    {"Hershey/Gothic_German",1.2056},
    {"Hershey/Gothic_English",1.2021},
    {"Hershey/Gothic_Italian",1.2021},
    {"Hershey/Symbol_Set_1",.9059},
    {"Hershey/Symbol_Set_2",.9059},
    {"Hershey/Symbol_Math",.9059},

    /* These are available in the Microsoft Office import filter.  By
       default, the script font can apparently be accessed only via
       the name "15".  */
    {"ZapfDingbats",1.583},
    {"Script",1.139},
    {"15",1.139},

    /* in the Microsoft Office and Corel Draw import filters, these
       are pseudonyms for some of the above */
    {"Helvetica Italic",1.099},
    {"Helvetica Bold Italic",1.011},
    {"Courier Italic",1.218},
    {"Courier Bold Italic",1.341},
    {"Times Oblique",.959},
    {"Times Bold Oblique",1.0},

    {0,0}
  },
    *cgm_font_data = cgm_basic_font_data;

#define DEFAULT_CGMFONT "Helvetica Bold"

/* variables to record the options */
static char cgm_font[32] = DEFAULT_CGMFONT;
static unsigned int cgm_fontsize = 12;
static unsigned cgm_linewidth;	/* line width in plot units */
static unsigned cgm_linewidth_pt = 1;	/* line width in pt */
static TBOOLEAN cgm_monochrome = FALSE;		/* colors enabled? */
static int cgm_plotwidth = 432;	/* assumed width of plot in pt. */
static TBOOLEAN cgm_portrait = FALSE;	/* portrait orientation? */
static TBOOLEAN cgm_rotate = TRUE;	/* text rotation enabled? */
static TBOOLEAN cgm_dashed = TRUE;	/* dashed linestyles enabled? */
static TBOOLEAN cgm_nofontlist_mode = FALSE;	/* omit font list? */

/* prototypes for static functions */
static void CGM_local_reset __PROTO((void));
static void CGM_flush_polyline __PROTO((void));
static void CGM_flush_polygon __PROTO((void));
static void CGM_write_char_record __PROTO((int class, int cgm_id, int length,
					   char *data));
static void CGM_write_code __PROTO((int class, int cgm_id, int length));
static void CGM_write_int __PROTO((int value));
static void CGM_write_int_record __PROTO((int class, int cgm_id, int length,
					  int *data));
static void CGM_write_mixed_record __PROTO((int class, int cgm_id,
					    int numint, int *int_data,
					    int numchar, char *char_data));
static void CGM_write_byte_record __PROTO((int class, int cgm_id, int length,
					   char *data));

TERM_PUBLIC void
CGM_options()
{
    struct value a;

    CGM_local_reset();

    while (!END_OF_COMMAND) {
	if (almost_equals(c_token, "p$ortrait")) {
	    cgm_portrait = TRUE;
	    c_token++;
	    continue;
	}
	if (almost_equals(c_token, "la$ndscape")) {
	    cgm_portrait = FALSE;
	    c_token++;
	    continue;
	}
	if (almost_equals(c_token, "de$fault")) {
	    CGM_local_reset();
	    c_token++;
	    continue;
	}
	if (almost_equals(c_token, "nof$ontlist")
	    || almost_equals(c_token, "w$inword6")) { /* deprecated */
	    cgm_nofontlist_mode = TRUE;
	    c_token++;
	    continue;
	}
	if (almost_equals(c_token, "m$onochrome")) {
	    cgm_monochrome = TRUE;
	    c_token++;
	    continue;
	}
	if (almost_equals(c_token, "c$olor")
	    || almost_equals(c_token, "c$olour")) {
	    cgm_monochrome = FALSE;
	    c_token++;
	    continue;
	}
	if (almost_equals(c_token, "r$otate")) {
	    cgm_rotate = TRUE;
	    c_token++;
	    continue;
	}
	if (almost_equals(c_token, "nor$otate")) {
	    cgm_rotate = FALSE;
	    c_token++;
	    continue;
	}
	if (almost_equals(c_token, "da$shed")) {
	    cgm_dashed = TRUE;
	    c_token++;
	    continue;
	}
	if (almost_equals(c_token, "s$olid")) {
	    cgm_dashed = FALSE;
	    c_token++;
	    continue;
	}
	if (almost_equals(c_token, "li$newidth")) {
	    c_token++;
	    if (!END_OF_COMMAND) {
		cgm_linewidth_pt = (unsigned int) real(const_express(&a));
		if (cgm_linewidth_pt == 0 || cgm_linewidth_pt > 10000) {
		    fputs("gnuplot(cgm.trm): linewidth out of range\n",
			  stderr);
		    cgm_linewidth_pt = 1;
		}
	    }
	    continue;
	}
	if (almost_equals(c_token, "wid$th")) {
	    c_token++;
	    if (!END_OF_COMMAND) {
		cgm_plotwidth = (int) real(const_express(&a));
		if (cgm_plotwidth < 0 || cgm_plotwidth > 10000) {
		    fputs("gnuplot(cgm.trm): width out of range\n", stderr);
		    cgm_plotwidth = 6 * 72;
		}
	    }
	    continue;
	}
	break;
    }

    if (!END_OF_COMMAND && isstring(c_token)) {
	char *string = input_line + token[c_token].start_index;

	if (string[0] == 'x') { /* set color */
	    unsigned short red, green, blue;
              
	    if (sscanf(string, "x%2hx%2hx%2hx", &red, &green, &blue ) != 3)
		int_error("invalid color spec, must be xRRGGBB",c_token);
	    if (cgm_user_color_count[0] >= cgm_user_color_max) {
		cgm_user_color_max = cgm_user_color_max*2 + 4;
		cgm_user_color_table = 
                    gp_realloc(cgm_user_color_table, 
                               (cgm_user_color_max*3+1)*sizeof(int),
                               "CGM color table");
		/* 1st table entry is the minimum color index value */
		cgm_user_color_table[0] = 0;
	    }
	    cgm_user_color_table[1 + 3*cgm_user_color_count[0]] = red;
	    cgm_user_color_table[2 + 3*cgm_user_color_count[0]] = green;
	    cgm_user_color_table[3 + 3*cgm_user_color_count[0]] = blue;
	    cgm_user_color_count[0]++;
	    ++c_token;
	} else {
	    if (isstring(c_token)) {
		double relwidth;
		quote_str(cgm_font, c_token, MAX_ID_LEN);
		if (CGM_find_font(cgm_font, strlen(cgm_font),
				  &relwidth) == 0) {
		    /* insert the font in the font table */
		    size_t l = strlen(cgm_font);
		    int n;
		    for (n=0; cgm_font_data[n].name; n++)
			;
		    if (l <= 255) {
			struct fontdata *new_font_data;
			int i;
			new_font_data = 
			    (struct fontdata *)gp_alloc((n + 2)*sizeof(struct fontdata),
				     "CGM font list");
			new_font_data->name = gp_alloc(l+1,"CGM font list");
			strcpy(new_font_data->name, cgm_font);
                                /* punt, since we don't know the real font width */
			new_font_data->width = 1.0;
			for (i = 0; i <= n; i++)
			    new_font_data[i+1] = cgm_font_data[i];
			cgm_font_data = new_font_data;
		    }
		}
		c_token++;
	    } else {
		/* the user is specifying the font size */
		cgm_fontsize = (int) real(const_express(&a));
	    }
	}
    }

    if (cgm_portrait) {
	term->xmax = CGM_SMALL - CGM_MARGIN;
	term->ymax = CGM_LARGE - CGM_MARGIN;
    } else {
	term->xmax = CGM_LARGE - CGM_MARGIN;
	term->ymax = CGM_SMALL - CGM_MARGIN;
    }

    {   /* cgm_font, cgm_fontsize, and/or term->v_char may have changed */
        double w;
        CGM_find_font(cgm_font, strlen(cgm_font), &w);
        term->v_char = (unsigned int) (cgm_fontsize*CGM_PT);
        term->h_char = (unsigned int) (cgm_fontsize*CGM_PT*.527*w);
    }

    sprintf(default_font, "%s,%d", cgm_font, cgm_fontsize);
    /* default_font holds the font and size set at 'set term' */
    sprintf(term_options, "%s %s %s %s %s width %d linewidth %d \"%s\" %d",
            cgm_portrait ? "portrait" : "landscape",
            cgm_monochrome ? "monochrome" : "color",
            cgm_rotate ? "rotate" : "norotate",
            cgm_dashed ? "dashed" : "solid",
            cgm_nofontlist_mode ? "nofontlist" : "",
            cgm_plotwidth,
            cgm_linewidth_pt,
            cgm_font, cgm_fontsize);

    if (cgm_user_color_count[0]) {
	int i, red, green, blue;
	for (i = 0; i < cgm_user_color_count[0] && 
		 (strlen(term_options) + 9 < MAX_LINE_LEN); i++) {
	    red = cgm_user_color_table[1 + 3*i];
	    green = cgm_user_color_table[2 + 3*i];
	    blue = cgm_user_color_table[3 + 3*i];
	    sprintf(term_options + strlen(term_options),
		    " x%02x%02x%02x", red, green, blue);
	}
	if (cgm_user_color_count[0] == 1) {
	    /* user only specified the background color */
	    cgm_default_color_table[1] = cgm_user_color_table[1];
	    cgm_default_color_table[2] = cgm_user_color_table[2];
	    cgm_default_color_table[3] = cgm_user_color_table[3];
	    cgm_user_color_count[0] = 0;
	} else {
	    cgm_maximum_color_index[0] = cgm_user_color_count[0] - 1;
	}
    }
}

static void
CGM_local_reset()
{
    double w;
    strcpy(cgm_font, DEFAULT_CGMFONT);
    CGM_find_font(cgm_font, strlen(cgm_font), &w);
    cgm_fontsize = 12;
    term->v_char = (unsigned int) (cgm_fontsize * CGM_PT);
    term->h_char = (unsigned int) (cgm_fontsize * CGM_PT * .527 * w);
    cgm_linewidth_pt = 1;
    cgm_monochrome = FALSE;
    cgm_plotwidth = 6 * 72;
    cgm_portrait = FALSE;
    cgm_rotate = TRUE;
    cgm_dashed = TRUE;
    cgm_nofontlist_mode = FALSE;
    cgm_current = cgm_reset;
    cgm_user_color_count[0] = 0;
}

TERM_PUBLIC void
CGM_init()
{
    cgm_posx = cgm_posy = 0;
    cgm_linetype = 0;
    cgm_next.angle = 0;
}

TERM_PUBLIC void
CGM_graphics()
{
    register struct termentry *t = term;
    static int version_data[] = { 1 };
    static int vdc_type_data[] = { 0 };
    static int integer_precision_data[] = { 16 };
    static int real_precision_data[] = { 1, 16, 16 };
    static int index_precision_data[] = { 16 };
    static int color_precision_data[] = { 16 };
    static int color_index_precision_data[] = { 16 };
    static int scaling_mode_data[] = { 0, 0, 0 };
    static int color_value_extent_data[] = { 0, 0, 0, 255, 255, 255 };
    static int color_selection_mode_data[] = { 0 };
    static int linewidth_specification_mode_data[] = { 0 };
    static int edge_width_specification_mode_data[] = { 0 };
    static int marker_size_specification_mode_data[] = { 0 };
    static int vdc_extent_data[] = { 0, 0, 0, 0 };
/*  static int line_color_data[] = { 1 }; */
    static int line_type_data[] = { 1 };
    static int interior_style_data[] = { 1 };			/* 1=filled */

    static int GPFAR elements_list_data[] =
    {
	0,			/* will be set to # elements in this list */
	0, 1,			/* Begin Metafile */
	0, 2,			/* End Metafile */
	0, 3,			/* Begin Picture */
	0, 4,			/* Begin Picture Body */
	0, 5,			/* End Picture */
	1, 1,			/* Metafile Version */
	1, 2,			/* Metafile Description */
	1, 3,			/* VDC Type */
	1, 4,			/* Integer Precision */
	1, 5,			/* Real Precision */
	1, 6,			/* Index Precision */
	1, 7,			/* Color Precision */
	1, 8,			/* Color Index Precision */
	1, 9,			/* Maximum Color Index */
	1, 10,			/* Color Value Extent */
	1, 13,			/* Font List */
	2, 1,			/* Scaling Mode */
	2, 2,			/* Color Selection Mode */
	2, 3,			/* Line Width Specification Mode */
	2, 4,			/* Marker Size Specification Mode */
	2, 5,			/* Edge Width Specification Mode */
	2, 6,			/* VDC Extent */
#ifdef NEVER
	/* disabled due to complaints from CGM import filters */
	3, 1,			/* VDC Integer Precision */
	3, 4,			/* Transparency */
	3, 6,			/* Clip Indicator */
#endif
	4, 1,			/* Polyline */
	4, 3,			/* Polymarker */
	4, 4,			/* Text */
	4, 7,			/* Polygon */
	4, 11,			/* Rectangle */
	4, 12,			/* Circle */
	4, 15,			/* Circular Arc Center */
	4, 16,			/* Circular Arc Center Close */
	4, 17,			/* Ellipse */
	4, 18,			/* Elliptical Arc */
	4, 19,			/* Elliptical Arc Close */
	5, 2,			/* Line Type */
	5, 3,			/* Line Width */
	5, 4,			/* Line Color */
	5, 6,			/* Marker Type */
	5, 7,			/* Marker Size */
	5, 8,			/* Marker Color */
	5, 10,			/* Text Font Index */
	5, 14,			/* Text Color */
	5, 15,			/* Character Height */
	5, 16,			/* Character Orientation */
	5, 18,			/* Text Alignment */
	5, 22,			/* Interior Style */
	5, 23,			/* Fill Color */
	5, 24,			/* Hatch Index */
	5, 27,			/* Edge Type */
	5, 28,			/* Edge Width */
	5, 29,			/* Edge Color */
	5, 30,			/* Edge Visibility */
	5, 34,			/* Color Table */
	6, 1,			/* Escape */
	7, 2			/* Application Data */
    };

    /* metafile description (class 1), including filename if available */
    if (!outstr)
	CGM_write_char_record(0, 1, 1, outstr);
    else
	CGM_write_char_record(0, 1, strlen(outstr) + 1, outstr);
    CGM_write_int_record(1, 1, 2, version_data);
    {
      char description_data[256];
      sprintf(description_data, "\
Gnuplot version %s patchlevel %s,\
 Computer Graphics Metafile version 1 per MIL-D-28003A/BASIC-1.%d", 
	      gnuplot_version, gnuplot_patchlevel, cgm_monochrome? 0:2);
	CGM_write_char_record(1, 2, strlen(description_data),
			      description_data);
    }
    elements_list_data[0] = (sizeof(elements_list_data) / CGM_ADJ - 2) / 4;
    CGM_write_int_record(1, 11, sizeof(elements_list_data) / CGM_ADJ,
			 elements_list_data);
    CGM_write_int_record(1, 3, 2, vdc_type_data);
    CGM_write_int_record(1, 4, 2, integer_precision_data);
    CGM_write_int_record(1, 5, 6, real_precision_data);
    CGM_write_int_record(1, 6, 2, index_precision_data);
    CGM_write_int_record(1, 7, 2, color_precision_data);
    CGM_write_int_record(1, 8, 2, color_index_precision_data);
    CGM_write_int_record(1, 9, 2, cgm_maximum_color_index);
    CGM_write_int_record(1, 10, sizeof(color_value_extent_data) / CGM_ADJ,
			 color_value_extent_data);
    if (cgm_nofontlist_mode == FALSE)
      {
	char *buf, *s;
	int i, lgh = 0;
	for (i = 0; cgm_font_data[i].name; i++)
	  lgh += strlen(cgm_font_data[i].name) + 1;
	buf = gp_alloc(lgh + 1, "CGM font list");
	for (s = buf, i = 0; cgm_font_data[i].name; i++)
	  {
	    int lgh = strlen(cgm_font_data[i].name);
	    *s++ = (char)lgh;
	    strcpy(s, cgm_font_data[i].name);
	    s += lgh;
	  }
	CGM_write_byte_record(1, 13, lgh, buf);
	free(buf);
      }

    /* picture description (classes 2 and 3) */
    CGM_write_char_record(0, 3, 8, "PICTURE1");
    CGM_write_int_record(2, 1, 6, scaling_mode_data);
    CGM_write_int_record(2, 2, 2, color_selection_mode_data);
    CGM_write_int_record(2, 3, 2, linewidth_specification_mode_data);
    CGM_write_int_record(2, 4, 2, marker_size_specification_mode_data);
    CGM_write_int_record(2, 5, 2, edge_width_specification_mode_data);
    vdc_extent_data[2] = t->xmax + CGM_MARGIN;
    vdc_extent_data[3] = t->ymax + CGM_MARGIN;
    CGM_write_int_record(2, 6, 8, vdc_extent_data);

    /* picture body (classes 4 and 5) */
    CGM_write_int_record(0, 4, 0, NULL);

#ifdef NEVER		/* no need for these, since we accept the defaults */
    {
      static int vdc_integer_precision_data[] = { 16 };
      CGM_write_int_record(3, 1, 2, vdc_integer_precision_data);
    }
    {
      static int transparency_data[] = { 1 }; /* text background:
						 0=auxiliary color
						 1=transparent */
      CGM_write_int_record(3, 4, sizeof(transparency_data) / CGM_ADJ,
			   transparency_data);
    }
    {
      static int clip_indicator_data[] = { 0 };
      CGM_write_int_record(3, 6, sizeof(clip_indicator_data) / CGM_ADJ,
			   clip_indicator_data);
    }
#endif
    if (!cgm_monochrome) {
      if (cgm_user_color_count[0]) {
	CGM_write_int_record(5, 34, (cgm_user_color_count[0]*3+1)*
			     sizeof(cgm_user_color_table[0])/CGM_ADJ,
			     cgm_user_color_table);
      } else
	CGM_write_int_record(5, 34, sizeof(cgm_default_color_table)/CGM_ADJ,
			   cgm_default_color_table);
    }
    CGM_write_int_record(5, 2, sizeof(line_type_data) / CGM_ADJ,
			 line_type_data); /* line type 1=SOLID */
    cgm_linewidth = cgm_linewidth_pt * CGM_PT;
    CGM_write_int_record(5, 3, sizeof(cgm_linewidth) / CGM_ADJ,
			 (int *) &cgm_linewidth); /* line width */
    CGM_write_int_record(5, 28, sizeof(cgm_linewidth) / CGM_ADJ,
			 (int *) &cgm_linewidth); /* edge width */
    CGM_write_int_record(5, 27,  sizeof(line_type_data) / CGM_ADJ,
			 line_type_data); /* edge type 1=SOLID */
    CGM_linecolor(0);

    cgm_current = cgm_reset;
    cgm_next.char_height = t->v_char;

    CGM_write_int_record(5, 22, 2, interior_style_data);
    {
	char buf[45];
	sprintf(buf, "%.31s,%d", cgm_font, cgm_fontsize);
	CGM_set_font(buf);
    }
    CGM_set_pointsize(pointsize);
}

/* Return the index for the font with the name `name'.  The index for
   the first font is 1.  Set relwidth to the width of the font,
   relative to Times Bold Italic.  If the font is not in the table,
   set *relwidth to 1.0 and return 0. */
TERM_PUBLIC int
CGM_find_font(name, numchar, relwidth)
char *name;
int numchar;
double *relwidth;
{
    int i;
    *relwidth = 1.;
    for (i=0; cgm_font_data[i].name; i++)
      /* strncasecmp is not standard, but defined by stdfn.c if not available */
      if (strlen(cgm_font_data[i].name) == numchar &&
	  strncasecmp(name, cgm_font_data[i].name, numchar) == 0)
	{
	  *relwidth = cgm_font_data[i].width;
	  return i+1;
	}

    return 0;
}

TERM_PUBLIC int
CGM_set_font(font)
char *font;
{
    register struct termentry *t = term;
    int size, font_index;
    char *comma = strchr(font, ',');
    int len;
    double width;

    /* find font in font table, or use 1st font */
    if (comma)
	len = comma - font;
    else
	len = strlen(font);

    font_index = CGM_find_font(font, len, &width);
    if (font_index == 0)
	font_index = 1;
    cgm_next.font_index = font_index;

    {
      char *s = cgm_font_data[font_index-1].name;

      len = strlen(s);
      if (len > 31)
	len = 31;
      strncpy(cgm_font, s, len);
      cgm_font[len] = NUL;
    }

    /* set font size */
    size = cgm_fontsize;
    if (comma)
	sscanf(comma + 1, "%d", &size);
    t->v_char = size * CGM_PT;
    t->h_char = size * CGM_PT * .527 * width;

    cgm_next.char_height = t->v_char;

    return TRUE;
}

TERM_PUBLIC void
CGM_text()
{
    CGM_flush_polyline();
    CGM_write_int_record(0, 5, 0, NULL);	/* end picture */
    CGM_write_int_record(0, 2, 0, NULL);	/* end metafile */
}

TERM_PUBLIC void
CGM_linetype(linetype)
int linetype;
{
    assert(linetype >= -2);
    if (linetype == cgm_linetype)
	return;
    cgm_linetype = linetype;

    CGM_linecolor(linetype);
    if (cgm_dashed) {
	CGM_dashtype(linetype);	/* DBT 10-8-98    use dashes */
    } else {
	/* dashes for gridlines, solid for everything else */
	CGM_dashtype(linetype == -1 ? 2 : 0);
    }
    /* CGM_dashtype(cgm_monochrome ? linetype : 0); first fix, color->no dashes */
    /* CGM_dashtype(linetype);  orig distribution              */
}

TERM_PUBLIC void
CGM_linecolor(linecolor)
int linecolor;
{
    assert(linecolor >= -2);
    linecolor = (linecolor < 1) ? 1 : 
      linecolor % cgm_maximum_color_index[0] + 1;
    if (cgm_monochrome || linecolor == cgm_color)
	return;
    cgm_color = linecolor;

    CGM_flush_polyline();
    CGM_write_int_record(5, 4, 2, (int *) &cgm_color);
}

TERM_PUBLIC void
CGM_linewidth(width)
double width;
{
    int new_linewidth;

    assert(width > 0);
    new_linewidth = width * cgm_linewidth_pt * CGM_PT;
    if (new_linewidth == cgm_linewidth)
	return;

    CGM_flush_polyline();

    cgm_linewidth = new_linewidth;
    CGM_write_int_record(5, 3, sizeof(cgm_linewidth) / CGM_ADJ,
			 (int *) &cgm_linewidth);
    CGM_dashtype(cgm_dashtype);	/* have dash lengths recalculated */
}

TERM_PUBLIC void
CGM_dashtype(dashtype)
int dashtype;
{
    int i, j;
    /* Each group of 8 entries in dot_length[] defines a dash
       pattern.  Entries in each group are alternately length of
       whitespace and length of line, in units of 2/3 of the
       linewidth. */
    static int dot_length[CGM_LINE_TYPES * 8] =
    {				/* 0 - solid             */
	5, 8, 5, 8, 5, 8, 5, 8,	/* 1 - dashes            */
	5, 3, 5, 3, 5, 3, 5, 3,	/* 2 - short dashes      */
	4, 1, 4, 1, 4, 1, 4, 1,	/* 3 - dotted            */
	4, 8, 4, 1, 4, 8, 4, 1,	/* 4 - dash-dot          */
	4, 9, 4, 1, 4, 1, 0, 0,	/* 5 - dash-dot-dot      */
	4, 10, 4, 1, 4, 1, 4, 1,	/* 6 - dash-dot-dot-dot  */
	4, 10, 4, 10, 4, 1, 0, 0,	/* 7 - dash-dash-dot     */
	4, 10, 4, 10, 4, 1, 4, 1};	/* 8 - dash-dash-dot-dot */


    assert(dashtype >= -2);
    if (dashtype == cgm_dashtype)
	return;
    cgm_dashtype = dashtype;

    CGM_flush_polyline();

    if (dashtype >= CGM_LINE_TYPES)
	dashtype = dashtype % CGM_LINE_TYPES;
    if (dashtype < 1) {
	term->vector = CGM_solid_vector;
	return;
    }
    term->vector = CGM_dashed_vector;

    /* set up dash dimensions */
    j = (dashtype - 1) * 8;
    for (i = 0; i < 8; i++, j++) {
	if (dot_length[j])
	    cgm_step_sizes[i] = (dot_length[j] * cgm_linewidth) * 2 / 3;
	else
	    cgm_step_sizes[i] = 0;
    }
    /* first thing drawn will be a line */
    cgm_step = cgm_step_sizes[1];
    cgm_step_index = 1;
}

TERM_PUBLIC void
CGM_move(x, y)
unsigned int x, y;
{
    assert(x < term->xmax && y < term->ymax);

    if (x == cgm_posx && y == cgm_posy)
	return;
    CGM_flush_polyline();
    cgm_posx = x;
    cgm_posy = y;
}

static void
CGM_flush_polyline()
{
    if (cgm_coords == 0)
	return;
    CGM_write_int_record(4, 1, cgm_coords * 2, cgm_polyline);
    cgm_coords = 0;
}

static void
CGM_write_char_record(class, cgm_id, numbytes, data)
int class, cgm_id, numbytes;
char *data;
{
    int i, pad, length;
    static unsigned char flag = 0xff;
    static unsigned char paddata = 0;
    char short_len;

    pad = 0;
    length = numbytes + 1;
    if (numbytes >= 255)
	length += 2;	/* long string */
    if (length & 1)
	pad = 1;	/* needs pad */
    CGM_write_code(class, cgm_id, length);
    if (numbytes < 255)
    {
        short_len = (char)numbytes;
	fwrite(&short_len, 1, 1, gpoutfile);	/* write true length */
    } else {
        fwrite(&flag, 1, 1, gpoutfile);
	CGM_write_int(numbytes);
    }

    if (data)
        fwrite(data, 1, numbytes, gpoutfile);		/* write string */
    else
	for (i=0; i<numbytes+pad; i++)
	    fputc('\0', gpoutfile);			/* write null bytes */

    if(pad)
      fwrite(&paddata, 1, 1, gpoutfile);
}

static void
CGM_write_byte_record(class, cgm_id, numbytes, data)
int class, cgm_id, numbytes;
char *data;
{
    int pad;
    static unsigned char paddata = 0;

    pad = numbytes & 1;
    CGM_write_code(class, cgm_id, numbytes);
    fwrite(data, 1, numbytes, gpoutfile);		/* write string */
    if(pad)
      fwrite(&paddata, 1, 1, gpoutfile);
}

static void
CGM_write_int_record(class, cgm_id, numbytes, data)
int class, cgm_id, numbytes, *data;
{
    int i;
    assert((numbytes & 1) == 0);
    CGM_write_code(class, cgm_id, numbytes);
    numbytes >>= 1;
    for (i = 0; i < numbytes; i++)
	CGM_write_int(data[i]);
}

static void
CGM_write_mixed_record(class, cgm_id, numint, int_data, numchar, char_data)
int class, cgm_id, numint, *int_data, numchar;
char *char_data;
{
    int i, pad, length;
    static unsigned char paddata = 0;
    static unsigned char flag = 0xff;
    char short_len;

    pad = 0;
    length = numchar + 1;
    if (numchar >= 255)
	length += 2;	/* long string */
    if (length & 1)
	pad = 1;	/* needs pad */

    CGM_write_code(class, cgm_id, numint * 2 + length);

    for (i = 0; i < numint; i++)
	CGM_write_int(int_data[i]);	/* write integers */

    if (numchar < 255) {
        short_len = (char)numchar;
	fwrite(&short_len, 1, 1, gpoutfile);	/* write string length */
    } else {
	fwrite(&flag, 1, 1, gpoutfile);
	CGM_write_int(numchar);
    }
    fwrite(char_data, 1, numchar, gpoutfile);	/* write string */
    if(pad)
      fwrite(&paddata, 1, 1, gpoutfile);
}

/*
   Write the code word that starts a CGM record.
   bits in code word are as follows...
   cccciiiiiiilllll
   where 
   cccc is a 4-bit class number
   iiiiiii is a 7-bit ID number
   lllll is a 5-bit length (# bytes following the code word, or 
            31 followed by a word with the actual number)
   */
static void
CGM_write_code(class, cgm_id, length)
int class, cgm_id, length;
{
    unsigned code;

    assert((0 <= class) &&(class <16));
    assert((0 <= cgm_id) && (cgm_id < 128));
    assert(0 <= length);
    if (length < 31) {
	code = ((class &0x0f) <<12) |
	    ((cgm_id & 0x7f) << 5) |
	    ((length & 0x1f));
	CGM_write_int(code);
    } else {
	code = ((class &0x0f) <<12) |
	    ((cgm_id & 0x7f) << 5) |
	    0x1f;
	CGM_write_int(code);
	CGM_write_int(length);
    }
}

static void
CGM_write_int(value)
int value;
{
    union {
	short s;
	char c[2];
    } u;

#if !defined(DOS16) && !defined(WIN16)
    assert( -32768 <= value );
    assert( value <= 32767 );
#endif

    u.c[0] = (value >> 8) & 255;	/* convert to network order */
    u.c[1] = value & 255;

    fwrite(&u.s, 1, 2, gpoutfile);
}

	/* Draw a dashed line to (ux,uy).  CGM has linestyles, but
	   they are not usable -- at least with the Word for Windows
	   6.0 filter, where lines of significant width (even 1 pt)
	   always come out solid.  Therefore, we implement dashed
	   lines here instead.  */
TERM_PUBLIC void
CGM_dashed_vector(ux, uy)
unsigned int ux, uy;
{
    int xa, ya;
    int dx, dy, adx, ady;
    int dist;			/* approximate distance in plot units
				   from starting point to specified end
				   point. */
    long remain;		/* approximate distance in plot units
				   remaining to specified end point. */

    assert(ux < term->xmax && uy < term->ymax);

    dx = (ux - cgm_posx);
    dy = (uy - cgm_posy);
    adx = abs(dx);
    ady = abs(dy * 10);

    /* using the approximation 
       sqrt(x**2 + y**2)  ~  x + (5*x*x)/(12*y)   when x > y.  
       Note ordering of calculations to avoid overflow on 16 bit
       architectures */
    if (10 * adx < ady)
	dist = (ady / 2 + 25 * adx / ady * adx / 6 * 5) / 5;
    else {
	if (adx == 0)
	    return;
	dist = (adx * 10 + (ady / 24) * (ady / adx)) / 10;
    }
    remain = dist;
    xa = cgm_posx;
    ya = cgm_posy;
    while (remain > cgm_step) {
	remain -= cgm_step;
	if (cgm_step_index & 1)
	    CGM_solid_vector((int) (ux - (remain * dx) / dist),
			     (int) (uy - (remain * dy) / dist));
	else {
	    xa = (int) (ux - (remain * dx) / dist);
	    ya = (int) (uy - (remain * dy) / dist);
	    CGM_move(xa, ya);
	}
	if (++cgm_step_index >= 8)
	    cgm_step_index = 0;
	cgm_step = cgm_step_sizes[cgm_step_index];
    }
    if (cgm_step_index & 1)
	CGM_solid_vector(ux, uy);
    else
	CGM_move(ux, uy);
    cgm_step -= (int) remain;
}

TERM_PUBLIC void
CGM_solid_vector(ux, uy)
unsigned int ux, uy;
{
    assert(ux < term->xmax && uy < term->ymax);

    if (ux == cgm_posx && uy == cgm_posy)
	return;
    if (cgm_coords > CGM_MAX_SEGMENTS - 2) {
	CGM_flush_polyline();
	cgm_polyline[cgm_coords++] = cgm_posx;
	cgm_polyline[cgm_coords++] = cgm_posy + CGM_MARGIN;
    } else if (cgm_coords == 0) {
	cgm_polyline[cgm_coords++] = cgm_posx;
	cgm_polyline[cgm_coords++] = cgm_posy + CGM_MARGIN;
    }
    cgm_polyline[cgm_coords++] = ux;
    cgm_polyline[cgm_coords++] = uy + CGM_MARGIN;
    cgm_posx = ux;
    cgm_posy = uy;
}

TERM_PUBLIC void
CGM_put_text(x, y, str)
unsigned int x, y;
char str[];
{
    static int where[3] = { 0, 0, 1 }; /* the final "1" signals that
					  this is the last text in the
					  string */
    char *s = str;

    while (*s)
	if (!isspace((int) *s++))
	    goto showit;
    return;

  showit:

    CGM_flush_polyline();

    /* update the text characteristics if they have changed since the
       last text string was output */
    if (cgm_current.font_index != cgm_next.font_index) {
      cgm_current.font_index = cgm_next.font_index;
      CGM_write_int_record(5, 10, 2, &cgm_next.font_index);
    }
    if (cgm_current.justify_mode != cgm_next.justify_mode) {
      static int data[6] = { 1, 3, 0, 0, 0, 0 };
      cgm_current.justify_mode = cgm_next.justify_mode;

      switch (cgm_current.justify_mode) {
      case LEFT:
	data[0] = 1;
	break;
      case CENTRE:
	data[0] = 2;
	break;
      case RIGHT:
	data[0] = 3;
	break;
      default:
	assert(0);
      }
      CGM_write_int_record(5, 18, 12, data);
    }

    if (cgm_current.char_height != cgm_next.char_height) {
      int h = cgm_next.char_height;
      cgm_current.char_height = h;
      h = h*2/3;		/* gnuplot measures fonts by the
                                   baseline-to-baseline distance,
                                   while the CGM file needs the actual
                                   height of the upper case
                                   characters. */
      CGM_write_int_record(5, 15, 2, &h);
    }

    /* "angle" is the angle of the text baseline (counter-clockwise in
       radians from horizontal).  This is a bit more general than
       gnuplot needs right now. */
    if (cgm_current.angle != cgm_next.angle) {
      /* The first two elements of orient are components of a vector
	 "upward" with respect to the text.  The next two elements are
	 components of a vector along the baseline of the text. The
	 lengths of both vectors are equal to the baseline-to-baseline
	 distance in plot units. */
      static int orient[4];
      extern double sin(double), cos(double);
      cgm_current.angle = cgm_next.angle;

      orient[0] = (int)cgm_next.char_height*cos(cgm_next.angle+3.1416/2);
      orient[1] = (int)cgm_next.char_height*sin(cgm_next.angle+3.1416/2);
      orient[2] = (int)cgm_next.char_height*cos(cgm_next.angle);
      orient[3] = (int)cgm_next.char_height*sin(cgm_next.angle);
      CGM_write_int_record(5, 16, 8, orient);
    }

    where[0] = x;
    where[1] = y + CGM_MARGIN;
    CGM_write_mixed_record(4, 4, 3, where, strlen(str), str);

    cgm_posx = cgm_posy = -2000;
}

TERM_PUBLIC int
CGM_text_angle(ang)
int ang;
{
    if (cgm_rotate) {
	cgm_next.angle = ang ? M_PI/2 : 0;
	return TRUE;
    }
    return ang ? FALSE : TRUE;
}

TERM_PUBLIC int
CGM_justify_text(mode)
enum JUSTIFY mode;
{
  cgm_next.justify_mode = mode;
  return (TRUE);
}

TERM_PUBLIC void
CGM_reset()
{
    cgm_posx = cgm_posy = 0;
}

TERM_PUBLIC void
CGM_point(x, y, number)
unsigned int x, y;
int number;
{
    int old_dashtype;

    if (number < 0) {		/* draw dot */
	CGM_move(x, y);
	CGM_solid_vector(x + 1, y);
	return;
    }
    number %= CGM_POINTS;

    CGM_flush_polyline();
    old_dashtype = cgm_dashtype;
    CGM_dashtype(0);
    if (number <= 7) {
      cgm_next.edge_visibility = 0;
      cgm_next.fill_color = cgm_color;
    } else {
      cgm_next.edge_visibility = 1;
      cgm_next.fill_color = 0;	/* index 0 is always the background color */
      cgm_next.edge_color = cgm_color;
    }
    if (cgm_current.fill_color != cgm_next.fill_color){
      cgm_current.fill_color = cgm_next.fill_color;
      CGM_write_int_record(5, 23, 2, &cgm_next.fill_color);
    }
    if (cgm_current.edge_visibility != cgm_next.edge_visibility){
      cgm_current.edge_visibility = cgm_next.edge_visibility;
      CGM_write_int_record(5, 30, 2, &cgm_current.edge_visibility);
    }
    if (cgm_current.edge_visibility &&
	cgm_current.edge_color != cgm_next.edge_color){
      cgm_current.edge_color = cgm_next.edge_color;
      CGM_write_int_record(5, 29, 2, &cgm_current.edge_color);
    }
      
    switch (number) {
    case 0:			/* draw diamond */
    case 8:
	CGM_move(x - cgm_tic, y);
	CGM_solid_vector(x, y - cgm_tic);
	CGM_solid_vector(x + cgm_tic, y);
	CGM_solid_vector(x, y + cgm_tic);
	CGM_flush_polygon();
	break;
    case 1:			/* draw plus */
	CGM_move(x - cgm_tic, y);
	CGM_solid_vector(x + cgm_tic, y);
	CGM_move(x, y - cgm_tic);
	CGM_solid_vector(x, y + cgm_tic);
	break;
    case 2:			/* draw box */
    case 9:
	CGM_move(x - cgm_tic707, y - cgm_tic707);
	CGM_solid_vector(x + cgm_tic707, y - cgm_tic707);
	CGM_solid_vector(x + cgm_tic707, y + cgm_tic707);
	CGM_solid_vector(x - cgm_tic707, y + cgm_tic707);
	CGM_flush_polygon();
	break;
    case 3:			/* draw X */
	CGM_move(x - cgm_tic707, y - cgm_tic707);
	CGM_solid_vector(x + cgm_tic707, y + cgm_tic707);
	CGM_move(x - cgm_tic707, y + cgm_tic707);
	CGM_solid_vector(x + cgm_tic707, y - cgm_tic707);
	break;
    case 4:			/* draw triangle (point up) */
    case 10:
	CGM_move(x, y + cgm_tic1241);
	CGM_solid_vector(x - cgm_tic1077, y - cgm_tic621);
	CGM_solid_vector(x + cgm_tic1077, y - cgm_tic621);
	CGM_flush_polygon();
	break;
    case 5:			/* draw star (asterisk) */
	CGM_move(x, y - cgm_tic);
	CGM_solid_vector(x, y + cgm_tic);
	CGM_move(x + cgm_tic866, y - cgm_tic500);
	CGM_solid_vector(x - cgm_tic866, y + cgm_tic500);
	CGM_move(x + cgm_tic866, y + cgm_tic500);
	CGM_solid_vector(x - cgm_tic866, y - cgm_tic500);
	break;
    case 6:			/* draw triangle (point down) */
    case 11:
	CGM_move(x, y - cgm_tic1241);
	CGM_solid_vector(x - cgm_tic1077, y + cgm_tic621);
	CGM_solid_vector(x + cgm_tic1077, y + cgm_tic621);
	CGM_flush_polygon();
	break;
    case 7:
    case 12:			/* draw circle (actually, dodecagon)
				   (WinWord 6 accepts the CGM "circle"
				   element, but the resulting circle
				   is not correctly centered!) */
	CGM_move(x, y - cgm_tic);
	CGM_solid_vector(x + cgm_tic500, y - cgm_tic866);
	CGM_solid_vector(x + cgm_tic866, y - cgm_tic500);
	CGM_solid_vector(x + cgm_tic, y);
	CGM_solid_vector(x + cgm_tic866, y + cgm_tic500);
	CGM_solid_vector(x + cgm_tic500, y + cgm_tic866);
	CGM_solid_vector(x, y + cgm_tic);
	CGM_solid_vector(x - cgm_tic500, y + cgm_tic866);
	CGM_solid_vector(x - cgm_tic866, y + cgm_tic500);
	CGM_solid_vector(x - cgm_tic, y);
	CGM_solid_vector(x - cgm_tic866, y - cgm_tic500);
	CGM_solid_vector(x - cgm_tic500, y - cgm_tic866);
	CGM_flush_polygon();
	break;
    }
    CGM_dashtype(old_dashtype);
}


TERM_PUBLIC void
CGM_set_pointsize(size)
double size;
{
    /* Markers were chosen to have approximately equal
       areas.  Dimensions are as follows, in units of
       cgm_tic:

       plus, diamond: half height = 1

       square, cross: half height = sqrt(1/2) ~ 12/17

       triangle: half width = sqrt(sqrt(4/3)) ~ 14/13,
       height = sqrt(3*sqrt(4/3)) ~ 54/29

       star: half height = 1, half width = sqrt(3/4) ~ 13/15

       dodecagon: coordinates of vertices are 0,
       sin(30) = 1/2, cos(30) = sqrt(3/4) ~ 13/15, or 1

       The fractions are approximates of the equivalent
       continued fractions. */
    cgm_tic = (size * term->h_tic / 2);
    cgm_tic707 = cgm_tic * 12 / 17;
    cgm_tic866 = cgm_tic * 13 / 15;
    cgm_tic500 = cgm_tic / 2;
    cgm_tic1241 = cgm_tic * 36 / 29;
    cgm_tic1077 = cgm_tic * 14 / 13;
    cgm_tic621 = cgm_tic * 18 / 29;
}

static void
CGM_flush_polygon()
{
    if (cgm_coords == 0)
	return;
    CGM_write_int_record(4, 7, cgm_coords * 2, cgm_polyline);
    cgm_coords = 0;
}


#ifdef DEFEAT_ASSERTIONS
#define NDEBUG
#include <assert.h>
#undef DEFEAT_ASSERTIONS
#endif /* DEFEAT_ASSERTIONS */

#ifdef NEXT
#undef id
#undef datum
#endif

#endif /* TERM_BODY */

#ifdef TERM_TABLE
TERM_TABLE_START(cgm_driver)
    "cgm", "Computer Graphics Metafile",
    CGM_LARGE - CGM_MARGIN, CGM_SMALL - CGM_MARGIN, CGM_VCHAR, CGM_HCHAR,
    CGM_VTIC, CGM_HTIC, CGM_options, CGM_init, CGM_reset,
    CGM_text, null_scale, CGM_graphics, CGM_move, CGM_solid_vector,
    CGM_linetype, CGM_put_text, CGM_text_angle,
    CGM_justify_text, CGM_point, do_arrow, CGM_set_font,
    CGM_set_pointsize,
    TERM_BINARY,		/* various flags */
    NULL,			/* after one plot of multiplot */
    NULL,			/* before subsequent plot of multiplot */
    NULL,			/* clear part of multiplot */
    CGM_linewidth
TERM_TABLE_END(cgm_driver)

#undef LAST_TERM
#define LAST_TERM cgm_driver

#endif /* TERM_TABLE */
#endif /* TERM_PROTO_ONLY */

#ifdef TERM_HELP
START_HELP(cgm)
"1 cgm",
"?commands set terminal cgm",
"?set terminal cgm",
"?set term cgm",
"?terminal cgm",
"?term cgm",
"?cgm",
" The `cgm` terminal generates a Computer Graphics Metafile, Version 1. ",
" This file format is a subset of the ANSI X3.122-1986 standard entitled",
" \"Computer Graphics - Metafile for the Storage and Transfer of Picture",
" Description Information\".",
" Several options may be set in `cgm`.",
"",
" Syntax:",
"       set terminal cgm {<mode>} {<color>} {<rotation>} {solid | dashed}",
"                        {width <plot_width>} {linewidth <line_width>}",
"                        {\"<font>\"} {<fontsize>}",
"                        {<color0> <color1> <color2> ...}",
"",
" where <mode> is `landscape`, `portrait`, or `default`;",
" <color> is either `color` or `monochrome`; ",
" <rotation> is either `rotate` or `norotate`;",
" `solid` draws all curves with solid lines, overriding any dashed patterns;",
" <plot_width> is the assumed width of the plot in points; ",
" <line_width> is the line width in points (default 1); ",
" <font> is the name of a font; and ",
" <fontsize> is the size of the font in points (default 12).",
"",
" By default, `cgm` uses rotated text for the Y axis label.",
"",
" The first six options can be in any order.  Selecting `default` sets all",
" options to their default values.",
"",
" Each color must be of the form 'xrrggbb', where x is the literal",
" character 'x' and 'rrggbb' are the red, green and blue components in",
" hex.  For example, 'x00ff00' is green.  The background color is set",
" first, then the plotting colors."
"",
" Examples:",
"       set terminal cgm landscape color rotate dashed width 432 \\",
"                      linewidth 1  'Helvetica Bold' 12       # defaults",
"       set terminal cgm 14 linewidth 2  14  # wider lines & larger font",
"       set terminal cgm portrait \"Times Italic\" 12",
"       set terminal cgm color solid      # no pesky dashes!",

"2 font",
"?commands set terminal cgm font",
"?set terminal cgm font",
"?set term cgm font",
"?cgm font",
" The first part of a Computer Graphics Metafile, the metafile description,",
" includes a font table.  In the picture body, a font is designated by an",
" index into this table.  By default, this terminal generates a table with",
" the following 16 fonts, plus six more with `italic` replaced by",
" `oblique`, or vice-versa (since at least the Microsoft Office and Corel",
" Draw CGM import filters treat `italic` and `oblique` as equivalent):",
"@start table - first is interactive cleartext form",
"       Helvetica",
"       Helvetica Bold",
"       Helvetica Oblique",
"       Helvetica Bold Oblique",
"       Times Roman",
"       Times Bold",
"       Times Italic",
"       Times Bold Italic",
"       Courier",
"       Courier Bold",
"       Courier Oblique",
"       Courier Bold Oblique",
"       Symbol",
"       Hershey/Cartographic_Roman",
"       Hershey/Cartographic_Greek",
"       Hershey/Simplex_Roman",
"       Hershey/Simplex_Greek",
"       Hershey/Simplex_Script",
"       Hershey/Complex_Roman",
"       Hershey/Complex_Greek",
"       Hershey/Complex_Script",
"       Hershey/Complex_Italic",
"       Hershey/Complex_Cyrillic",
"       Hershey/Duplex_Roman",
"       Hershey/Triplex_Roman",
"       Hershey/Triplex_Italic",
"       Hershey/Gothic_German",
"       Hershey/Gothic_English",
"       Hershey/Gothic_Italian",
"       Hershey/Symbol_Set_1",
"       Hershey/Symbol_Set_2",
"       Hershey/Symbol_Math",
"       ZapfDingbats",
"       Script",
"       15",
"#\\begin{tabular}{|ccl|} \\hline",
"#\\multicolumn{2}{|c|}{CGM fonts}\\\\",
"#&Helvetica&\\\\",
"#&Helvetica Bold&\\\\",
"#&Helvetica Oblique&\\\\",
"#&Helvetica Bold Oblique&\\\\",
"#&Times Roman&\\\\",
"#&Times Bold&\\\\",
"#&Times Italic&\\\\",
"#&Times Bold Italic&\\\\",
"#&Courier&\\\\",
"#&Courier Bold&\\\\",
"#&Courier Oblique&\\\\",
"#&Courier Bold Oblique&\\\\",
"#&Symbol&\\\\",
"#&Hershey/Cartographic\\_Roman&\\\\",
"#&Hershey/Cartographic\\_Greek&\\\\",
"#&Hershey/Simplex\\_Roman&\\\\",
"#&Hershey/Simplex\\_Greek&\\\\",
"#&Hershey/Simplex\\_Script&\\\\",
"#&Hershey/Complex\\_Roman&\\\\",
"#&Hershey/Complex\\_Greek&\\\\",
"#&Hershey/Complex\\_Script&\\\\",
"#&Hershey/Complex\\_Italic&\\\\",
"#&Hershey/Complex\\_Cyrillic&\\\\",
"#&Hershey/Duplex\\_Roman&\\\\",
"#&Hershey/Triplex\\_Roman&\\\\",
"#&Hershey/Triplex\\_Italic&\\\\",
"#&Hershey/Gothic\\_German&\\\\",
"#&Hershey/Gothic\\_English&\\\\",
"#&Hershey/Gothic\\_Italian&\\\\",
"#&Hershey/Symbol\\_Set\\_1&\\\\",
"#&Hershey/Symbol\\_Set\\_2&\\\\",
"#&Hershey/Symbol\\_Math&\\\\",
"#&ZapfDingbats&\\\\",
"#&Script&\\\\",
"#&15&\\\\",
"%c c l .",
"%@@CGM fonts",
"%_",
"%@@Helvetica",
"%@@Helvetica Bold",
"%@@Helvetica Oblique",
"%@@Helvetica Bold Oblique",
"%@@Times Roman",
"%@@Times Bold",
"%@@Times Italic",
"%@@Times Bold Italic",
"%@@Courier",
"%@@Courier Bold",
"%@@Courier Oblique",
"%@@Courier Bold Oblique",
"%@@Symbol",
"%@@Hershey/Cartographic_Roman",
"%@@Hershey/Cartographic_Greek",
"%@@Hershey/Simplex_Roman",
"%@@Hershey/Simplex_Greek",
"%@@Hershey/Simplex_Script",
"%@@Hershey/Complex_Roman",
"%@@Hershey/Complex_Greek",
"%@@Hershey/Complex_Script",
"%@@Hershey/Complex_Italic",
"%@@Hershey/Complex_Cyrillic",
"%@@Hershey/Duplex_Roman",
"%@@Hershey/Triplex_Roman",
"%@@Hershey/Triplex_Italic",
"%@@Hershey/Gothic_German",
"%@@Hershey/Gothic_English",
"%@@Hershey/Gothic_Italian",
"%@@Hershey/Symbol_Set_1",
"%@@Hershey/Symbol_Set_2",
"%@@Hershey/Symbol_Math",
"%@@ZapfDingbats",
"%@@Script",
"%@@15",
"@end table",

" The first thirteen of these fonts are required for WebCGM.  The",
" Microsoft Office CGM import filter implements the 13 standard fonts",
" listed above, and also 'ZapfDingbats' and 'Script'.  However, the",
" script font may only be accessed under the name '15'.  For more on",
" Microsoft import filter font substitutions, check its help file which",
" you may find here:",
"   C:\\Program Files\\Microsoft Office\\Office\\Cgmimp32.hlp",
" and/or its configuration file, which you may find here:",
"   C:\\Program Files\\Common Files\\Microsoft Shared\\Grphflt\\Cgmimp32.cfg",
"",
" In the `set term` command, you may specify a font name which does not",
" appear in the default font table.  In that case, a new font table is",
" constructed with the specified font as its first entry. You must ensure",
" that the spelling, capitalization, and spacing of the name are",
" appropriate for the application that will read the CGM file.  (Gnuplot",
" and any MIL-D-28003A compliant application ignore case in font names.)",
" If you need to add several new fonts, use several `set term` commands.",
"",
" Example:",
"       set terminal cgm 'Old English'",
"       set terminal cgm 'Tengwar'",
"       set terminal cgm 'Arabic'",
"       set output 'myfile.cgm'",
"       plot ...",
"       set output",
"",
" You cannot introduce a new font in a `set label` command."

"2 fontsize",
"?commands set terminal cgm fontsize",
"?set terminal cgm fontsize",
"?set term cgm fontsize",
"?cgm fontsize",
" Fonts are scaled assuming the page is 6 inches wide.  If the `size`",
" command is used to change the aspect ratio of the page or the CGM file",
" is converted to a different width, the resulting font sizes will be",
" scaled up or down accordingly.  To change the assumed width, use the",
" `width` option.",

"2 linewidth",
"?commands set terminal cgm linewidth",
"?set terminal cgm linewidth",
"?set term cgm linewidth",
"?cgm linewidth",
" The `linewidth` option sets the width of lines in pt.  The default width",
" is 1 pt.  Scaling is affected by the actual width of the page, as",
" discussed under the `fontsize` and `width` options",

"2 rotate",
"?commands set terminal cgm rotate",
"?set terminal cgm rotate",
"?set term cgm rotate",
"?cgm rotate",
" The `norotate` option may be used to disable text rotation.  For",
" example, the CGM input filter for Word for Windows 6.0c can accept",
" rotated text, but the DRAW editor within Word cannot.  If you edit a",
" graph (for example, to label a curve), all rotated text is restored to",
" horizontal.  The Y axis label will then extend beyond the clip boundary.",
" With `norotate`, the Y axis label starts in a less attractive location,",
" but the page can be edited without damage.  The `rotate` option confirms",
" the default behavior.",

"2 solid",
"?set terminal cgm solid",
"?set term cgm solid",
"?cgm solid",
" The `solid` option may be used to disable dashed line styles in the",
" plots.  This is useful when color is enabled and the dashing of the",
" lines detracts from the appearance of the plot. The `dashed` option",
" confirms the default behavior, which gives a different dash pattern to",
" each curve.",

"2 size",
"?commands set terminal cgm size",
"?set terminal cgm size",
"?set term cgm size",
"?cgm size",
" Default size of a CGM plot is 32599 units wide and 23457 units high for",
" landscape, or 23457 units wide by 32599 units high for portrait.",

"2 width",
"?commands set terminal cgm width",
"?set terminal cgm width",
"?set term cgm width",
"?cgm width",
" All distances in the CGM file are in abstract units.  The application",
" that reads the file determines the size of the final plot.  By default,",
" the width of the final plot is assumed to be 6 inches (15.24 cm).  This",
" distance is used to calculate the correct font size, and may be changed",
" with the `width` option.  The keyword should be followed by the width in",
" points.  (Here, a point is 1/72 inch, as in PostScript.  This unit is",
" known as a \"big point\" in TeX.)  Gnuplot `expressions` can be used to",
" convert from other units.",
"",
" Example:",
"       set terminal cgm width 432            # default",
"       set terminal cgm width 6*72           # same as above",
"       set terminal cgm width 10/2.54*72     # 10 cm wide",

"2 nofontlist",
"?commands set terminal cgm nofontlist",
"?set terminal cgm nofontlist",
"?set term cgm nofontlist",
"?cgm nofontlist",
"?commands set terminal cgm winword6",
"?set terminal cgm winword6",
"?set term cgm winword6",
"?cgm winword6",
" The default font table includes the fonts recommended for WebCGM, which",
" are compatible with the Computer Graphics Metafile input filter for",
" Microsoft Office and Corel Draw.  Another application might use",
" different fonts and/or different font names, which may not be",
" documented.  As a workaround, the `nofontlist` option deletes the font",
" table from the CGM file.  In this case, the reading application should",
" use a default table.  Gnuplot will still use its own default font table",
" to select font indices.  Thus, 'Helvetica' will give you an index of 1,",
" which should get you the first entry in your application's default font",
" table. 'Helvetica Bold' will give you its second entry, etc.",
"",
" The former `winword6` option is now a deprecated synonym for",
" `nofontlist`.  The problems involving the color and font tables that",
" the `winword6` option was intended to work around turned out to be",
" gnuplot bugs which have now been fixed."

END_HELP(cgm)
#endif /* TERM_HELP */