|
|
1.1 root 1: % Copyright Barbara Liskov 1985, 1986
2:
3: x_font = cluster is create, destroy, query, widths, width, all_widths,
4: get_id, equal, similar, copy
5:
6: rep = int
7:
8: create = proc (name: string) returns (cvt) signals (error(string))
9: x_buf$setup(x_getfont, 0, 0, 0)
10: x_buf$set_s0(string$size(name))
11: x_buf$send_data(s2b(name), 1, string$size(name))
12: x_buf$receive()
13: resignal error
14: return(x_buf$get_lp0())
15: end create
16:
17: destroy = proc (font: cvt)
18: x_buf$setup(x_freefont, 0, 0, 0)
19: x_buf$set_l0(font)
20: end destroy
21:
22: % returns (avg_width, height, first_char, last_char, baseline, fixedwidth)
23:
24: query = proc (font: cvt) returns (int, int, char, char, int, bool)
25: signals (error(string))
26: x_buf$setup(x_queryfont, 0, 0, 0)
27: x_buf$set_l0(font)
28: x_buf$receive()
29: resignal error
30: return(x_buf$get_sp1(), x_buf$get_sp0(),
31: char$i2c(x_buf$get_sp2()), char$i2c(x_buf$get_sp3()),
32: x_buf$get_sp4(), x_buf$get_sp5() ~= 0)
33: end query
34:
35: widths = iter (font: cvt, s: string) yields (char, int) signals (error(string))
36: x_buf$setup(x_charwidths, 0, 0, 0)
37: x_buf$set_l0s23(font, string$size(s), 0)
38: x_buf$send_data(s2b(s), 1, string$size(s))
39: x_buf$receive()
40: resignal error
41: b: _bytevec := _bytevec$create(x_buf$get_lp0())
42: x_buf$receive_data(b)
43: i: int := 1
44: for c: char in string$chars(s) do
45: yield(c, _wordvec$wfetch(b2w(b), i))
46: i := i + 2
47: end
48: end widths
49:
50: width = proc (font: cvt, s: string) returns (int) signals (error(string))
51: x_buf$setup(x_stringwidth, 0, 0, 0)
52: x_buf$set_l0s23(font, string$size(s), 0)
53: x_buf$send_data(s2b(s), 1, string$size(s))
54: x_buf$receive()
55: resignal error
56: return(x_buf$get_sp0())
57: end width
58:
59: all_widths = proc (font: cvt) returns (_wordvec) signals (error(string))
60: x_buf$setup(x_fontwidths, 0, 0, 0)
61: x_buf$set_l0(font)
62: x_buf$receive()
63: resignal error
64: b: _bytevec := _bytevec$create(x_buf$get_lp0())
65: x_buf$receive_data(b)
66: return(b2w(b))
67: end all_widths
68:
69: get_id = proc (font: cvt) returns (int)
70: return(font)
71: end get_id
72:
73: equal = proc (font1, font2: cvt) returns (bool)
74: return(font1 = font2)
75: end equal
76:
77: similar = proc (font1, font2: cvt) returns (bool)
78: return(font1 = font2)
79: end similar
80:
81: copy = proc (font: cvt) returns (cvt)
82: return(font)
83: end copy
84:
85: end x_font
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.