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