aboutsummaryrefslogtreecommitdiff
path: root/libX11/specs/libX11/CH08
blob: 3d2161fb2bead01d70c99115bcb89edd3f13834d (plain)
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
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
.\" a copy of this software and associated documentation files (the
.\" "Software"), to deal in the Software without restriction, including
.\" without limitation the rights to use, copy, modify, merge, publish,
.\" distribute, sublicense, and/or sell copies of the Software, and to
.\" permit persons to whom the Software is furnished to do so, subject to
.\" the following conditions:
.\"
.\" The above copyright notice and this permission notice shall be included
.\" in all copies or substantial portions of the Software.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
.\" OTHER DEALINGS IN THE SOFTWARE.
.\"
.\" Except as contained in this notice, the name of the X Consortium shall
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
.\"
.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
.\" Digital Equipment Corporation
.\"
.\" Portions Copyright \(co 1990, 1991 by
.\" Tektronix, Inc.
.\"
.\" Permission to use, copy, modify and distribute this documentation for
.\" any purpose and without fee is hereby granted, provided that the above
.\" copyright notice appears in all copies and that both that copyright notice
.\" and this permission notice appear in all copies, and that the names of
.\" Digital and Tektronix not be used in in advertising or publicity pertaining
.\" to this documentation without specific, written prior permission.
.\" Digital and Tektronix makes no representations about the suitability
.\" of this documentation for any purpose.
.\" It is provided ``as is'' without express or implied warranty.
.\" 
\&
.sp 1
.ce 3
\s+1\fBChapter 8\fP\s-1

\s+1\fBGraphics Functions\fP\s-1
.sp 2
.nr H1 8
.nr H2 0
.nr H3 0
.nr H4 0
.nr H5 0
.na
.LP
.XS
Chapter 8: Graphics Functions 
.XE
Once you have established a connection to a display,
you can use the Xlib graphics functions to:
.IP \(bu 5
Clear and copy areas
.IP \(bu 5
Draw points, lines, rectangles, and arcs
.IP \(bu 5
Fill areas
.IP \(bu 5
Manipulate fonts
.IP \(bu 5
Draw text
.IP \(bu 5
Transfer images between clients and the server
.LP
If the same drawable and GC is used for each call,
Xlib batches back-to-back calls to
.PN XDrawPoint ,
.PN XDrawLine ,
.PN XDrawRectangle ,
.PN XFillArc ,
and
.PN XFillRectangle .
Note that this reduces the total number of requests sent to the server.
.NH 2
Clearing Areas
.XS
\*(SN Clearing Areas 
.XE
.LP
Xlib provides functions that you can use to clear an area or the entire window.
Because pixmaps do not have defined backgrounds, 
they cannot be filled by using the functions described in this section.
Instead, to accomplish an analogous operation on a pixmap,
you should use 
.PN XFillRectangle ,
which sets the pixmap to a known value.
.LP
.sp
To clear a rectangular area of a given window, use
.PN XClearArea .
.IN "Areas" "clearing"
.IN "Clearing" "areas"
.IN "XClearArea" "" "@DEF@"
.sM
.FD 0
XClearArea\^(\^\fIdisplay\fP, \fIw\fP\^, \fIx\fP\^, \fIy\fP\^, \fIwidth\fP\^, \fIheight\fP\^, \fIexposures\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Window \fIw\fP\^;
.br
      int \fIx\fP\^, \fIy\fP\^;
.br
      unsigned int \fIwidth\fP\^, \fIheight\fP\^;
.br
      Bool \fIexposures\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fIw\fP 1i
Specifies the window.
.ds Xy , which are relative to the origin of the window \
and specify the upper-left corner of the rectangle
.IP \fIx\fP 1i
.br
.ns
.IP \fIy\fP 1i
Specify the x and y coordinates\*(Xy.
.ds Wh , which are the dimensions of the rectangle
.IP \fIwidth\fP 1i
.br
.ns
.IP \fIheight\fP 1i
Specify the width and height\*(Wh.
.IP \fIexposures\fP 1i
Specifies a Boolean value that indicates if
.PN Expose
events are to be generated.
.LP
.eM
The
.PN XClearArea
function paints a rectangular area in the specified window according to the
specified dimensions with the window's background pixel or pixmap.
The subwindow-mode effectively is
.PN ClipByChildren . 
If width is zero, it
is replaced with the current width of the window minus x.
If height is
zero, it is replaced with the current height of the window minus y.
If the window has a defined background tile, 
the rectangle clipped by any children is filled with this tile.
If the window has
background 
.PN None , 
the contents of the window are not changed.  
In either
case, if exposures is 
.PN True , 
one or more 
.PN Expose 
events are generated for regions of the rectangle that are either visible or are
being retained in a backing store.
If you specify a window whose class is
.PN InputOnly ,
a
.PN BadMatch
error results.
.LP
.PN XClearArea
can generate
.PN BadMatch ,
.PN BadValue ,
and
.PN BadWindow 
errors.
.LP
.sp
To clear the entire area in a given window, use
.PN XClearWindow .
.IN "Window" "clearing"
.IN "Clearing" "windows"
.IN "XClearWindow" "" "@DEF@"
.sM
.FD 0
XClearWindow\^(\^\fIdisplay\fP, \fIw\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Window \fIw\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fIw\fP 1i
Specifies the window.
.LP
.eM
The
.PN XClearWindow
function clears the entire area in the specified window and is
equivalent to
.PN XClearArea
(display, w, 0, 0, 0, 0, 
.PN False ).
If the window has a defined background tile, the rectangle is tiled with a
plane-mask of all ones and 
.PN GXcopy
function.
If the window has
background 
.PN None , 
the contents of the window are not changed.  
If you specify a window whose class is
.PN InputOnly ,
a
.PN BadMatch
error results. 
.LP
.PN XClearWindow
can generate
.PN BadMatch
and
.PN BadWindow 
errors.
.NH 2
Copying Areas
.XS
\*(SN Copying Areas 
.XE
.LP
Xlib provides functions that you can use to copy an area or a bit plane.
.LP
.sp
To copy an area between drawables of the same
root and depth, use
.PN XCopyArea .
.IN "Areas" "copying"
.IN "Copying" "areas"
.IN "XCopyArea" "" "@DEF@"
.sM
.FD 0
XCopyArea\^(\^\fIdisplay\fP, \fIsrc\fP\^, \fIdest\fP\^, \fIgc\fP\^, \fIsrc_x\fP\^, \fIsrc_y\fP\^, \fIwidth\fP\^, \fIheight\fP\^,  \fIdest_x\fP\^, \fIdest_y\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fIsrc\fP\^, \fIdest\fP\^;
.br
      GC \fIgc\fP\^;
.br
      int \fIsrc_x\fP\^, \fIsrc_y\fP\^;
.br
      unsigned int \fIwidth\fP\^, \fIheight\fP\^;
.br
      int \fIdest_x\fP\^, \fIdest_y\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fIsrc\fP 1i
.br
.ns
.IP \fIdest\fP 1i
Specify the source and destination rectangles to be combined. 
.IP \fIgc\fP 1i
Specifies the GC.
.IP \fIsrc_x\fP 1i
.br
.ns
.IP \fIsrc_y\fP 1i
Specify the x and y coordinates, 
which are relative to the origin of the source rectangle
and specify its upper-left corner.
.ds Wh , which are the dimensions of both the source \
and destination rectangles
.IP \fIwidth\fP 1i
.br
.ns
.IP \fIheight\fP 1i
Specify the width and height\*(Wh.
.ds Dx , which are relative to the origin of the destination rectangle \
and specify its upper-left corner
.IP \fIdest_x\fP 1i
.br
.ns
.IP \fIdest_y\fP 1i
Specify the x and y coordinates\*(Dx. 
.LP
.eM
The
.PN XCopyArea
function combines the specified rectangle of src with the specified rectangle 
of dest.
The drawables must have the same root and depth,
or a
.PN BadMatch
error results.
.LP
If regions of the source rectangle are obscured and have not been
retained in backing store 
or if regions outside the boundaries of the source drawable are specified, 
those regions are not copied. 
Instead, the 
following occurs on all corresponding destination regions that are either
visible or are retained in backing store.  
If the destination is a window with a background other than 
.PN None , 
corresponding regions
of the destination are tiled with that background
(with plane-mask of all ones and
.PN GXcopy 
function).
Regardless of tiling or whether the destination is a window or a pixmap,
if graphics-exposures is 
.PN True ,
then
.PN GraphicsExpose
events for all corresponding destination regions are generated.
If graphics-exposures is 
.PN True 
but no
.PN GraphicsExpose
events are generated, a
.PN NoExpose 
event is generated.
Note that by default graphics-exposures is
.PN True
in new GCs.
.LP
This function uses these GC components: function, plane-mask, 
subwindow-mode, graphics-exposures, clip-x-origin,
clip-y-origin, and clip-mask.
.LP
.PN XCopyArea
can generate
.PN BadDrawable ,
.PN BadGC ,
and
.PN BadMatch 
errors.
.sp
.LP
To copy a single bit plane of a given drawable, use
.PN XCopyPlane .
.IN "Plane" "copying"
.IN "Copying" "planes"
.IN "XCopyPlane" "" "@DEF@"
.sM
.FD 0
XCopyPlane\^(\^\fIdisplay\fP, \fIsrc\fP\^, \fIdest\fP\^, \fIgc\fP\^, \fIsrc_x\fP\^, \fIsrc_y\fP\^, \fIwidth\fP\^, \fIheight\fP\^, \fIdest_x\fP\^, \fIdest_y\fP\^, \fIplane\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fIsrc\fP\^, \fIdest\fP\^;
.br
      GC \fIgc\fP\^;
.br
      int \fIsrc_x\fP\^, \fIsrc_y\fP\^;
.br
      unsigned int \fIwidth\fP\^, \fIheight\fP\^;
.br
      int \fIdest_x\fP\^, \fIdest_y\fP\^;
.br
      unsigned long \fIplane\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fIsrc\fP 1i
.br
.ns
.IP \fIdest\fP 1i
Specify the source and destination rectangles to be combined. 
.IP \fIgc\fP 1i
Specifies the GC.
.IP \fIsrc_x\fP 1i
.br
.ns
.IP \fIsrc_y\fP 1i
Specify the x and y coordinates, 
which are relative to the origin of the source rectangle
and specify its upper-left corner.
.ds Wh , which are the dimensions of both the source and destination rectangles
.IP \fIwidth\fP 1i
.br
.ns
.IP \fIheight\fP 1i
Specify the width and height\*(Wh.
.ds Dx , which are relative to the origin of the destination rectangle \
and specify its upper-left corner
.IP \fIdest_x\fP 1i
.br
.ns
.IP \fIdest_y\fP 1i
Specify the x and y coordinates\*(Dx. 
.IP \fIplane\fP 1i
Specifies the bit plane.
You must set exactly one bit to 1.
.LP
.eM
The
.PN XCopyPlane
function uses a single bit plane of the specified source rectangle
combined with the specified GC to modify the specified rectangle of dest.
The drawables must have the same root but need not have the same depth.
If the drawables do not have the same root, a
.PN BadMatch
error results.
If plane does not have exactly one bit set to 1 and the value of plane
is not less than %2 sup n%, where \fIn\fP is the depth of src, a
.PN BadValue
error results.
.LP
Effectively, 
.PN XCopyPlane
forms a pixmap of the same depth as the rectangle of dest and with a
size specified by the source region. 
It uses the foreground/background pixels in the GC (foreground
everywhere the bit plane in src contains a bit set to 1,
background everywhere the bit plane in src contains a bit set to 0)
and the equivalent of a 
.PN CopyArea
protocol request is performed with all the same exposure semantics.
This can also be thought of as using the specified region of the source 
bit plane as a stipple with a fill-style of
.PN FillOpaqueStippled
for filling a rectangular area of the destination.
.LP
This function uses these GC components: function, plane-mask, foreground,
background, subwindow-mode, graphics-exposures, clip-x-origin, clip-y-origin,
and clip-mask.
.LP
.PN XCopyPlane
can generate
.PN BadDrawable ,
.PN BadGC ,
.PN BadMatch ,
and 
.PN BadValue 
errors.
.NH 2
Drawing Points, Lines, Rectangles, and Arcs
.XS
\*(SN Drawing Points, Lines, Rectangles, and Arcs 
.XE
.LP
Xlib provides functions that you can use to draw:
.IP \(bu 5
A single point or multiple points
.IP \(bu 5
A single line or multiple lines
.IP \(bu 5
A single rectangle or multiple rectangles
.IP \(bu 5
A single arc or multiple arcs
.LP
Some of the functions described in the following sections
use these structures:
.LP
.IN "XSegment" "" "@DEF@"
.sM
.Ds 0
.TA .5i
.ta .5i
typedef struct {
	short x1, y1, x2, y2;
} XSegment;
.De
.LP
.eM
.IN "XPoint" "" "@DEF@"
.sM
.Ds 0
.TA .5i
.ta .5i
typedef struct {
	short x, y;
} XPoint;
.De
.LP
.eM
.IN "XRectangle" "" "@DEF@"
.sM
.Ds 0
.TA .5i
.ta .5i
typedef struct {
	short x, y;
	unsigned short width, height;
} XRectangle;
.De
.LP
.eM
.IN "XArc" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	short x, y;
	unsigned short width, height;
	short angle1, angle2;             /* Degrees * 64 */
} XArc;
.De
.LP
.eM
All x and y members are signed integers.
The width and height members are 16-bit unsigned integers.
You should be careful not to generate coordinates and sizes
out of the 16-bit ranges, because the protocol only has 16-bit fields
for these values.
.NH 3
Drawing Single and Multiple Points
.XS
\*(SN Drawing Single and Multiple Points 
.XE
.LP
.IN "Points" "drawing"
.IN "Drawing" "points"
.IN "XDrawPoints"
.IN "XDrawPoint"
.LP
To draw a single point in a given drawable, use
.PN XDrawPoint .
.IN "XDrawPoint" "" "@DEF@"
.sM
.FD 0
XDrawPoint\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      int \fIx\fP\^, \fIy\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.IP \fIx\fP 1i
.br
.ns
.IP \fIy\fP 1i
Specify the x and y coordinates where you want the point drawn.
.LP
.eM
.sp
To draw multiple points in a given drawable, use
.PN XDrawPoints .
.IN "XDrawPoints" "" "@DEF@"
.sM
.FD 0
XDrawPoints\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIpoints\fP\^, \fInpoints\fP\^, \fImode\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      XPoint *\fIpoints\fP\^;
.br
      int \fInpoints\fP\^;
.br
      int \fImode\fP\^; 
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.IP \fIpoints\fP 1i
Specifies an array of points.
.IP \fInpoints\fP 1i
Specifies the number of points in the array.
.IP \fImode\fP 1i
Specifies the coordinate mode. 
You can pass
.PN CoordModeOrigin
or
.PN CoordModePrevious .
.LP
.eM
The
.PN XDrawPoint
function uses the foreground pixel and function components of the
GC to draw a single point into the specified drawable; 
.PN XDrawPoints
draws multiple points this way.
.PN CoordModeOrigin
treats all coordinates as relative to the origin,
and
.PN CoordModePrevious
treats all coordinates after the first as relative to the previous point.
.PN XDrawPoints
draws the points in the order listed in the array.
.LP
Both functions use these GC components: function, plane-mask,
foreground, subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask.
.LP
.PN XDrawPoint
can generate
.PN BadDrawable ,
.PN BadGC ,
and 
.PN BadMatch 
errors.
.PN XDrawPoints
can generate
.PN BadDrawable ,
.PN BadGC ,
.PN BadMatch ,
and
.PN BadValue 
errors.
.NH 3
Drawing Single and Multiple Lines
.XS
\*(SN Drawing Single and Multiple Lines
.XE
.LP
.IN "Lines" "drawing"
.IN "Drawing" "lines"
.IN "XDrawLine"
.IN "XDrawLines"
.IN "Polygons" "drawing"
.IN "Drawing" "polygons"
.IN "XDrawSegments"
.LP
To draw a single line between two points in a given drawable, use
.PN XDrawLine .
.IN "XDrawLine" "" "@DEF@"
.sM
.FD 0
XDrawLine\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx1\fP\^, \fIy1\fP\^, \fIx2\fP\^, \fIy2\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      int \fIx1\fP\^, \fIy1\fP\^, \fIx2\fP\^, \fIy2\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.IP \fIx1\fP 1i
.br
.ns
.IP \fIy1\fP 1i
.br
.ns
.IP \fIx2\fP 1i
.br
.ns
.IP \fIy2\fP 1i
Specify the points (x1, y1) and (x2, y2) to be connected.
.LP
.eM
.sp
To draw multiple lines in a given drawable, use
.PN XDrawLines .
.IN "XDrawLines" "" "@DEF@"
.sM
.FD 0
XDrawLines\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIpoints\fP\^, \fInpoints\fP\^, \fImode\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      XPoint *\fIpoints\fP\^;
.br
      int \fInpoints\fP\^;
.br
      int \fImode\fP\^; 
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.IP \fIpoints\fP 1i
Specifies an array of points.
.IP \fInpoints\fP 1i
Specifies the number of points in the array.
.IP \fImode\fP 1i
Specifies the coordinate mode. 
You can pass
.PN CoordModeOrigin
or
.PN CoordModePrevious .
.LP
.eM
.sp
To draw multiple, unconnected lines in a given drawable,
use
.PN XDrawSegments .
.IN "XDrawSegments" "" "@DEF@"
.sM
.FD 0
XDrawSegments\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIsegments\fP\^, \fInsegments\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      XSegment *\fIsegments\fP\^;
.br
      int \fInsegments\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.IP \fIsegments\fP 1i
Specifies an array of segments.
.IP \fInsegments\fP 1i
Specifies the number of segments in the array.
.LP
.eM
The
.PN XDrawLine
function uses the components of the specified GC to
draw a line between the specified set of points (x1, y1) and (x2, y2).
It does not perform joining at coincident endpoints.
For any given line, 
.PN XDrawLine 
does not draw a pixel more than once.
If lines intersect, the intersecting pixels are drawn multiple times.  
.LP
The
.PN XDrawLines
function uses the components of the specified GC to draw 
npoints\-1 lines between each pair of points (point[i], point[i+1]) 
in the array of
.PN XPoint
structures.
It draws the lines in the order listed in the array.
The lines join correctly at all intermediate points, and if the first and last
points coincide, the first and last lines also join correctly.
For any given line, 
.PN XDrawLines
does not draw a pixel more than once.
If thin (zero line-width) lines intersect, 
the intersecting pixels are drawn multiple times.
If wide lines intersect, the intersecting pixels are drawn only once, as though
the entire 
.PN PolyLine 
protocol request were a single, filled shape.
.PN CoordModeOrigin
treats all coordinates as relative to the origin,
and
.PN CoordModePrevious
treats all coordinates after the first as relative to the previous point.
.LP
The
.PN XDrawSegments 
function draws multiple, unconnected lines. 
For each segment, 
.PN XDrawSegments 
draws a
line between (x1, y1) and (x2, y2).
It draws the lines in the order listed in the array of
.PN XSegment
structures and does not perform joining at coincident endpoints.
For any given line, 
.PN XDrawSegments
does not draw a pixel more than once.  
If lines intersect, the intersecting pixels are drawn multiple times.  
.LP
All three functions use these GC components:
function, plane-mask, line-width,
line-style, cap-style, fill-style, subwindow-mode,
clip-x-origin, clip-y-origin, and clip-mask.
The
.PN XDrawLines
function also uses the join-style GC component.
All three functions also use these GC mode-dependent components:
foreground, background, tile, stipple, tile-stipple-x-origin, 
tile-stipple-y-origin, dash-offset, and dash-list.
.LP
.PN XDrawLine ,
.PN XDrawLines ,
and
.PN XDrawSegments
can generate
.PN BadDrawable ,
.PN BadGC ,
and
.PN BadMatch 
errors.
.PN XDrawLines
also can generate
.PN BadValue 
errors.
.NH 3
Drawing Single and Multiple Rectangles 
.XS
\*(SN Drawing Single and Multiple Rectangles 
.XE
.LP
.IN "Rectangles" "drawing"
.IN "Drawing" "rectangles"
.IN "XDrawRectangle"
.IN "XDrawRectangles"
.LP
To draw the outline of a single rectangle in a given drawable, use
.PN XDrawRectangle .
.IN "XDrawRectangle" "" "@DEF@"
.sM
.FD 0
XDrawRectangle\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIwidth\fP\^, \fIheight\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      int \fIx\fP\^, \fIy\fP\^;
.br
      unsigned int \fIwidth\fP\^, \fIheight\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.ds Xy , which specify the upper-left corner of the rectangle
.IP \fIx\fP 1i
.br
.ns
.IP \fIy\fP 1i
Specify the x and y coordinates\*(Xy.
.ds Wh , which specify the dimensions of the rectangle
.IP \fIwidth\fP 1i
.br
.ns
.IP \fIheight\fP 1i
Specify the width and height\*(Wh.
.LP
.eM
.sp
To draw the outline of multiple rectangles
in a given drawable, use
.PN XDrawRectangles .
.IN "XDrawRectangles" "" "@DEF@"
.sM
.FD 0
XDrawRectangles\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIrectangles\fP\^, \fInrectangles\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      XRectangle \fIrectangles\fP\^[\^]\^;
.br
      int \fInrectangles\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.IP \fIrectangles\fP 1i
Specifies an array of rectangles.
.IP \fInrectangles\fP 1i
Specifies the number of rectangles in the array.
.LP
.eM
The
.PN XDrawRectangle
and
.PN XDrawRectangles
functions draw the outlines of the specified rectangle or rectangles as
if a five-point 
.PN PolyLine 
protocol request were specified for each rectangle:
.IP
[x,y] [x+width,y] [x+width,y+height] [x,y+height] [x,y]
.LP 
For the specified rectangle or rectangles, 
these functions do not draw a pixel more than once.
.PN XDrawRectangles
draws the rectangles in the order listed in the array.
If rectangles intersect,
the intersecting pixels are drawn multiple times.
.LP
Both functions use these GC components: 
function, plane-mask, line-width,
line-style, cap-style, join-style, fill-style, 
subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask.
They also use these GC mode-dependent components: 
foreground, background, tile, stipple, tile-stipple-x-origin, 
tile-stipple-y-origin, dash-offset, and dash-list.
.LP
.PN XDrawRectangle
and
.PN XDrawRectangles
can generate
.PN BadDrawable ,
.PN BadGC ,
and
.PN BadMatch 
errors.
.NH 3
Drawing Single and Multiple Arcs
.XS
\*(SN Drawing Single and Multiple Arcs 
.XE
.LP
.IN "Drawing" "arcs"
.IN "XDrawArc"
.IN "Arcs" "drawing"
.IN "XDrawArcs"
.LP
.sp
To draw a single arc in a given drawable, use
.PN XDrawArc .
.IN "XDrawArc" "" "@DEF@"
.sM
.FD 0
XDrawArc\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIwidth\fP\^, \fIheight\fP\^, \fIangle1\fP\^, \fIangle2\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      int \fIx\fP\^, \fIy\fP\^;
.br
      unsigned int \fIwidth\fP\^, \fIheight\fP\^;
.br
      int \fIangle1\fP\^, \fIangle2\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.ds Xy , which are relative to the origin of the drawable \
and specify the upper-left corner of the bounding rectangle
.IP \fIx\fP 1i
.br
.ns
.IP \fIy\fP 1i
Specify the x and y coordinates\*(Xy.
.ds Wh , which are the major and minor axes of the arc
.IP \fIwidth\fP 1i
.br
.ns
.IP \fIheight\fP 1i
Specify the width and height\*(Wh.
.IP \fIangle1\fP 1i
Specifies the start of the arc relative to the three-o'clock position
from the center, in units of degrees * 64.
.IP \fIangle2\fP 1i
Specifies the path and extent of the arc relative to the start of the
arc, in units of degrees * 64.
.LP
.eM
.sp
To draw multiple arcs in a given drawable, use
.PN XDrawArcs .
.IN "XDrawArcs" "" "@DEF@"
.sM
.FD 0
XDrawArcs\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIarcs\fP\^, \fInarcs\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      XArc *\fIarcs\fP\^;
.br
      int \fInarcs\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.IP \fIarcs\fP 1i
Specifies an array of arcs.
.IP \fInarcs\fP 1i
Specifies the number of arcs in the array.
.LP
.eM
.EQ
delim %%
.EN
.PN XDrawArc
draws a single circular or elliptical arc, and 
.PN XDrawArcs
draws multiple circular or elliptical arcs.
Each arc is specified by a rectangle and two angles.  
The center of the circle or ellipse is the center of the
rectangle, and the major and minor axes are specified by the width and height.
Positive angles indicate counterclockwise motion, 
and negative angles indicate clockwise motion.  
If the magnitude of angle2 is greater than 360 degrees, 
.PN XDrawArc
or 
.PN XDrawArcs
truncates it to 360 degrees.
.LP
For an arc specified as %[ ~x, ~y, ~width , ~height, ~angle1, ~angle2 ]%, 
the origin of the major and minor axes is at 
% [ x +^ {width over 2} , ~y +^ {height over 2}  ]%, 
and the infinitely thin path describing the entire circle or ellipse 
intersects the horizontal axis at % [ x, ~y +^ {height over 2}  ]% and 
% [ x +^ width , ~y +^ { height over 2 }] %
and intersects the vertical axis at % [ x +^ { width over 2 } , ~y ]% and 
% [ x +^ { width over 2 }, ~y +^ height ]%.
These coordinates can be fractional
and so are not truncated to discrete coordinates.
The path should be defined by the ideal mathematical path.  
For a wide line with line-width lw, 
the bounding outlines for filling are given        
by the two infinitely thin paths consisting of all points whose perpendicular
distance from the path of the circle/ellipse is equal to lw/2
(which may be a fractional value).
The cap-style and join-style are applied the same as for a line
corresponding to the tangent of the circle/ellipse at the endpoint.
.LP
For an arc specified as % [ ~x, ~y, ~width, ~height, ~angle1, ~angle2  ]%,
the angles must be specified
in the effectively skewed coordinate system of the ellipse (for a
circle, the angles and coordinate systems are identical).  The
relationship between these angles and angles expressed in the normal
coordinate system of the screen (as measured with a protractor) is as
follows:
.LP
.Ds
% roman "skewed-angle" ~ = ~ atan left ( tan ( roman "normal-angle" )
 * width over height right ) +^ adjust%
.De
.LP
The skewed-angle and normal-angle are expressed in radians (rather
than in degrees scaled by 64) in the range % [ 0 , ~2 pi  ]% and where atan
returns a value in the range % [ - pi over 2 , ~pi over 2  ] %
and adjust is:
.LP
.Ds
.TA 1i 2i
.ta 1i 2i
%0%	for normal-angle in the range % [ 0 , ~pi over 2  ]%
%pi%	for normal-angle in the range % [ pi over 2 , ~{3 pi} over 2  ]%
%2 pi%	for normal-angle in the range % [ {3 pi} over 2 , ~2 pi  ]%
.De
.LP
For any given arc, 
.PN XDrawArc
and
.PN XDrawArcs
do not draw a pixel more than once.  
If two arcs join correctly and if the line-width is greater than zero 
and the arcs intersect, 
.PN XDrawArc
and
.PN XDrawArcs
do not draw a pixel more than once.
Otherwise, 
the intersecting pixels of intersecting arcs are drawn multiple times.
Specifying an arc with one endpoint and a clockwise extent draws the same pixels
as specifying the other endpoint and an equivalent counterclockwise extent,
except as it affects joins.
.LP
If the last point in one arc coincides with the first point in the following 
arc, the two arcs will join correctly.  
If the first point in the first arc coincides with the last point in the last 
arc, the two arcs will join correctly.
By specifying one axis to be zero, a horizontal or vertical line can be
drawn.
Angles are computed based solely on the coordinate system and ignore the
aspect ratio.
.LP
Both functions use these GC components: 
function, plane-mask, line-width, line-style, cap-style, join-style, 
fill-style, subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask.
They also use these GC mode-dependent components: 
foreground, background, tile, stipple, tile-stipple-x-origin, 
tile-stipple-y-origin, dash-offset, and dash-list.
.LP
.PN XDrawArc
and
.PN XDrawArcs
can generate
.PN BadDrawable ,
.PN BadGC ,
and
.PN BadMatch 
errors.
.NH 2
Filling Areas
.XS
\*(SN Filling Areas 
.XE
.LP
Xlib provides functions that you can use to fill:
.IP \(bu 5
A single rectangle or multiple rectangles
.IP \(bu 5
A single polygon
.IP \(bu 5
A single arc or multiple arcs
.NH 3
Filling Single and Multiple Rectangles
.XS
\*(SN Filling Single and Multiple Rectangles 
.XE
.LP
.IN "Filling" "rectangles"
.IN "XFillRectangle"
.IN "Rectangle" "filling"
.IN "XFillRectangles"
.LP
.sp
To fill a single rectangular area in a given drawable, use
.PN XFillRectangle .
.IN "XFillRectangle" "" "@DEF@"
.sM
.FD 0 
XFillRectangle\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIwidth\fP\^, \fIheight\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      int \fIx\fP\^, \fIy\fP\^;
.br
      unsigned int \fIwidth\fP\^, \fIheight\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.ds Xy , which are relative to the origin of the drawable \
and specify the upper-left corner of the rectangle
.IP \fIx\fP 1i
.br
.ns
.IP \fIy\fP 1i
Specify the x and y coordinates\*(Xy.
.ds Wh , which are the dimensions of the rectangle to be filled
.IP \fIwidth\fP 1i
.br
.ns
.IP \fIheight\fP 1i
Specify the width and height\*(Wh.
.LP
.eM
.sp
To fill multiple rectangular areas in a given drawable, use
.PN XFillRectangles .
.IN "XFillRectangles" "" "@DEF@"
.sM
.FD 0 
XFillRectangles\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIrectangles\fP\^, \fInrectangles\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      XRectangle *\fIrectangles\fP\^;
.br
      int \fInrectangles\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.IP \fIrectangles\fP 1i
Specifies an array of rectangles.
.IP \fInrectangles\fP 1i
Specifies the number of rectangles in the array.
.LP
.eM
The
.PN XFillRectangle
and
.PN XFillRectangles
functions fill the specified rectangle or rectangles
as if a four-point 
.PN FillPolygon
protocol request were specified for each rectangle:
.LP
.Ds
[x,y] [x+width,y] [x+width,y+height] [x,y+height]
.De
.LP
Each function uses the x and y coordinates,
width and height dimensions, and GC you specify.
.LP
.PN XFillRectangles
fills the rectangles in the order listed in the array.  
For any given rectangle,
.PN XFillRectangle
and
.PN XFillRectangles
do not draw a pixel more than once.  
If rectangles intersect, the intersecting pixels are
drawn multiple times.
.LP
Both functions use these GC components: 
function, plane-mask, fill-style, subwindow-mode, 
clip-x-origin, clip-y-origin, and clip-mask.
They also use these GC mode-dependent components: 
foreground, background, tile, stipple, tile-stipple-x-origin, 
and tile-stipple-y-origin.
.LP
.PN XFillRectangle
and
.PN XFillRectangles
can generate
.PN BadDrawable ,
.PN BadGC ,
and
.PN BadMatch 
errors.
.NH 3
Filling a Single Polygon
.XS
\*(SN Filling a Single Polygon 
.XE
.LP
.sp
To fill a polygon area in a given drawable, use
.PN XFillPolygon .
.IN "Polygons" "filling"
.IN "Filling" "polygon"
.IN "XFillPolygon" "" "@DEF@"
.sM
.FD 0 
XFillPolygon\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIpoints\fP\^, \fInpoints\fP\^, \fIshape\fP\^, \fImode\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      XPoint *\fIpoints\fP\^;
.br
      int \fInpoints\fP\^;
.br
      int \fIshape\fP\^; 
.br
      int \fImode\fP\^; 
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.IP \fIpoints\fP 1i
Specifies an array of points.
.IP \fInpoints\fP 1i
Specifies the number of points in the array.
.IP \fIshape\fP 1i
Specifies a shape that helps the server to improve performance.
You can pass 
.PN Complex , 
.PN Convex , 
or 
.PN Nonconvex .
.IP \fImode\fP 1i
Specifies the coordinate mode. 
You can pass
.PN CoordModeOrigin
or
.PN CoordModePrevious .
.LP
.eM
.PN XFillPolygon 
fills the region closed by the specified path.
The path is closed
automatically if the last point in the list does not coincide with the
first point.
.PN XFillPolygon
does not draw a pixel of the region more than once.
.PN CoordModeOrigin
treats all coordinates as relative to the origin,
and
.PN CoordModePrevious
treats all coordinates after the first as relative to the previous point.
.LP
Depending on the specified shape, the following occurs: 
.IP \(bu 5
If shape is
.PN Complex , 
the path may self-intersect. 
Note that contiguous coincident points in the path are not treated 
as self-intersection.
.IP \(bu 5
If shape is
.PN Convex , 
for every pair of points inside the polygon,
the line segment connecting them does not intersect the path.
If known by the client,
specifying 
.PN Convex 
can improve performance.  
If you specify
.PN Convex 
for a path that is not convex, 
the graphics results are undefined.
.IP \(bu 5
If shape is
.PN Nonconvex , 
the path does not self-intersect, but the shape is not
wholly convex. 
If known by the client, 
specifying 
.PN Nonconvex 
instead of
.PN Complex 
may improve performance.  
If you specify
.PN Nonconvex 
for a self-intersecting path, the graphics results are undefined.
.LP
The fill-rule of the GC controls the filling behavior of 
self-intersecting polygons.
.LP
This function uses these GC components: 
function, plane-mask, fill-style, fill-rule, subwindow-mode, clip-x-origin, 
clip-y-origin, and clip-mask.
It also uses these GC mode-dependent components: 
foreground, background, tile, stipple, tile-stipple-x-origin, 
and tile-stipple-y-origin.
.LP
.PN XFillPolygon
can generate
.PN BadDrawable ,
.PN BadGC ,
.PN BadMatch ,
and
.PN BadValue 
errors.
.NH 3
Filling Single and Multiple Arcs
.XS
\*(SN Filling Single and Multiple Arcs 
.XE
.LP
.IN "XFillArc"
.IN "Arcs" "filling"
.IN "Filling" "arcs"
To fill a single arc in a given drawable, use
.PN XFillArc .
.IN "XFillArc" "" "@DEF@"
.sM
.FD 0
XFillArc\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^,  \fIx\fP\^, \fIy\fP\^, \fIwidth\fP\^, \fIheight\fP\^, \fIangle1\fP\^, \fIangle2\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      int \fIx\fP\^, \fIy\fP\^;
.br
      unsigned int \fIwidth\fP\^, \fIheight\fP\^;
.br
      int \fIangle1\fP\^, \fIangle2\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.ds Xy , which are relative to the origin of the drawable \
and specify the upper-left corner of the bounding rectangle
.IP \fIx\fP 1i
.br
.ns
.IP \fIy\fP 1i
Specify the x and y coordinates\*(Xy.
.ds Wh , which are the major and minor axes of the arc
.IP \fIwidth\fP 1i
.br
.ns
.IP \fIheight\fP 1i
Specify the width and height\*(Wh.
.IP \fIangle1\fP 1i
Specifies the start of the arc relative to the three-o'clock position
from the center, in units of degrees * 64.
.IP \fIangle2\fP 1i
Specifies the path and extent of the arc relative to the start of the
arc, in units of degrees * 64.
.LP
.eM
.sp
To fill multiple arcs in a given drawable, use
.PN XFillArcs .
.IN "XFillArcs" "" "@DEF@"
.sM
.FD 0
XFillArcs\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIarcs\fP\^, \fInarcs\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      XArc *\fIarcs\fP\^;
.br
      int \fInarcs\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.IP \fIarcs\fP 1i
Specifies an array of arcs.
.IP \fInarcs\fP 1i
Specifies the number of arcs in the array.
.LP
.eM
For each arc, 
.PN XFillArc
or
.PN XFillArcs
fills the region closed by the infinitely thin path
described by the specified arc and, depending on the 
arc-mode specified in the GC, one or two line segments. 
For 
.PN ArcChord , 
the single line segment joining the endpoints of the arc is used.  
For 
.PN ArcPieSlice ,
the two line segments joining the endpoints of the arc with the center
point are used.  
.PN XFillArcs
fills the arcs in the order listed in the array.  
For any given arc,  
.PN XFillArc
and
.PN XFillArcs
do not draw a pixel more than once.  
If regions intersect, 
the intersecting pixels are drawn multiple times.
.LP
Both functions use these GC components: 
function, plane-mask, fill-style, arc-mode, subwindow-mode, clip-x-origin, 
clip-y-origin, and clip-mask.
They also use these GC mode-dependent components: 
foreground, background, tile, stipple, tile-stipple-x-origin, 
and tile-stipple-y-origin.
.LP
.PN XFillArc
and
.PN XFillArcs
can generate
.PN BadDrawable ,
.PN BadGC ,
and
.PN BadMatch 
errors.
.NH 2
Font Metrics
.XS
\*(SN Font Metrics 
.XE
.LP
.IN "Font"
A font is a graphical description of a set of characters that are used to 
increase efficiency whenever a set of small, similar sized patterns are 
repeatedly used.
.LP
This section discusses how to:
.IP \(bu 5
Load and free fonts
.IP \(bu 5
Obtain and free font names
.IP \(bu 5
Compute character string sizes
.IP \(bu 5
Compute logical extents
.IP \(bu 5
Query character string sizes
.LP
The X server loads fonts whenever a program requests a new font.
The server can cache fonts for quick lookup.
Fonts are global across all screens in a server.
Several levels are possible when dealing with fonts.
Most applications simply use 
.PN XLoadQueryFont
to load a font and query the font metrics.
.LP
Characters in fonts are regarded as masks.
Except for image text requests,
the only pixels modified are those in which bits are set to 1 in the character.
This means that it makes sense to draw text using stipples or tiles
(for example, many menus gray-out unusable entries).
.LP
.sM
The
.PN XFontStruct
structure contains all of the information for the font
and consists of the font-specific information as well as
a pointer to an array of
.PN XCharStruct
structures for the
characters contained in the font.
The
.PN XFontStruct ,
.PN XFontProp ,
and
.PN XCharStruct
structures contain:
.LP
.IN "XCharStruct" "" "@DEF@"
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	short lbearing;	/* origin to left edge of raster */
	short rbearing;	/* origin to right edge of raster */
	short width;	/* advance to next char's origin */
	short ascent;	/* baseline to top edge of raster */
	short descent;	/* baseline to bottom edge of raster */
	unsigned short attributes;	/* per char flags (not predefined) */
} XCharStruct;
.De
.LP
.IN "XFontProp" "" "@DEF@"
.Ds 0
.TA .5i 1i 3i
.ta .5i 1i 3i
typedef struct {
	Atom	name;
	unsigned long card32;
} XFontProp;
.De
.LP
.IN "XChar2b" "" "@DEF@"
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {	/* normal 16 bit characters are two bytes */
    unsigned char byte1;
    unsigned char byte2;
} XChar2b;
.De
.LP
.IN "XFontStruct" "" "@DEF@"
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	XExtData *ext_data;	/* hook for extension to hang data */
	Font fid;	/* Font id for this font */
	unsigned direction;	/* hint about the direction font is painted */
	unsigned min_char_or_byte2;	/* first character */
	unsigned max_char_or_byte2;	/* last character */
	unsigned min_byte1;	/* first row that exists */
	unsigned max_byte1;	/* last row that exists */
	Bool all_chars_exist;	/* flag if all characters have nonzero size */
	unsigned default_char;	/* char to print for undefined character */
	int n_properties;	/* how many properties there are */
	XFontProp *properties;	/* pointer to array of additional properties */
	XCharStruct min_bounds;	/* minimum bounds over all existing char */
	XCharStruct max_bounds;	/* maximum bounds over all existing char */
	XCharStruct *per_char;	/* first_char to last_char information */
	int ascent;	/* logical extent above baseline for spacing */
	int descent;	/* logical descent below baseline for spacing */
} XFontStruct;
.De
.LP
.eM
X supports single byte/character, two bytes/character matrix,
and 16-bit character text operations.
Note that any of these forms can be used with a font, but a
single byte/character text request can only specify a single byte
(that is, the first row of a 2-byte font).
You should view 2-byte fonts as a two-dimensional matrix of defined
characters: byte1 specifies the range of defined rows and
byte2 defines the range of defined columns of the font.
Single byte/character fonts have one row defined, and the byte2 range
specified in the structure defines a range of characters.
.LP
The bounding box of a character is defined by the 
.PN XCharStruct 
of that character.
When characters are absent from a font,
the default_char is used.
When fonts have all characters of the same size,
only the information in the
.PN XFontStruct
min and max bounds are used.
.LP
The members of the 
.PN XFontStruct 
have the following semantics:
.IP \(bu 5
The direction member can be either 
.PN FontLeftToRight 
or 
.PN FontRightToLeft . 
It is just a hint as to whether most 
.PN XCharStruct 
elements 
have a positive 
.Pn ( FontLeftToRight ) 
or a negative 
.Pn ( FontRightToLeft )
character width 
metric.
The core protocol defines no support for vertical text.
.IP \(bu 5
If the min_byte1 and max_byte1 members are both zero, min_char_or_byte2
specifies the linear character index corresponding to the first element
of the per_char array, and max_char_or_byte2 specifies the linear character
index of the last element.
.IP
If either min_byte1 or max_byte1 are nonzero, both
min_char_or_byte2 and max_char_or_byte2 are less than 256, 
and the 2-byte character index values corresponding to the
per_char array element N (counting from 0) are:
.IP
.nf
	byte1 = N/D + min_byte1
.br
	byte2 = N\\D + min_char_or_byte2
.IP
.fi
where:
.IP
.nf
        D = max_char_or_byte2 \- min_char_or_byte2 + 1
        / = integer division
        \\ = integer modulus
.fi
.IP \(bu 5
If the per_char pointer is NULL, 
all glyphs between the first and last character indexes
inclusive have the same information,
as given by both min_bounds and max_bounds.
.IP \(bu 5
If all_chars_exist is 
.PN True ,
all characters in the per_char array have nonzero bounding boxes.
.IP \(bu 5
The default_char member specifies the character that will be used when an
undefined or nonexistent character is printed.  
The default_char is a 16-bit character (not a 2-byte character).
For a font using 2-byte matrix format, 
the default_char has byte1 in the most-significant byte
and byte2 in the least significant byte.
If the default_char itself specifies an undefined or nonexistent character, 
no printing is performed for an undefined or nonexistent character.
.IP \(bu 5
The min_bounds and max_bounds members contain the most extreme values of
each individual 
.PN XCharStruct 
component over all elements of this array
(and ignore nonexistent characters).
The bounding box of the font (the smallest
rectangle enclosing the shape obtained by superimposing all of the
characters at the same origin [x,y]) has its upper-left coordinate at:
.Ds
	[x + min_bounds.lbearing, y \- max_bounds.ascent]
.De
.IP
Its width is:
.Ds
	max_bounds.rbearing \- min_bounds.lbearing
.De
.IP
Its height is:
.Ds
	max_bounds.ascent + max_bounds.descent
.De
.IP \(bu 5
The ascent member is the logical extent of the font above the baseline that is
used for determining line spacing.
Specific characters may extend beyond
this.
.IP \(bu 5
The descent member is the logical extent of the font at or below the
baseline that is used for determining line spacing.
Specific characters may extend beyond this.
.IP \(bu 5
If the baseline is at Y-coordinate y,
the logical extent of the font is inclusive between the Y-coordinate 
values (y \- font.ascent) and (y + font.descent \- 1).
Typically,
the minimum interline spacing between rows of text is given
by ascent + descent.
.LP
For a character origin at [x,y],
the bounding box of a character (that is, 
the smallest rectangle that encloses the character's shape)
described in terms of 
.PN XCharStruct 
components is a rectangle with its upper-left corner at:
.LP
.Ds
[x + lbearing, y \- ascent]
.De
.LP
Its width is:
.LP
.Ds
rbearing \- lbearing
.De
.LP
Its height is:
.LP
.Ds
ascent + descent
.De
.LP
The origin for the next character is defined to be:
.LP
.Ds
[x + width, y]
.De
.LP
The lbearing member defines the extent of the left edge of the character ink
from the origin.
The rbearing member defines the extent of the right edge of the character ink
from the origin.
The ascent member defines the extent of the top edge of the character ink
from the origin.
The descent member defines the extent of the bottom edge of the character ink
from the origin.
The width member defines the logical width of the character.
.LP
Note that the baseline (the y position of the character origin) 
is logically viewed as being the scanline just below nondescending characters. 
When descent is zero,
only pixels with Y-coordinates less than y are drawn,
and the origin is logically viewed as being coincident with the left edge of
a nonkerned character. 
When lbearing is zero,
no pixels with X-coordinate less than x are drawn.
Any of the
.PN XCharStruct
metric members could be negative.
If the width is negative,
the next character will be placed to the left of the current origin.
.LP
The X protocol does not define the interpretation of the attributes member 
in the
.PN XCharStruct
structure.
A nonexistent character is represented with all members of its
.PN XCharStruct
set to zero.
.LP
A font is not guaranteed to have any properties.
The interpretation of the property value (for example, long or unsigned long)
must be derived from \fIa priori\fP knowledge of the property. 
A basic set of font properties is specified in the X Consortium standard
\fIX Logical Font Description Conventions\fP.
.NH 3
Loading and Freeing Fonts
.XS
\*(SN Loading and Freeing Fonts 
.XE
.LP
Xlib provides functions that you can use to load fonts, get font information,
unload fonts, and free font information.
.IN "Fonts" "getting information"
.IN "Fonts" "unloading"
.IN "Fonts" "freeing font information"
A few font functions use a 
.PN GContext 
resource ID or a font ID interchangeably.
.LP
.sp
To load a given font, use
.PN XLoadFont .
.IN "XLoadFont" "" "@DEF@"
.sM
.FD 0
Font XLoadFont\^(\^\fIdisplay\fP, \fIname\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      char *\fIname\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fIname\fP 1i
Specifies the name of the font,
which is a null-terminated string.
.LP
.eM
The
.PN XLoadFont
function loads the specified font and returns its associated font ID.
If the font name is not in the Host Portable Character Encoding,
the result is implementation-dependent.
Use of uppercase or lowercase does not matter.
When the characters ``?'' and ``*'' are used in a font name, a
pattern match is performed and any matching font is used.
In the pattern, 
the ``?'' character will match any single character, 
and the ``*'' character will match any number of characters.
A structured format for font names is specified in the X Consortium standard 
\fIX Logical Font Description Conventions\fP.
If 
.PN XLoadFont
was unsuccessful at loading the specified font, 
a 
.PN BadName 
error results.
Fonts are not associated with a particular screen 
and can be stored as a component
of any GC.
When the font is no longer needed, call 
.PN XUnloadFont .
.LP
.PN XLoadFont
can generate
.PN BadAlloc
and
.PN BadName 
errors.
.LP
.sp
To return information about an available font, use
.PN XQueryFont .
.IN "XQueryFont" "" "@DEF@"
.sM
.FD 0
XFontStruct *XQueryFont\^(\^\fIdisplay\fP, \fIfont_ID\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      XID \fIfont_ID\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fIfont_ID\fP 1i
Specifies the font ID or the 
.PN GContext
ID.
.LP
.eM
The
.PN XQueryFont
function returns a pointer to the
.PN XFontStruct
structure, which contains information associated with the font.
You can query a font or the font stored in a GC.
The font ID stored in the 
.PN XFontStruct
structure will be the 
.PN GContext 
ID, and you need to be careful when using this ID in other functions
(see
.PN XGContextFromGC ).
If the font does not exist,
.PN XQueryFont
returns NULL.
To free this data, use
.PN XFreeFontInfo .
.LP
.sp
To perform a
.PN XLoadFont
and
.PN XQueryFont
in a single operation, use
.PN XLoadQueryFont .
.IN "XLoadQueryFont" "" "@DEF@"
.sM
.FD 0
XFontStruct *XLoadQueryFont\^(\^\fIdisplay\fP, \fIname\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      char *\fIname\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fIname\fP 1i
Specifies the name of the font,
which is a null-terminated string.
.LP
.eM
The
.PN XLoadQueryFont
function provides the most common way for accessing a font.
.PN XLoadQueryFont
both opens (loads) the specified font and returns a pointer to the
appropriate
.PN XFontStruct
structure.
If the font name is not in the Host Portable Character Encoding,
the result is implementation-dependent.
If the font does not exist,
.PN XLoadQueryFont
returns NULL.
.LP
.PN XLoadQueryFont
can generate a
.PN BadAlloc 
error.
.LP
.sp
To unload the font and free the storage used by the font structure
that was allocated by
.PN XQueryFont
or
.PN XLoadQueryFont ,
use
.PN XFreeFont .
.IN "XFreeFont" "" "@DEF@"
.sM
.FD 0
XFreeFont\^(\^\fIdisplay\fP, \fIfont_struct\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      XFontStruct *\fIfont_struct\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fIfont_struct\fP 1i
Specifies the storage associated with the font.
.LP
.eM 
The
.PN XFreeFont
function deletes the association between the font resource ID and the specified 
font and frees the
.PN XFontStruct
structure.
The font itself will be freed when no other resource references it.
The data and the font should not be referenced again.
.LP
.PN XFreeFont
can generate a
.PN BadFont 
error.
.LP
.sp
To return a given font property, use
.PN XGetFontProperty .
.IN "XGetFontProperty" "" "@DEF@"
.sM
.FD 0
Bool XGetFontProperty\^(\^\fIfont_struct\fP\^, \^\fIatom\fP\^, \^\fIvalue_return\fP\^)
.br
      XFontStruct *\fIfont_struct\fP\^;
.br
      Atom \fIatom\fP\^;
.br
      unsigned long *\fIvalue_return\fP\^;
.FN
.IP \fIfont_struct\fP 1i
Specifies the storage associated with the font.
.IP \fIatom\fP 1i
Specifies the atom for the property name you want returned.
.IP \fIvalue_return\fP 1i
Returns the value of the font property.
.LP
.eM
Given the atom for that property,
the
.PN XGetFontProperty
function returns the value of the specified font property. 
.PN XGetFontProperty
also returns 
.PN False
if the property was not defined or 
.PN True
if it was defined.
A set of predefined atoms exists for font properties,
which can be found in
.hN X11/Xatom.h .
This set contains the standard properties associated with
a font.
Although it is not guaranteed,
it is likely that the predefined font properties will be present.
.LP
.sp
To unload a font that was loaded by
.PN XLoadFont , 
use
.PN XUnloadFont .
.IN "XUnloadFont" "" "@DEF@"
.sM
.FD 0
XUnloadFont\^(\^\fIdisplay\fP, \fIfont\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Font \fIfont\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fIfont\fP 1i
Specifies the font.
.LP
.eM
The
.PN XUnloadFont
function deletes the association between the font resource ID and the specified font.
The font itself will be freed when no other resource references it.
The font should not be referenced again.
.LP
.PN XUnloadFont
can generate a
.PN BadFont 
error.
.NH 3
Obtaining and Freeing Font Names and Information
.XS
\*(SN Obtaining and Freeing Font Names and Information
.XE
.LP
You obtain font names and information by matching a wildcard specification
when querying a font type for a list of available sizes and so on.
.LP
.sp
To return a list of the available font names, use
.PN XListFonts .
.IN "XListFonts" "" "@DEF@"
.sM
.FD 0
char **XListFonts\^(\^\fIdisplay\fP, \fIpattern\fP\^, \fImaxnames\fP, \fIactual_count_return\fP\^)
.br
      Display *\^\fIdisplay\fP\^;
.br
      char *\^\fIpattern\fP\^;
.br
      int \fImaxnames\fP\^;
.br
      int *\^\fIactual_count_return\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fIpattern\fP 1i
Specifies the null-terminated pattern string that can contain wildcard 
characters.
.IP \fImaxnames\fP 1i
Specifies the maximum number of names to be returned.
.IP \fIactual_count_return\fP 1i
Returns the actual number of font names.
.LP
.eM
The
.PN XListFonts
function returns an array of available font names 
(as controlled by the font search path; see
.PN XSetFontPath )
that match the string you passed to the pattern argument.
The pattern string can contain any characters,
but each asterisk (*) is a wildcard for any number of characters,
and each question mark (?) is a wildcard for a single character.
If the pattern string is not in the Host Portable Character Encoding,
the result is implementation-dependent.
Use of uppercase or lowercase does not matter.
Each returned string is null-terminated.
If the data returned by the server is in the Latin Portable Character Encoding,
then the returned strings are in the Host Portable Character Encoding.
Otherwise, the result is implementation-dependent.
If there are no matching font names,
.PN XListFonts
returns NULL.
The client should call
.PN XFreeFontNames
when finished with the result to free the memory.
.LP
.sp
To free a font name array, use
.PN XFreeFontNames .
.IN "XFreeFontNames" "" "@DEF@"
.sM
.FD 0
XFreeFontNames\^(\^\fIlist\fP\^)
.br
      char *\fIlist\fP\^[\^]\^;
.FN
.IP \fIlist\fP 1i
Specifies the array of strings you want to free.
.LP
.eM
The
.PN XFreeFontNames
function frees the array and strings returned by
.PN XListFonts 
or
.PN XListFontsWithInfo .
.LP
.sp
To obtain the names and information about available fonts, use
.PN XListFontsWithInfo .
.IN "XListFontsWithInfo" "" "@DEF@"
.sM
.FD 0
char **XListFontsWithInfo\^(\^\fIdisplay\fP, \fIpattern\fP, \fImaxnames\fP, \fIcount_return\fP, \fIinfo_return\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      char *\fIpattern\fP\^;
.br
      int \fImaxnames\fP\^;
.br
      int *\fIcount_return\fP\^;
.br
      XFontStruct **\fIinfo_return\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fIpattern\fP 1i
Specifies the null-terminated pattern string that can contain wildcard 
characters.
.IP \fImaxnames\fP 1i
Specifies the maximum number of names to be returned.
.IP \fIcount_return\fP 1i
Returns the actual number of matched font names.
.IP \fIinfo_return\fP 1i
Returns the font information.
.LP
.eM
The
.PN XListFontsWithInfo
function returns a list of font names that match the specified pattern and their
associated font information.
The list of names is limited to size specified by maxnames.
The information returned for each font is identical to what
.PN XLoadQueryFont
would return except that the per-character metrics are not returned.
The pattern string can contain any characters,
but each asterisk (*) is a wildcard for any number of characters,
and each question mark (?) is a wildcard for a single character.
If the pattern string is not in the Host Portable Character Encoding,
the result is implementation-dependent.
Use of uppercase or lowercase does not matter.
Each returned string is null-terminated.
If the data returned by the server is in the Latin Portable Character Encoding,
then the returned strings are in the Host Portable Character Encoding.
Otherwise, the result is implementation-dependent.
If there are no matching font names,
.PN XListFontsWithInfo
returns NULL.
.LP
To free only the allocated name array,
the client should call
.PN XFreeFontNames .
To free both the name array and the font information array
or to free just the font information array,
the client should call
.PN XFreeFontInfo .
.LP
.sp
To free font structures and font names, use
.PN XFreeFontInfo .
.IN "XFreeFontInfo" "" "@DEF@"
.sM
.FD 0
XFreeFontInfo(\^\fInames\fP, \fIfree_info\fP, \fIactual_count\fP\^)
.br
      char **\fInames\fP\^;
.br
      XFontStruct *\fIfree_info\fP;
.br
      int \fIactual_count\fP\^;
.FN
.IP \fInames\fP 1i
Specifies the list of font names.

.IP \fIfree_info\fP 1i
Specifies the font information.

.IP \fIactual_count\fP 1i
Specifies the actual number of font names.

.LP
.eM
The
.PN XFreeFontInfo
function frees a font structure or an array of font structures
and optionally an array of font names.
If NULL is passed for names, no font names are freed.
If a font structure for an open font (returned by
.PN XLoadQueryFont )
is passed, the structure is freed,
but the font is not closed; use
.PN XUnloadFont
to close the font.
.NH 3
Computing Character String Sizes
.XS
\*(SN Computing Character String Sizes 
.XE
.LP
Xlib provides functions that you can use to compute the width,
the logical extents, 
and the server information about 8-bit and 2-byte text strings.
.IN "XTextWidth"
.IN "XTextWidth16"
The width is computed by adding the character widths of all the characters.
It does not matter if the font is an 8-bit or 2-byte font.
These functions return the sum of the character metrics in pixels.
.LP
.sp
To determine the width of an 8-bit character string, use
.PN XTextWidth .
.IN "XTextWidth" "" "@DEF@"
.sM
.FD 0
int XTextWidth\^(\^\fIfont_struct\fP\^, \fIstring\fP, \fIcount\fP\^)
.br
      XFontStruct *\fIfont_struct\fP\^;
.br
      char *\fIstring\fP\^;
.br
      int \fIcount\fP\^;
.FN
.IP \fIfont_struct\fP 1i
Specifies the font used for the width computation.
.IP \fIstring\fP 1i
Specifies the character string.
.IP \fIcount\fP 1i
Specifies the character count in the specified string.
.LP
.eM
.sp
To determine the width of a 2-byte character string, use
.PN XTextWidth16 .
.IN "XTextWidth16" "" "@DEF@"
.sM
.FD 0
int XTextWidth16\^(\^\fIfont_struct\fP\^, \fIstring\fP, \fIcount\fP\^)
.br
      XFontStruct *\fIfont_struct\fP\^;
.br
      XChar2b *\fIstring\fP\^;
.br
      int \fIcount\fP\^;
.FN
.IP \fIfont_struct\fP 1i
Specifies the font used for the width computation.
.IP \fIstring\fP 1i
Specifies the character string.
.IP \fIcount\fP 1i
Specifies the character count in the specified string.
.LP
.eM
.NH 3
Computing Logical Extents
.XS
\*(SN Computing Logical Extents 
.XE
.LP
To compute the bounding box of an 8-bit character string in a given font, use
.PN XTextExtents .
.IN "XTextExtents" "" "@DEF@"
.sM
.FD 0
XTextExtents\^(\^\fIfont_struct\fP\^, \fIstring\fP\^, \fInchars\fP\^, \
\fIdirection_return\fP, \fIfont_ascent_return\fP,
.br
              \fIfont_descent_return\fP, \fIoverall_return\fP\^)
.br
      XFontStruct *\fIfont_struct\fP\^;
.br
      char *\fIstring\fP\^;
.br
      int \fInchars\fP\^;
.br
      int *\fIdirection_return\fP\^;
.br
      int *\fIfont_ascent_return\fP, *\fIfont_descent_return\fP\^;
.br
      XCharStruct *\fIoverall_return\fP\^;

.FN
.IP \fIfont_struct\fP 1i
Specifies the 
.PN XFontStruct 
structure.
.IP \fIstring\fP 1i
Specifies the character string.
.IP \fInchars\fP 1i
Specifies the number of characters in the character string.
.IP \fIdirection_return\fP 1i
Returns the value of the direction hint
.Pn ( FontLeftToRight
or
.PN FontRightToLeft ).
.IP \fIfont_ascent_return\fP 1i
Returns the font ascent.
.IP \fIfont_descent_return\fP 1i
Returns the font descent.
.IP \fIoverall_return\fP 1i
Returns the overall size in the specified
.PN XCharStruct 
structure.
.LP
.eM
.sp
To compute the bounding box of a 2-byte character string in a given font, use
.PN XTextExtents16 .
.IN "XTextExtents16" "" "@DEF@"
.sM
.FD 0
XTextExtents16\^(\^\fIfont_struct\fP\^, \fIstring\fP\^, \fInchars\fP\^, \
\fIdirection_return\fP, \fIfont_ascent_return\fP, 
.br
                \fIfont_descent_return\fP, \fIoverall_return\fP\^)
.br
      XFontStruct *\fIfont_struct\fP\^;
.br
      XChar2b *\fIstring\fP\^;
.br
      int \fInchars\fP\^;
.br
      int *\fIdirection_return\fP\^;
.br
      int *\fIfont_ascent_return\fP, *\fIfont_descent_return\fP\^;
.br
      XCharStruct *\fIoverall_return\fP\^;

.FN
.IP \fIfont_struct\fP 1i
Specifies the 
.PN XFontStruct 
structure.
.IP \fIstring\fP 1i
Specifies the character string.
.IP \fInchars\fP 1i
Specifies the number of characters in the character string.
.IP \fIdirection_return\fP 1i
Returns the value of the direction hint
.Pn ( FontLeftToRight
or
.PN FontRightToLeft ).
.IP \fIfont_ascent_return\fP 1i
Returns the font ascent.
.IP \fIfont_descent_return\fP 1i
Returns the font descent.
.IP \fIoverall_return\fP 1i
Returns the overall size in the specified
.PN XCharStruct 
structure.
.LP
.eM
The
.PN XTextExtents
and
.PN XTextExtents16
functions 
perform the size computation locally and, thereby,
avoid the round-trip overhead of
.PN XQueryTextExtents 
and
.PN XQueryTextExtents16 .
Both functions return an
.PN XCharStruct
structure, whose members are set to the values as follows.
.LP
The ascent member is set to the maximum of the ascent metrics of all
characters in the string.
The descent member is set to the maximum of the descent metrics.
The width member is set to the sum of the character-width metrics of all
characters in the string.
For each character in the string,
let W be the sum of the character-width metrics of all characters preceding 
it in the string.
Let L be the left-side-bearing metric of the character plus W.
Let R be the right-side-bearing metric of the character plus W.
The lbearing member is set to the minimum L of all characters in the string.
The rbearing member is set to the maximum R.
.LP
For fonts defined with linear indexing rather than 2-byte matrix indexing,
each 
.PN XChar2b 
structure is interpreted as a 16-bit number with byte1 as the 
most significant byte.
If the font has no defined default character,
undefined characters in the string are taken to have all zero metrics.
.NH 3
Querying Character String Sizes
.XS
\*(SN Querying Character String Sizes 
.XE
.LP
To query the server for the bounding box of an 8-bit character string in a 
given font, use 
.PN XQueryTextExtents .
.IN "XQueryTextExtents" "" "@DEF@"
.sM
.FD 0
XQueryTextExtents\^(\^\fIdisplay\fP, \fIfont_ID\fP, \fIstring\fP, \
\fInchars\fP, \fIdirection_return\fP, \fIfont_ascent_return\fP, 
.br
                    \fIfont_descent_return\fP, \fIoverall_return\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      XID \fIfont_ID\fP\^;
.br
      char *\fIstring\fP\^;
.br
      int \fInchars\fP\^;
.br
      int *\fIdirection_return\fP\^;
.br
      int *\fIfont_ascent_return\fP, *\fIfont_descent_return\fP\^;
.br
      XCharStruct *\fIoverall_return\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fIfont_ID\fP 1i
Specifies either the font ID or the 
.PN GContext
ID that contains the font.
.IP \fIstring\fP 1i
Specifies the character string.
.IP \fInchars\fP 1i
Specifies the number of characters in the character string.
.IP \fIdirection_return\fP 1i
Returns the value of the direction hint
.Pn ( FontLeftToRight
or
.PN FontRightToLeft ).
.IP \fIfont_ascent_return\fP 1i
Returns the font ascent.
.IP \fIfont_descent_return\fP 1i
Returns the font descent.
.IP \fIoverall_return\fP 1i
Returns the overall size in the specified
.PN XCharStruct 
structure.
.LP
.eM
.sp
To query the server for the bounding box of a 2-byte character string
in a given font, use
.PN XQueryTextExtents16 .
.IN "XQueryTextExtents16" "" "@DEF@"
.sM
.FD 0
XQueryTextExtents16\^(\^\fIdisplay\fP, \fIfont_ID\fP, \fIstring\fP, \
\fInchars\fP, \fIdirection_return\fP, \fIfont_ascent_return\fP, 
.br
                        \fIfont_descent_return\fP, \fIoverall_return\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      XID \fIfont_ID\fP\^;
.br
      XChar2b *\fIstring\fP\^;
.br
      int \fInchars\fP\^;
.br
      int *\fIdirection_return\fP\^;
.br
      int *\fIfont_ascent_return\fP, *\fIfont_descent_return\fP\^;
.br
      XCharStruct *\fIoverall_return\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fIfont_ID\fP 1i
Specifies either the font ID or the 
.PN GContext
ID that contains the font.
.IP \fIstring\fP 1i
Specifies the character string.
.IP \fInchars\fP 1i
Specifies the number of characters in the character string.
.IP \fIdirection_return\fP 1i
Returns the value of the direction hint
.Pn ( FontLeftToRight
or
.PN FontRightToLeft ).
.IP \fIfont_ascent_return\fP 1i
Returns the font ascent.
.IP \fIfont_descent_return\fP 1i
Returns the font descent.
.IP \fIoverall_return\fP 1i
Returns the overall size in the specified
.PN XCharStruct 
structure.
.LP
.eM
The
.PN XQueryTextExtents
and
.PN XQueryTextExtents16
functions return the bounding box of the specified 8-bit and 16-bit
character string in the specified font or the font contained in the
specified GC.
These functions query the X server and, therefore, suffer the round-trip
overhead that is avoided by
.PN XTextExtents
and 
.PN XTextExtents16 .
Both functions return a
.PN XCharStruct 
structure, whose members are set to the values as follows.
.LP
The ascent member is set to the maximum of the ascent metrics 
of all characters in the string.
The descent member is set to the maximum of the descent metrics.
The width member is set to the sum of the character-width metrics 
of all characters in the string.
For each character in the string,
let W be the sum of the character-width metrics of all characters preceding
it in the string.
Let L be the left-side-bearing metric of the character plus W.
Let R be the right-side-bearing metric of the character plus W.
The lbearing member is set to the minimum L of all characters in the string.
The rbearing member is set to the maximum R.
.LP
For fonts defined with linear indexing rather than 2-byte matrix indexing,
each 
.PN XChar2b 
structure is interpreted as a 16-bit number with byte1 as the 
most significant byte.
If the font has no defined default character,
undefined characters in the string are taken to have all zero metrics.
.LP
Characters with all zero metrics are ignored.
If the font has no defined default_char,
the undefined characters in the string are also ignored.
.LP
.PN XQueryTextExtents
and
.PN XQueryTextExtents16
can generate
.PN BadFont
and
.PN BadGC 
errors.
.NH 2
Drawing Text
.XS
\*(SN Drawing Text
.XE
.LP
This section discusses how to draw:
.IP \(bu 5
Complex text 
.IP \(bu 5
Text characters
.IP \(bu 5
Image text characters
.LP
The fundamental text functions
.PN XDrawText
and
.PN XDrawText16
use the following structures:
.LP
.IN "XTextItem" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	char *chars;	/* pointer to string */
	int nchars;	/* number of characters */
	int delta;	/* delta between strings */
	Font font;	/* Font to print it in, None don't change */
} XTextItem;
.De
.LP
.IN "XTextItem16" "" "@DEF@"
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	XChar2b *chars;	/* pointer to two-byte characters */
	int nchars;	/* number of characters */
	int delta;	/* delta between strings */
	Font font;	/* font to print it in, None don't change */
} XTextItem16;
.De
.LP
.eM
If the font member is not
.PN None ,
the font is changed before printing and also is stored in the GC.
If an error was generated during text drawing,
the previous items may have been drawn.
The baseline of the characters are drawn starting at the x and y
coordinates that you pass in the text drawing functions.
.LP
For example, consider the background rectangle drawn by
.PN XDrawImageString .
If you want the upper-left corner of the background rectangle
to be at pixel coordinate (x,y), pass the (x,y + ascent)
as the baseline origin coordinates to the text functions.
The ascent is the font ascent, as given in the
.PN XFontStruct
structure.
If you want the lower-left corner of the background rectangle
to be at pixel coordinate (x,y), pass the (x,y \- descent + 1)
as the baseline origin coordinates to the text functions.
The descent is the font descent, as given in the
.PN XFontStruct
structure.
.NH 3
Drawing Complex Text
.XS
\*(SN Drawing Complex Text 
.XE
.LP
.IN "Text" "drawing"
.IN "Drawing" "text items"
.LP
To draw 8-bit characters in a given drawable, use
.PN XDrawText .
.IN "XDrawText" "" "@DEF@"
.sM
.FD 0
XDrawText\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIitems\fP\^, \fInitems\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      int \fIx\fP\^, \fIy\fP\^;
.br
      XTextItem *\fIitems\fP\^;
.br
      int \fInitems\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.ds Xy , which are relative to the origin of the specified drawable \
and define the origin of the first character
.IP \fIx\fP 1i
.br
.ns
.IP \fIy\fP 1i
Specify the x and y coordinates\*(Xy.
.IP \fIitems\fP 1i
Specifies an array of text items.
.IP \fInitems\fP 1i
Specifies the number of text items in the array.
.LP
.eM
.sp
To draw 2-byte characters in a given drawable, use
.PN XDrawText16 .
.IN "XDrawText16" "" "@DEF@"
.sM
.FD 0
XDrawText16\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIitems\fP\^, \fInitems\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      int \fIx\fP\^, \fIy\fP\^;
.br
      XTextItem16 *\fIitems\fP\^;
.br
      int \fInitems\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.ds Xy , which are relative to the origin of the specified drawable \
and define the origin of the first character
.IP \fIx\fP 1i
.br
.ns
.IP \fIy\fP 1i
Specify the x and y coordinates\*(Xy.
.IP \fIitems\fP 1i
Specifies an array of text items.
.IP \fInitems\fP 1i
Specifies the number of text items in the array.
.LP
.eM
The
.PN XDrawText16
function is similar to
.PN XDrawText 
except that it uses 2-byte or 16-bit characters.
Both functions allow complex spacing and font shifts between counted strings.
.LP
Each text item is processed in turn.
A font member other than 
.PN None
in an item causes the font to be stored in the GC
and used for subsequent text.  
A text element delta specifies an additional change
in the position along the x axis before the string is drawn. 
The delta is always added to the character origin
and is not dependent on any characteristics of the font.
Each character image, as defined by the font in the GC, is treated as an
additional mask for a fill operation on the drawable.
The drawable is modified only where the font character has a bit set to 1.
If a text item generates a
.PN BadFont
error, the previous text items may have been drawn.
.LP
For fonts defined with linear indexing rather than 2-byte matrix indexing,
each 
.PN XChar2b
structure is interpreted as a 16-bit number with byte1 as the 
most significant byte.
.LP
Both functions use these GC components:
function, plane-mask, fill-style, font, subwindow-mode, 
clip-x-origin, clip-y-origin, and clip-mask.
They also use these GC mode-dependent components: 
foreground, background, tile, stipple, tile-stipple-x-origin, 
and tile-stipple-y-origin.
.LP
.PN XDrawText
and
.PN XDrawText16
can generate
.PN BadDrawable ,
.PN BadFont ,
.PN BadGC ,
and
.PN BadMatch 
errors.
.NH 3
Drawing Text Characters
.XS
\*(SN Drawing Text Characters 
.XE
.LP
.IN "Strings" "drawing"
.IN "Drawing" "strings"
To draw 8-bit characters in a given drawable, use
.PN XDrawString .
.IN "XDrawString" "" "@DEF@"
.sM
.FD 0
XDrawString\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIstring\fP\^, \fIlength\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      int \fIx\fP\^, \fIy\fP\^;
.br
      char *\fIstring\fP\^;
.br
      int \fIlength\fP\^; 
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.ds Xy , which are relative to the origin of the specified drawable \
and define the origin of the first character
.IP \fIx\fP 1i
.br
.ns
.IP \fIy\fP 1i
Specify the x and y coordinates\*(Xy.
.IP \fIstring\fP 1i
Specifies the character string.
.IP \fIlength\fP 1i
Specifies the number of characters in the string argument.
.LP
.eM
.sp
To draw 2-byte characters in a given drawable, use
.PN XDrawString16 .
.IN "XDrawString16" "" "@DEF@"
.sM
.FD 0
XDrawString16\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIstring\fP\^, \fIlength\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      int \fIx\fP\^, \fIy\fP\^;
.br
      XChar2b *\fIstring\fP\^;
.br
      int \fIlength\fP\^; 
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.ds Xy , which are relative to the origin of the specified drawable \
and define the origin of the first character
.IP \fIx\fP 1i
.br
.ns
.IP \fIy\fP 1i
Specify the x and y coordinates\*(Xy.
.IP \fIstring\fP 1i
Specifies the character string.
.IP \fIlength\fP 1i
Specifies the number of characters in the string argument.
.LP
.eM
Each character image, as defined by the font in the GC, is treated as an
additional mask for a fill operation on the drawable.
The drawable is modified only where the font character has a bit set to 1.
For fonts defined with 2-byte matrix indexing
and used with
.PN XDrawString16 ,
each byte is used as a byte2 with a byte1 of zero.
.LP
Both functions use these GC components: 
function, plane-mask, fill-style, font, subwindow-mode, clip-x-origin, 
clip-y-origin, and clip-mask.
They also use these GC mode-dependent components: 
foreground, background, tile, stipple, tile-stipple-x-origin, 
and tile-stipple-y-origin.
.LP
.PN XDrawString
and
.PN XDrawString16
can generate
.PN BadDrawable ,
.PN BadGC ,
and
.PN BadMatch 
errors.
.NH 3
Drawing Image Text Characters
.XS
\*(SN Drawing Image Text Characters 
.XE
.LP
.IN "Image text" "drawing"
.IN "Drawing" "image text"
Some applications, in particular terminal emulators, need to
print image text in which both the foreground and background bits of
each character are painted.
This prevents annoying flicker on many displays.
.IN "XDrawImageString"
.IN "XDrawImageString16"
.LP
.sp
To draw 8-bit image text characters in a given drawable, use
.PN XDrawImageString .
.IN "XDrawImageString" "" "@DEF@"
.sM
.FD 0
XDrawImageString\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIstring\fP\^, \fIlength\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      int \fIx\fP\^, \fIy\fP\^;
.br
      char *\fIstring\fP\^;
.br
      int \fIlength\fP\^; 
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.ds Xy , which are relative to the origin of the specified drawable \
and define the origin of the first character
.IP \fIx\fP 1i
.br
.ns
.IP \fIy\fP 1i
Specify the x and y coordinates\*(Xy.
.IP \fIstring\fP 1i
Specifies the character string.
.IP \fIlength\fP 1i
Specifies the number of characters in the string argument.
.LP
.eM
.sp
To draw 2-byte image text characters in a given drawable, use
.PN XDrawImageString16 .
.IN "XDrawImageString16" "" "@DEF@"
.sM
.FD 0
XDrawImageString16\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIstring\fP\^, \fIlength\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      GC \fIgc\fP\^;
.br
      int \fIx\fP\^, \fIy\fP\^;
.br
      XChar2b *\fIstring\fP\^;
.br
      int \fIlength\fP\^; 
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.ds Xy , which are relative to the origin of the specified drawable \
and define the origin of the first character
.IP \fIx\fP 1i
.br
.ns
.IP \fIy\fP 1i
Specify the x and y coordinates\*(Xy.
.IP \fIstring\fP 1i
Specifies the character string.
.IP \fIlength\fP 1i
Specifies the number of characters in the string argument.
.LP
.eM
The
.PN XDrawImageString16
function is similar to
.PN XDrawImageString 
except that it uses 2-byte or 16-bit characters.
Both functions also use both the foreground and background pixels 
of the GC in the destination.
.LP
The effect is first to fill a
destination rectangle with the background pixel defined in the GC and then
to paint the text with the foreground pixel.
The upper-left corner of the filled rectangle is at:
.LP
.Ds
[x, y \- font-ascent]
.De
.LP
The width is:
.LP
.Ds
overall-width
.De
.LP
The height is:
.LP
.Ds
font-ascent + font-descent
.De
.LP
The overall-width, font-ascent, and font-descent
are as would be returned by 
.PN XQueryTextExtents 
using gc and string.
The function and fill-style defined in the GC are ignored for these functions. 
The effective function is 
.PN GXcopy ,
and the effective fill-style is
.PN FillSolid .
.LP
For fonts defined with 2-byte matrix indexing
and used with
.PN XDrawImageString ,
each byte is used as a byte2 with a byte1 of zero.
.LP
Both functions use these GC components: 
plane-mask, foreground, background, font, subwindow-mode, clip-x-origin, 
clip-y-origin, and clip-mask.
.LP
.PN XDrawImageString
and
.PN XDrawImageString16
can generate
.PN BadDrawable ,
.PN BadGC ,
and
.PN BadMatch 
errors.
.LP
.NH 2
Transferring Images between Client and Server
.XS
\*(SN Transferring Images between Client and Server 
.XE
.LP
Xlib provides functions that you can use to transfer images between a client 
and the server.
Because the server may require diverse data formats, 
Xlib provides an image object that fully describes the data in memory 
and that provides for basic operations on that data.  
You should reference the data 
through the image object rather than referencing the data directly.
However, some implementations of the Xlib library may efficiently deal with 
frequently used data formats by replacing
functions in the procedure vector with special case functions.
Supported operations include destroying the image, getting a pixel,
storing a pixel, extracting a subimage of an image, and adding a constant
to an image (see section 16.8).
.LP
All the image manipulation functions discussed in this section make use of 
the 
.PN XImage 
structure,
which describes an image as it exists in the client's memory.
.LP
.IN "XImage" "" "@DEF@"
.sM
.Ds 0
.TA .5i 1i 3i
.ta .5i 1i 3i
typedef struct _XImage {
	int width, height;		/* size of image */
	int xoffset;		/* number of pixels offset in X direction */
	int format;		/* XYBitmap, XYPixmap, ZPixmap */
	char *data;		/* pointer to image data */
	int byte_order;		/* data byte order, LSBFirst, MSBFirst */
	int bitmap_unit;		/* quant. of scanline 8, 16, 32 */
	int bitmap_bit_order;		/* LSBFirst, MSBFirst */
	int bitmap_pad;		/* 8, 16, 32 either XY or ZPixmap */
	int depth;		/* depth of image */
	int bytes_per_line;		/* accelerator to next scanline */
	int bits_per_pixel;		/* bits per pixel (ZPixmap) */
	unsigned long red_mask;		/* bits in z arrangement */
	unsigned long green_mask;
	unsigned long blue_mask;
	XPointer obdata;	/* hook for the object routines to hang on */
	struct funcs {		/* image manipulation routines */
		struct _XImage *(*create_image)();
		int (*destroy_image)();
		unsigned long (*get_pixel)();
		int (*put_pixel)();
		struct _XImage *(*sub_image)();
		int (*add_pixel)();
	} f;
} XImage;
.De
.LP
.eM
.sp
To initialize the image manipulation routines of an image structure, use
.PN XInitImage .
.IN "XInitImage" "" "@DEF@"
.sM
.FD 0
Status XInitImage\^(\^\fIimage\fP\^)
.br
      XImage *\fIimage\fP\^;
.FN
.IP \fIximage\fP 1i
Specifies the image.
.LP
.eM
The
.PN XInitImage
function initializes the internal image manipulation routines of an
image structure, based on the values of the various structure members.
All fields other than the manipulation routines must already be initialized.
If the bytes_per_line member is zero,
.PN XInitImage
will assume the image data is contiguous in memory and set the
bytes_per_line member to an appropriate value based on the other
members; otherwise, the value of bytes_per_line is not changed.
All of the manipulation routines are initialized to functions
that other Xlib image manipulation functions need to operate on the
type of image specified by the rest of the structure.
.LP
This function must be called for any image constructed by the client
before passing it to any other Xlib function.
Image structures created or returned by Xlib do not need to be
initialized in this fashion.
.LP
This function returns a nonzero status if initialization of the
structure is successful.  It returns zero if it detected some error
or inconsistency in the structure, in which case the image is not changed.
.LP
.sp
To combine an image with a rectangle of a drawable on the display,
use
.PN XPutImage .
.IN "XPutImage" "" "@DEF@"
.sM
.FD 0
XPutImage\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIimage\fP\^, \fIsrc_x\fP, \fIsrc_y\fP, \fIdest_x\fP\^, \fIdest_y\fP\^, \fIwidth\fP\^, \fIheight\fP\^)
.br
        Display *\fIdisplay\fP\^;
.br
        Drawable \fId\fP\^;
.br
        GC \fIgc\fP\^;
.br
        XImage *\fIimage\fP\^;
.br
        int \fIsrc_x\fP\^, \fIsrc_y\fP\^;
.br
        int \fIdest_x\fP\^, \fIdest_y\fP\^;
.br
        unsigned int \fIwidth\fP\^, \fIheight\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.IP \fIgc\fP 1i
Specifies the GC.
.IP \fIimage\fP 1i
Specifies the image you want combined with the rectangle. 
.IP \fIsrc_x\fP 1i
Specifies the offset in X from the left edge of the image defined
by the 
.PN XImage 
structure.
.IP \fIsrc_y\fP 1i
Specifies the offset in Y from the top edge of the image defined
by the 
.PN XImage 
structure.
.ds Dx , which are relative to the origin of the drawable \
and are the coordinates of the subimage
.IP \fIdest_x\fP 1i
.br
.ns
.IP \fIdest_y\fP 1i
Specify the x and y coordinates\*(Dx. 
.ds Wh \ of the subimage, which define the dimensions of the rectangle
.IP \fIwidth\fP 1i
.br
.ns
.IP \fIheight\fP 1i
Specify the width and height\*(Wh.
.LP
.eM
The
.PN XPutImage
function
combines an image with a rectangle of the specified drawable.
The section of the image defined by the src_x, src_y, width, and height 
arguments is drawn on the specified part of the drawable.
If 
.PN XYBitmap 
format is used, the depth of the image must be one,
or a
.PN BadMatch 
error results.
The foreground pixel in the GC defines the source for the one bits in the image,
and the background pixel defines the source for the zero bits.
For 
.PN XYPixmap 
and 
.PN ZPixmap , 
the depth of the image must match the depth of the drawable,
or a
.PN BadMatch
error results.
.LP
If the characteristics of the image (for example, byte_order and bitmap_unit)
differ from what the server requires,
.PN XPutImage 
automatically makes the appropriate
conversions.
.LP
This function uses these GC components: 
function, plane-mask, subwindow-mode, clip-x-origin, clip-y-origin, 
and clip-mask.
It also uses these GC mode-dependent components:
foreground and background.
.LP
.PN XPutImage
can generate
.PN BadDrawable ,
.PN BadGC ,
.PN BadMatch ,
and
.PN BadValue 
errors.
.LP
.sp
To return the contents of a rectangle in a given drawable on the display,
use
.PN XGetImage .
This function specifically supports rudimentary screen dumps.
.IN "XGetImage" "" "@DEF@"
.sM
.FD 0
XImage *XGetImage\^(\^\fIdisplay\fP, \fId\fP\^, \fIx\fP\^, \fIy\fP\^, \fIwidth\fP\^, \fIheight\fP\^, \fIplane_mask\fP, \fIformat\fP\^)
.br
        Display *\fIdisplay\fP\^;
.br
        Drawable \fId\fP\^;
.br
        int \fIx\fP\^, \fIy\fP\^;
.br
        unsigned int \fIwidth\fP\^, \fIheight\fP\^;
.br
        unsigned long \fIplane_mask\fP\^;
.br
        int \fIformat\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.ds Xy , which are relative to the origin of the drawable \
and define the upper-left corner of the rectangle
.IP \fIx\fP 1i
.br
.ns
.IP \fIy\fP 1i
Specify the x and y coordinates\*(Xy.
.ds Wh \ of the subimage, which define the dimensions of the rectangle
.IP \fIwidth\fP 1i
.br
.ns
.IP \fIheight\fP 1i
Specify the width and height\*(Wh.
.IP \fIplane_mask\fP 1i
Specifies the plane mask.
.\" *** JIM: NEED MORE INFO FOR THIS. ***
.IP \fIformat\fP 1i
Specifies the format for the image.
You can pass
.PN XYPixmap
or 
.PN ZPixmap .
.LP
.eM
The
.PN XGetImage
function returns a pointer to an
.PN XImage
structure.
This structure provides you with the contents of the specified rectangle of
the drawable in the format you specify.
If the format argument is 
.PN XYPixmap ,
the image contains only the bit planes you passed to the plane_mask argument.
If the plane_mask argument only requests a subset of the planes of the
display, the depth of the returned image will be the number of planes
requested.
If the format argument is 
.PN ZPixmap ,
.PN XGetImage
returns as zero the bits in all planes not 
specified in the plane_mask argument.
The function performs no range checking on the values in plane_mask and ignores
extraneous bits.
.LP
.PN XGetImage
returns the depth of the image to the depth member of the
.PN XImage
structure.
The depth of the image is as specified when the drawable was created,
except when getting a subset of the planes in 
.PN XYPixmap
format, when the depth is given by the number of bits set to 1 in plane_mask.
.LP
If the drawable is a pixmap, 
the given rectangle must be wholly contained within the pixmap, 
or a
.PN BadMatch
error results.
If the drawable is a window, 
the window must be viewable, 
and it must be the case that if there were no inferiors or overlapping windows,
the specified rectangle of the window would be fully visible on the screen
and wholly contained within the outside edges of the window,
or a
.PN BadMatch
error results.
Note that the borders of the window can be included and read with
this request.
If the window has backing-store, the backing-store contents are
returned for regions of the window that are obscured by noninferior
windows. 
If the window does not have backing-store,
the returned contents of such obscured regions are undefined.
The returned contents of visible regions of inferiors
of a different depth than the specified window's depth are also undefined.
The pointer cursor image is not included in the returned contents.
If a problem occurs,
.PN XGetImage
returns NULL.
.LP
.PN XGetImage
can generate
.PN BadDrawable ,
.PN BadMatch ,
and
.PN BadValue 
errors.
.sp
.LP
To copy the contents of a rectangle on the display
to a location within a preexisting image structure, use
.PN XGetSubImage .
.IN "XGetSubImage" "" "@DEF@"
.sM
.FD 0
XImage *XGetSubImage\^(\^\fIdisplay\fP, \fId\fP\^, \fIx\fP\^, \fIy\fP\^, \fIwidth\fP\^, \fIheight\fP\^, \fIplane_mask\fP, \fIformat\fP\^, \fIdest_image\fP\^, \fIdest_x\fP\^, 
.br
                     \fIdest_y\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Drawable \fId\fP\^;
.br
      int \fIx\fP\^, \fIy\fP\^;
.br
      unsigned int \fIwidth\fP\^, \fIheight\fP\^;
.br
      unsigned long \fIplane_mask\fP\^;
.br
      int \fIformat\fP\^;
.br
      XImage *\fIdest_image\fP\^;
.br
      int \fIdest_x\fP\^, \fIdest_y\fP\^;
.FN
.IP \fIdisplay\fP 1i
Specifies the connection to the X server.
.IP \fId\fP 1i
Specifies the drawable. 
.ds Xy , which are relative to the origin of the drawable \
and define the upper-left corner of the rectangle
.IP \fIx\fP 1i
.br
.ns
.IP \fIy\fP 1i
Specify the x and y coordinates\*(Xy.
.ds Wh \ of the subimage, which define the dimensions of the rectangle
.IP \fIwidth\fP 1i
.br
.ns
.IP \fIheight\fP 1i
Specify the width and height\*(Wh.
.IP \fIplane_mask\fP 1i
Specifies the plane mask.
.\" *** JIM: NEED MORE INFO FOR THIS. ***
.IP \fIformat\fP 1i
Specifies the format for the image.
You can pass
.PN XYPixmap
or 
.PN ZPixmap .
.IP \fIdest_image\fP 1i
Specifies the destination image.
.ds Dx , which are relative to the origin of the destination rectangle, \
specify its upper-left corner, and determine where the subimage \
is placed in the destination image
.IP \fIdest_x\fP 1i
.br
.ns
.IP \fIdest_y\fP 1i
Specify the x and y coordinates\*(Dx. 
.LP
.eM
The 
.PN XGetSubImage 
function updates dest_image with the specified subimage in the same manner as 
.PN XGetImage . 
If the format argument is 
.PN XYPixmap ,
the image contains only the bit planes you passed to the plane_mask argument.
If the format argument is 
.PN ZPixmap ,
.PN XGetSubImage
returns as zero the bits in all planes not 
specified in the plane_mask argument.
The function performs no range checking on the values in plane_mask and ignores
extraneous bits.
As a convenience,
.PN XGetSubImage
returns a pointer to the same
.PN XImage
structure specified by dest_image.
.LP
The depth of the destination
.PN XImage
structure must be the same as that of the drawable.
If the specified subimage does not fit at the specified location
on the destination image, the right and bottom edges are clipped.
If the drawable is a pixmap,
the given rectangle must be wholly contained within the pixmap,
or a
.PN BadMatch
error results.
If the drawable is a window, 
the window must be viewable, 
and it must be the case that if there were no inferiors or overlapping windows,
the specified rectangle of the window would be fully visible on the screen
and wholly contained within the outside edges of the window,
or a
.PN BadMatch
error results.
If the window has backing-store, 
then the backing-store contents are returned for regions of the window 
that are obscured by noninferior windows. 
If the window does not have backing-store, 
the returned contents of such obscured regions are undefined.
The returned contents of visible regions of inferiors
of a different depth than the specified window's depth are also undefined.
If a problem occurs,
.PN XGetSubImage
returns NULL.
.LP
.PN XGetSubImage
can generate
.PN BadDrawable ,
.PN BadGC ,
.PN BadMatch ,
and
.PN BadValue 
errors.
.bp