|
|
1.1 ! root 1: #include <u.h> ! 2: #include <libc.h> ! 3: #include <libg.h> ! 4: #include <gnot.h> ! 5: ! 6: Point ! 7: gsubfstrsize(GSubfont *f, char *cs) ! 8: { ! 9: int i, l, n; ! 10: Fontchar *info; ! 11: uchar *s; ! 12: Rune c; ! 13: ! 14: s = (uchar*)cs; ! 15: l = 0; ! 16: n = f->n; ! 17: info = f->info; ! 18: if(s) ! 19: while(c = *s){ ! 20: if(c < Runeself) ! 21: s++; ! 22: else{ ! 23: i = chartorune(&c, (char*)s); ! 24: if(i == 0){ ! 25: s++; ! 26: continue; ! 27: } ! 28: s += i; ! 29: } ! 30: if(c < n) ! 31: l += info[c].width; ! 32: } ! 33: return Pt(l, f->height); ! 34: } ! 35: ! 36: long ! 37: gsubfstrwidth(GSubfont *f, char *s) ! 38: { ! 39: Point p; ! 40: ! 41: p = gsubfstrsize(f,s); ! 42: return p.x; ! 43: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.