[go: up one dir, main page]

Menu

[72b583]: / www / doc / pslib.html  Maximize  Restore  History

Download this file

1716 lines (1712 with data), 39.1 kB

   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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>PSLIB</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"></HEAD
><BODY
CLASS="REFENTRY"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><H1
><A
NAME="AEN1"
></A
>PSLIB</H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN15"
></A
><H2
>Name</H2
>pslib&nbsp;--&nbsp;Library to create PostScript files</DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN18"
></A
><H2
>DESCRIPTION</H2
><P
>pslib is a library to create PostScript files with a set of
about 50 functions for line drawing, text output, page handling, etc.
It is very similar to other libraries like panda, cpdf or pdflib which
produce PDF. pslib can to a certain degree replace those libraries if
the PostScript file is converted to PDF with ghostscripts excellent
pdf writer. The results achieved with pslib can be even better when
it comes to text output, because it supports kerning, ligatures and
hyphenation.
</P
><P
>pslib is a C-library but there are bindings for Perl, Python, Tcl
and PHP.
This documentation will only describe the functions of the C-library,
though most of what is said here can be applied to the other language
bindings.
The PHP extension of pslib is documented in PEAR. The extension is
called ps.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN22"
></A
><H2
>GETTING STARTED</H2
><P
>Programs which want to use pslib will have to include the
header file <TT
CLASS="LITERAL"
>libps/pslib.h</TT
> and link against libps.
Before doing any document
creation the library should be initialized with
<CODE
CLASS="FUNCTION"
>PS_boot(3)</CODE
>. It will set the locale and selects
the messages in your language as defined by the environment variable
LC_ALL. Your locale settings will affect hyphenation which uses
<CODE
CLASS="FUNCTION"
>isalpha(3)</CODE
> and <CODE
CLASS="FUNCTION"
>tolower(3)</CODE
>
to prepare the word for hyphenation. German umlauts will
be filtered out if the locale is not set properly. The library should
be finalized by <CODE
CLASS="FUNCTION"
>PS_shutdown(3)</CODE
>.</P
><P
>A PostScript document is
represented by a pointer to <TT
CLASS="LITERAL"
>PSDoc</TT
>. Such a document
can be created with <CODE
CLASS="FUNCTION"
>PS_new(3)</CODE
> and destroyed
with <CODE
CLASS="FUNCTION"
>PS_delete(3)</CODE
>. <CODE
CLASS="FUNCTION"
>PS_new(3)</CODE
>
returns a pointer to <TT
CLASS="LITERAL"
>PSDoc</TT
>. You can handle several
documents at the same time. The following example will do the basic
preparation without creating a document on the disk.</P
><PRE
CLASS="PROGRAMLISTING"
>...
#include &lt;libps/pslib.h&gt;
main(int argc, char *argv[]) {
PSDoc *psdoc;
PS_boot();
psdoc = PS_new();
PS_delete(psdoc);
PS_shutdown();
}
</PRE
><P
>In order to actually create a PostScript document on disk you will
have to call</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN38"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_open_file</CODE
>(PSDoc *psdoc, const char *filename);</CODE
></P
><P
></P
></DIV
><P
>or</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN47"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_open_fp</CODE
>(PSDoc *psdoc, FILE *fp);</CODE
></P
><P
></P
></DIV
><P
><CODE
CLASS="FUNCTION"
>PS_open_file(3)</CODE
> will create a new file
with the given file name, while <CODE
CLASS="FUNCTION"
>PS_open_fp(3)</CODE
>
will use an already open file. Both require a pointer to
<TT
CLASS="LITERAL"
>PSDoc</TT
>.</P
><P
>If the document shall not be created on disk but in memory,
which can be very handy in web application, one can use</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN60"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_open_mem</CODE
>(PSDoc *psdoc, (*writeproc) (PSDoc *p, void *data, size_t size));</CODE
></P
><P
></P
></DIV
><P
>The second parameter is a function which is called instead of pslib's
own output function.</P
><P
>Extending the previous example with one of the former three functions
to open a document will at least create an initial empty PostScript
document. It has to be closed with <CODE
CLASS="FUNCTION"
>PS_close(3)</CODE
>.
<CODE
CLASS="FUNCTION"
>PS_close(3)</CODE
> will only close the file if it
was opened by <CODE
CLASS="FUNCTION"
>PS_open_file(3)</CODE
>.
</P
><PRE
CLASS="PROGRAMLISTING"
>...
#include &lt;libps/pslib.h&gt;
main(int argc, char *argv[]) {
PSDoc *psdoc;
PS_boot();
psdoc = PS_new();
PS_open_file(psdoc, "test.ps");
PS_close(psdoc);
PS_delete(psdoc);
PS_shutdown();
}
</PRE
><P
>There are more sophisticated funktions to start a new PostScript
document. They are used when error handling and memory management
shall be controlled by the calling application. Check the manual pages
<CODE
CLASS="FUNCTION"
>PS_new2(3)</CODE
> and <CODE
CLASS="FUNCTION"
>PS_new3(3)</CODE
> for
a detailed description or read the section about memory management
and error handler below..</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN77"
></A
><H2
>PAGE HANDLING</H2
><P
>A PostScript document contains one or more pages. pslib provides
the function</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN80"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_begin_page</CODE
>(PSDoc *psdoc, float width, float height);</CODE
></P
><P
></P
></DIV
><P
>and</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN91"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_end_page</CODE
>(PSDoc *psdoc);</CODE
></P
><P
></P
></DIV
><P
>to start a new page with the given size in points and to end
a page. All functions that draw any visible output will
only work within a page. The page size has no meaning for the PostScript
interpreter but will be used by ghostscript or Acrobat Distiller
to set
the page size in the PDF document. Some PostScript viewer also use
the size to resize the output window.</P
><P
>Starting the first page of a document will internally end the
PostScript header. This may have impact on resource handling. For
more information see the section about resource handling.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN99"
></A
><H2
>COORDINATE SYSTEM, SCOPE</H2
><P
>PostScript defines a coordinate system with its origin in the
lower left corner of a page. Its base unit is point which is 1/72 of an
inch. Unless the coordinate system is scaled all values will be expected
in point.</P
><P
>pslib provides many functions which may not be called at any time.
For example, drawing and text output functions may only be called within
a page, path constrution functions may only be called within a path.
pslib defines so called scopes which are checked before executing a
function. Those scopes are prolog, document, page, pattern, template,
path and object. If for example, one tries
to output text outside of a page or within a path, then an error
will be issued.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN103"
></A
><H2
>DRAWING, PATH CONSTRUCTION</H2
><P
>PostScript does not have any functions to draw a line directly but
uses a two pass mechanism. First a path is constructed which is then
drawn (stroken). The path can also be used for filling an area or
to clip further drawing. A path must not be a continues line, it
may consist of several subpaths.</P
><P
>Each path is started with</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN107"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>void PS_moveto</CODE
>(PSDoc *psdoc, float x, float y);</CODE
></P
><P
></P
></DIV
><P
>If this function is called within a path, it will just start
a new subpath. The path can be constructed with one of the following
functions.</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN118"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>void PS_lineto</CODE
>(PSDoc *psdoc, float x, float y);</CODE
></P
><P
></P
></DIV
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN128"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>void PS_rect</CODE
>(PSDoc *psdoc, float x, float y, float width, float height);</CODE
></P
><P
></P
></DIV
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN142"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>void PS_circle</CODE
>(PSDoc *psdoc, float x, float y, float radius);</CODE
></P
><P
></P
></DIV
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN154"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>void PS_arc</CODE
>(PSDoc *psdoc, float x, float y, float radius, float alpha, float beta);</CODE
></P
><P
></P
></DIV
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN170"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>void PS_arcn</CODE
>(PSDoc *psdoc, float x, float y, float radius, float alpha, float beta);</CODE
></P
><P
></P
></DIV
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN186"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>void PS_curveto</CODE
>(PSDoc *psdoc, float x1, float y1, float x2, float y2, float x3, float y3);</CODE
></P
><P
></P
></DIV
><P
>Once a path is constructed it can be optionally closed by</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN205"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>void PS_closepath</CODE
>(PSDoc *psdoc);</CODE
></P
><P
></P
></DIV
><P
>Closing a path means to add a segment from the last point to
the starting point of the path. It is helpful if an area is to be
filled. In most cases
the path is used for drawing which is done with</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN212"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>void PS_stroke</CODE
>(PSDoc *psdoc);</CODE
></P
><P
></P
></DIV
><P
>In such a case you would not want to close the path. As already
mentioned a path can also be filled or even both with the
functions.</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN219"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>void PS_fill</CODE
>(PSDoc *psdoc);</CODE
></P
><P
></P
></DIV
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN225"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>void PS_fill_stroke</CODE
>(PSDoc *psdoc);</CODE
></P
><P
></P
></DIV
><P
><CODE
CLASS="FUNCTION"
>PS_fill_stroke(3)</CODE
> does first fill and than
stroke a path. This is important to realize because the stroken line
may cover parts of the filled area, depending on how wide it is.</P
><P
> </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN234"
></A
><H2
>TEXT OUTPUT</H2
><P
>Text output is definetly one of the strongest parts of pslib.
pslib supports kerning, protusion, ligatures and hyphenation. All of
it is in a wide range customizeable by parameters. The hyphenation
algorithmn is based on the one used by TeX without the ability to take a
whole paragraph into acount.</P
><P
>Text output requires at least the Adobe font metric files, even
for the standard PostScript fonts. pslib has not, like other libraries,
the font metrics for the standard fonts compiled in. They are freely
available in the internet. If the font is to be embedded into
the document, then the font outline (.pfb file) is also needed.</P
><P
>Additional files are needed for more sophisticated text output.
It will be explained later in this documentation.
</P
><P
>Before being able to output any text a font has to be loaded
with</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN240"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_findfont</CODE
>(PSDoc *psdoc, const char *fontname, const char *encoding, int embed);</CODE
></P
><P
></P
></DIV
><P
>It returns a unique id for the font.
The fontname is the filename of the Adobe font metrics file
without the extension .afm. If the font shall be embedded into the
document, then the last parameter must be set to 1 and the file
<CODE
CLASS="PARAMETER"
>fontname</CODE
>.pfb must be present.</P
><P
>The <CODE
CLASS="PARAMETER"
>encoding</CODE
> specifies the font encoding
to be used in the PostScript document. It defaults to TeXBase1, which
is a reasonable set of glyphs covering most western languages, when
the empty string or NULL is passed. The special encoding 'builtin'
stands for the encoding as provided by the font itself. It is usually
AdobeStandardEncoding which is a smaller set of glyphs than TeXBase1.
If unsure leave the encoding parameter empty.
</P
><P
>Calling <CODE
CLASS="FUNCTION"
>PS_findfont(3)</CODE
> is a sensitive matter.
Thought it may be called in almost every scope it is highly recommended
to call it either within a page or before the first page (within the
prolog). Especially when
the font is to be embedded or uses a non default encoding. This limitation
has to be enforced in order to be able to extract certain pages from
the document without corruption. Programs like <B
CLASS="COMMAND"
>psselect</B
>
extract a page by taking the prolog of the PostScript document and the
selected page. Resources, like fonts, not being part of the
page or the prolog will not be included into the resulting document and
using those resources will provoke errors.
pslib will output a warning in case of
potential problems.</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN259"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_setfont</CODE
>(PSDoc *psdoc, int fontid, float size);</CODE
></P
><P
></P
></DIV
><P
>sets the font which was loaded with
<CODE
CLASS="FUNCTION"
>PS_findfont(3)</CODE
> in a given size. After calling this
function everything is prepared to output text with one of the following
functions. Each text output function uses kerning pairs and ligatures
if available.</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN271"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_show</CODE
>(PSDoc *psdoc, const char *text);</CODE
></P
><P
></P
></DIV
><P
>outputs text at the current text position and moves the x position
to the end of the text. If text is to be output at a certain position on
the page the function</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN280"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_show_xy</CODE
>(PSDoc *psdoc, const char *text, float x, float y);</CODE
></P
><P
></P
></DIV
><P
>can be used. Both functions also exist in a version which requires
the length of the string as the third parameter. The are called
<CODE
CLASS="FUNCTION"
>PS_show2(3)</CODE
> and <CODE
CLASS="FUNCTION"
>PS_show_xy2(3)</CODE
>.
</P
><P
>The functions mentioned so far will print all text into one line.
If one would like to wrap a longer text into a box, the function</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN296"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_show_boxed</CODE
>(PSDoc *psdoc, const char *text, float left, float bottom, float width, float height, const char *hmode, const char *feature);</CODE
></P
><P
></P
></DIV
><P
>should be usesd. It breaks the text into lines of length
<CODE
CLASS="PARAMETER"
>width</CODE
> and fills the box until there is no space
left.
The function returns the number of remaining chars which did not fit
into the box. This number can be used to create a second, third, ...
box for the remaining text. Text can be left and/or right justified
or centered depending on the parameter <CODE
CLASS="PARAMETER"
>hmode</CODE
>.
Hyphenation is turned off by default, because it needs to be set up
before it can be used.
</P
><P
>Once again, working with fonts is an error prune issue, because
it is important
at what position in the document the fonts are loaded. At a rule of
thumb you should load fonts which are used on several pages of
the document before the first page, and fonts only used on a
single page within that page. For a more detailed discussion see the
section on resource handling.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN320"
></A
><H2
>HYPHENATION, KERNING, LIGATURES, PROTUSION</H2
><P
>pslib's advanced text output features cover hyphenation, kerning,
ligatures and protusion. Kerning and ligatures are turned on by default
and will be used if the current font supports it. Some ligatures are
built into pslib, just in case the font has the glyphs but misses the
command to build the ligature. Those ligatures are fi, fl, ff, ffi,
and ffl. Both ligatures and kerning can be turned off by setting the
parameter 'ligature' respectively 'kerning' to false. pslib automatically
inserts a ligature if the character sequence of that ligature is found.
If a ligature is not to be used then its character sequence must be
broken up with a broken bar character. Ligatures will never be used if
charspacing has a value unequal to zero.</P
><P
>If a font
provides more ligatures as those mentioned before, they are usually
at places not conform to the Adobe Standard Encoding. There glyph name
is often the name of the glyph supposed to be at that position in the
Adobe Standard Encoding. pslib can utilize those ligatures when a so
called encoding file is supplied. The encoding file contains an
font encoding vector and definitions for extra ligatures. An encoding
file is very similar to encoding files used by <B
CLASS="COMMAND"
>dvips</B
>
and usually found in <TT
CLASS="FILENAME"
>/usr/share/texmf/dvips/base</TT
>.
Adding a ligature requires a line like the following:</P
><PRE
CLASS="PROGRAMLISTING"
>% LIGKERN char1 char2 =: ligature ;
</PRE
><P
>If 'char1' is followed by 'char2' they will be both replaced by the
glyph 'ligature'. This replacement may not be used exclusively for
ligatures like 'fi' or 'ff' but for any combination of characters.
Quite common is a hyphen followed by a hyphen, which is replaced by an
endash.</P
><P
>In order to set up hyphenation you will first need a hyphenation
dictionary for your language. Since pslib uses a well know hyphenation
algorithmn used not just by TeX, but also by openoffice and scribus,
one can take the dictionary from those programs. If you have scribus
installed on your system, you will find the dictionaries for many
languages in <TT
CLASS="FILENAME"
>/usr/lib/scribus/dicts</TT
>.</P
><P
>Hyphenation is turned on when the parameter 'hyphenation' is set
to true and the parameter 'hyphendict' contains the file name of the
hyphenation dictionary.</P
><P
>Protusion is an advanced method to improve the appearance of text
margins. It is only used by the function
<CODE
CLASS="FUNCTION"
>PS_show_boxed(3)</CODE
> if the horizontal mode is set
to 'justify'. A margin may not look straight if lines end or begin
with characters with a 'light' appearance like a period, hyphen or comma.
Those characters should reach into the margin to make it look straight.
pslib tries to read a so called protusion file whenever a font is
loaded with <CODE
CLASS="FUNCTION"
>PS_findfont(3)</CODE
>. If it cannot be found
a warning is issued. The file must be named 'fontname.pro' and contains
a line for each character with protusion information. Finding reasonable
protusion values can be a tedious work.</P
><PRE
CLASS="PROGRAMLISTING"
>N hyphen ; M 0 650 ;
N comma ; M 0 650 ;
N period ; M 0 650 ;
N semicolon ; M 0 500 ;
</PRE
><P
>The syntax is similar to an .afm file. The protusion values for the
left and right margin are the last two numbers.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN336"
></A
><H2
>LOADING FILES</H2
><P
>All files which are being loaded by pslib are searched
for in the current directory and the 'SearchPath'. 'SearchPath' is
a parameter which is set by <CODE
CLASS="FUNCTION"
>PS_set_parameter(3)</CODE
>.
<CODE
CLASS="FUNCTION"
>PS_set_parameter(3)</CODE
> can be called multiple
times to add several directories to the search path. Function which
are affected by the search path are <CODE
CLASS="FUNCTION"
>PS_findfont(3)</CODE
>
for loading .afm, .pfb, and .enc files,
<CODE
CLASS="FUNCTION"
>PS_include_file(3)</CODE
>.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN343"
></A
><H2
>RESOURCE HANDLING</H2
><P
>Resources in pslib are fonts, patterns, templates, spot colors, and
images. Templates and images are treated equally. A resource is usally
loaded or created and can be used repeatingly afterwards. Resource
handling is
somewhat sensitve, in terms of the position in the document where they
are loaded or created. Plain PostScript does not care about where a
resource is defined as long as it is known before it is used. PostScript
documents are not always printed but quite often displayed on the screen
or processed by software. Most software which reads PostScript documents
does not just interpret the PostScript code but also so called Document
Structuring Conventions (DSC). Such instructions are helpful to provide
further information about the document and to partition the document
into sections like a prolog and pages. Programs evaluating those
instructions can easily determine the page size, the creator, title or
author, the number of pages and can jump straight to a certain page
without interpreting the PostScript code before that page. Especially
isolating certain pages requires the document to be created stringly
following the DSC. This means that all resource which are used through
out the document must be either created on each page where they are
used (not very sensible if the resource is used more than once)
or within the prolog right before the first
page. pslib will put everything before the first page into the prolog.
On the other side the prolog may not contain any PostScript code that
does output something. pslib makes sure this rule is not violated.
</P
><P
>In practice the above rules do not apply equally to all resource
but can be seen as a general rule of thumb. Fonts can under certain
circumstances be loaded at any time (see the section on 'Text output').
</P
><P
>Please note, that starting from 0.4.5 of pslib images are treated as
resources as well, though this behaviour can be turned of by setting
`imagereuse' to `false' if existing code shows unexpected side effects.
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN348"
></A
><H2
>IMAGES</H2
><P
>Placing images on a page in the PostScript document is similar
to font handling. First the image has to be loaded with</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN351"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_open_image_file</CODE
>(PSDoc *psdoc, const char *type, const char *filename, const char *stringparam, int intparam);</CODE
></P
><P
></P
></DIV
><P
>or</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN366"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_open_image</CODE
>(PSDoc *psdoc, const char *type, const char *source, const char *data, long length, int width, int height, int components, int bpc, const char *params);</CODE
></P
><P
></P
></DIV
><P
>and than it can be placed on the page with the function</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN391"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_place_image</CODE
>(PSDoc *psdoc, int imageid, float x, float y, float scale);</CODE
></P
><P
></P
></DIV
><P
>Once an image is not needed anymore it should be closed to free
the resources.</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN406"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_close_image</CODE
>(PSDoc *psdoc, int imageid);</CODE
></P
><P
></P
></DIV
><P
>Until version 0.4.4 of pslib images are not real resources. Each
call of
<CODE
CLASS="FUNCTION"
>PS_place_image(3)</CODE
> wrote the complete image
into the PostScript file. Starting with version 0.4.5 images are
by default reusable objects which are saved once into the PostScript
file (with <CODE
CLASS="FUNCTION"
>PS_open_image(3)</CODE
> or
<CODE
CLASS="FUNCTION"
>PS_open_image_file(3)</CODE
>) and replayed as often as
desired with <CODE
CLASS="FUNCTION"
>PS_place_image(3)</CODE
>. This behaviour
can be turned off if `imagereuse' is set to `false'. Reusing images
usually has the advantages of smaller file size, faster processing
of the PostScript file and the possibility to place images into
templates which was not allowed till version 0.4.4. If an image is
placed into a template and is not needed anymore, it can be closed
right after ending the template.</P
><P
>Please note, that everything sayed about resources becomes true
for reusable images, too.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN420"
></A
><H2
>TEMPLATES</H2
><P
>Templates are a bit like images created within the document
itself. Their big advantage is its reusability on any page thoughout
the document by simply referencing them. This saves a lot of disk space
if the template is placed many times. They are often used for logos or
headers which are to
be placed on each page. A template is started with the function</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN423"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_begin_template</CODE
>(PSDoc *psdoc, float width, float height);</CODE
></P
><P
></P
></DIV
><P
>Like a page or an image a template has a boundig box. Within that
box almost any operation for drawing, text output, etc. can be called.
Everything beyond the bounding box is clipped.
A template is ended and ready for use with</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN434"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_end_template</CODE
>(PSDoc *psdoc);</CODE
></P
><P
></P
></DIV
><P
>Each template has its own id which was returned by
<CODE
CLASS="FUNCTION"
>PS_begin_template(3)</CODE
>. This id is like an image id and
can be passed to <CODE
CLASS="FUNCTION"
>PS_place_image(3)</CODE
>. This makes a
template identical to an image in terms of handling. Any call of
<CODE
CLASS="FUNCTION"
>PS_place_image(3)</CODE
> will only place a reference to
the template into the document which results in a small document
size.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN444"
></A
><H2
>COLORS</H2
><P
>pslib supports all colorspaces available in PostScript including
spot colors. Opposed to the PostScript color modell which knows just
one current color, pslib distinguishes between a stroke and fill color.
Colors are set with</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN447"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_setcolor</CODE
>(PSDoc *psdoc, const char *type, const char *colorspace, float c1, float c2, float c3, float c4);</CODE
></P
><P
></P
></DIV
><P
><CODE
CLASS="PARAMETER"
>type</CODE
> determines if the fill, stroke or
both (fillstroke) colors are set by the function. The colorspace
can be any of 'gray', 'rgb', 'cmyk', 'spot', or 'pattern'. The colorspace
'pattern' is somewhat special and will be discussed in the next section.
The float parameters contain the actual values of the color. Depending
on the colorspace not all parameters will be evaluated. Spot colors
need to be created before with</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN467"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_makespotcolor</CODE
>(PSDoc *psdoc, const char *name, floatreserved);</CODE
></P
><P
></P
></DIV
><P
>The name of the spot color can be any string value, thought one will
usually take the official name of the spot color, e.g. PANTONE 114 C.
Each spot color has a color in an alternative colorspace which is used
when the spot color itself cannot be used. This is always the case when
the PostScript file is viewed on a computer screen or printed by an ink
printer. If the PostScript document is separated for professional
printing, the alternative color has no meaning. The alternative color is
taken from the current fill color. This means, that you have to call
<CODE
CLASS="FUNCTION"
>PS_setcolor(3)</CODE
> and set the current fill color before
calling <CODE
CLASS="FUNCTION"
>PS_makespotcolor(3)</CODE
>.
<CODE
CLASS="FUNCTION"
>PS_makespotcolor(3)</CODE
> can only handle fill colors in
the colorspace 'gray', 'rgb', or 'cmyk'.</P
><P
><CODE
CLASS="FUNCTION"
>PS_makespotcolor(3)</CODE
> returns the id of the spot
color which is passed as parameter <CODE
CLASS="PARAMETER"
>c1</CODE
> to
<CODE
CLASS="FUNCTION"
>PS_setcolor(3)</CODE
>. All spot colors used in the document
should be defined before the first page, otherwise they will not be
included into the list of custom colors within the document comments
section at the beginning of the file.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN485"
></A
><H2
>COLOR SEPARATION</H2
><P
>Printing a document sometimes requires to separate colors
because certain printers print each color separately.
Color separation is often done on the
multi color document by the printing company. However, pslib can
separate colors very easily by setting the value 'separationcolor' on
a value from 1 to 4, depending on the color you would like to separate
(1=cyan, 2=magenta, 3=yellow, 4=black). This has to be done before
creating a page. The resulting document will
contain only those parts in the separated color. Consequently, one
has to create four identical pages, each called with a different value
for 'separationcolor'.
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN488"
></A
><H2
>PATTERNS</H2
><P
>Filling an area can be done with a single color or a self designed
pattern. Such a pattern can be any drawing. Actually, it can be everything
which can be put on a page. If a pattern is used for filling it is
repeatingly placed in horizontal and vertical direction with a given
distance. Pattern are started with</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN491"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_begin_pattern</CODE
>(PSDoc *psdoc, float width, float height, float xstep, float ystep, int painttype);</CODE
></P
><P
></P
></DIV
><P
>and ended with</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN508"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_end_pattern</CODE
>(PSDoc *psdoc);</CODE
></P
><P
></P
></DIV
><P
>Within those two functions almost any output operation can be
used for creating the pattern. Once a pattern is created, it
can be used like a color for filling. Just pass the string "pattern"
and the pattern id (returned by <CODE
CLASS="FUNCTION"
>PS_begin_pattern(3)</CODE
>)
to <CODE
CLASS="FUNCTION"
>PS_setcolor(3)</CODE
>. Any following drawing and/or
filling operation will now use the pattern.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN517"
></A
><H2
>HYPERLINKS, BOOKMARKS</H2
><P
>PostScript itself does not support any hyperlink functions like
PDF does. Nervertheless, one can embed hyperlinks into a PostScript
document which will be used if the document is later converted to PDF.
Such commands for embedding hyperlinks are called pdfmarks. pdfmarks
allow to store any feature in a PostScript document which is available
in PDF. The PostScript interpreter itself will not care about the
pdfmarks. This features makes pslib a viable alternative to libraries
creating PDF directly.</P
><P
>Some functions of pslib will place a pdfmark silently into the
document. The most prominent function is
<CODE
CLASS="FUNCTION"
>PS_begin_page(3)</CODE
> which stores the page size with
the help of pdfmarks.</P
><P
>pslib supports several types of hyperlinks, which are inserted
with the following function.</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN523"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_add_weblink</CODE
>(PSDoc *psdoc, float llx, float lly, float urx, float ury, const char *url);</CODE
></P
><P
></P
></DIV
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN539"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_add_pdflink</CODE
>(PSDoc *psdoc, float llx, float lly, float urx, float ury, const char *filename, int page, const char *dest);</CODE
></P
><P
></P
></DIV
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN559"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_add_locallink</CODE
>(PSDoc *psdoc, float llx, float lly, float urx, float ury, int page, const char *dest);</CODE
></P
><P
></P
></DIV
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN577"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_add_launchlink</CODE
>(PSDoc *psdoc, float llx, float lly, float urx, float ury, const char *filename);</CODE
></P
><P
></P
></DIV
><P
>Each of the above function requires a rectangle with its lower
left corner at <CODE
CLASS="PARAMETER"
>llx</CODE
>, <CODE
CLASS="PARAMETER"
>lly</CODE
>
and its upper right corner at <CODE
CLASS="PARAMETER"
>urx</CODE
>,
<CODE
CLASS="PARAMETER"
>ury</CODE
>. The rectangle will not be visible in the
PostScript file and marks the sensitve area of the link. When the
document is concerted to PDF, the rectangle will become visible.
Its appearance can be set with the functions.</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN598"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_set_border_style</CODE
>(PSDoc *psdoc, const char *style, float width);</CODE
></P
><P
></P
></DIV
><P
><CODE
CLASS="PARAMETER"
>style</CODE
> can be either 'solid' or 'dashed'.</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN610"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_set_border_color</CODE
>(PSDoc *psdoc, float red, float green, float blue);</CODE
></P
><P
></P
></DIV
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN622"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_set_border_dash</CODE
>(PSDoc *psdoc, float black, float white);</CODE
></P
><P
></P
></DIV
><P
>pslib also supports to add bookmarks which will be displayed
by PDF viewers as a table of contents next to the document. Bookmarks have
a title and point to a page in the document. The can be added with</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN633"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_add_bookmark</CODE
>(PSDoc *psdoc, const char *text, int parent, int open);</CODE
></P
><P
></P
></DIV
><P
>To build up a hierachical tree of bookmarks, one can pass a
parent bookmark when creating a new one. The parent bookmark is referenced
by its id as it is returned by the function itself. A bookmark is
always added for the current page. It is shown open if the parameter
<CODE
CLASS="PARAMETER"
>open</CODE
> is greater 0.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN647"
></A
><H2
>TYPE3 FONTS</H2
><P
>PostScript knows several types of fonts. The most common is
called Type1 which are usally supplied by many font manufactures
as .pfb files. pslib can read those fonts and use them right away.
Another type of font is called Type3. Type3 fonts distinguish from
Type1 fonts by the way its glyphs are constructed. Glyphs in Type3
fonts are created with regular PostScript commands and can easily
be created with pslib. All you need to do is start a new font with</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN650"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_begin_font</CODE
>(PSDoc *psdoc, const char *fontname, int reserved, double a, double b, double c, double d, double e, double f, const char *optlist);</CODE
></P
><P
></P
></DIV
><P
>and end finish it with</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN675"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_end_font</CODE
>(PSDoc *psdoc);</CODE
></P
><P
></P
></DIV
><P
>Each font contains of a number of glyphs which are created
with a pair of</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN682"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_begin_glyph</CODE
>(PSDoc *psdoc, const char *glyphname, double wx, double llx, double lly, double urx, double ury);</CODE
></P
><P
></P
></DIV
><P
>and</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN701"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_end_glyph</CODE
>(PSDoc *psdoc);</CODE
></P
><P
></P
></DIV
><P
>Within a glyph each command is allowed to create a path and to
stroke or fill it. Once a font is created it can be used like any
other font by calling <CODE
CLASS="FUNCTION"
>PS_setfont(3)</CODE
>.</P
><P
>The font cannot be saved to a file and used by other applications
but it can used within the pslib document which has several advantages
when certain symbols, e.g. logos are used through out a document.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN710"
></A
><H2
>MEMORY MANAGEMENT, ERROR HANDLING</H2
><P
>pslib uses by default its on memory management and error handling
functions. In many cases the calling application has its own memory
management and error handling. pslib can be told to use those
functions by calling <CODE
CLASS="FUNCTION"
>PS_new2(3)</CODE
> instead of
<CODE
CLASS="FUNCTION"
>PS_new(3)</CODE
>.</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN715"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_new2</CODE
>(PSDoc *psdoc, (errorhandler *) (PSDoc *p, int type, const char *msg, void *data), (allocproc *) (PSDoc *p, size_t size, const char *caller), (reallocproc *) (PSDoc *p, void *mem, size_t size, const char *caller), (freeproc *) (PSDoc *p, void *mem), void *opaque);</CODE
></P
><P
></P
></DIV
><P
>The errorhandler and the last parameter <CODE
CLASS="PARAMETER"
>opaque</CODE
>
allow to pass arbitrary data as the last parameter to its own
errorhandler. This is quite often used if errors are being output
in a widget of a graphical toolkit. The pointer to that widget can
be passed as <CODE
CLASS="PARAMETER"
>opaque</CODE
> and pslib will pass it
forward to the error handler.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN734"
></A
><H2
>DOCUMENT INFORMATION</H2
><P
>PostScript documents usually contain a header made of comments
with information about the document. The printer usually disregards
this information but many PostScript viewer use it. Besides that,
one can also place pdfmarks into the PostScript document which contain
the title, keywords, author and other information. pslib provides the
function <CODE
CLASS="FUNCTION"
>PS_set_info(3)</CODE
> to set those fields.</P
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN738"
></A
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int PS_set_info</CODE
>(PSDoc *psdoc, const char *key, const char *value);</CODE
></P
><P
></P
></DIV
><P
><CODE
CLASS="FUNCTION"
>PS_set_info(3)</CODE
> must be called before the
first page. Calling it later will have no effect and produces a warning.
The function may also be used to set the bounding box of the document.
Usually there is no need for it, because the dimension of the first
page will be used for the bounding box.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN750"
></A
><H2
>SEE ALSO</H2
><P
>The detailed manual pages for each function of the library.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN753"
></A
><H2
>AUTHOR</H2
><P
>This manual page was written by Uwe Steinmann <CODE
CLASS="EMAIL"
>&#60;<A
HREF="mailto:uwe@steinmann.cx"
>uwe@steinmann.cx</A
>&#62;</CODE
>.</P
></DIV
></BODY
></HTML
>