string.c (1057B)
1 #include "u.h" 2 #include "lib.h" 3 #include "draw.h" 4 #include "memdraw.h" 5 #include "memlayer.h" 6 7 Point 8 memimagestring(Memimage *b, Point p, Memimage *color, Point cp, Memsubfont *f, char *cs) 9 { 10 int w, width; 11 uchar *s; 12 Rune c; 13 Fontchar *i; 14 15 s = (uchar*)cs; 16 for(; (c=*s); p.x+=width, cp.x+=width){ 17 width = 0; 18 if(c < Runeself) 19 s++; 20 else{ 21 w = chartorune(&c, (char*)s); 22 if(w == 0){ 23 s++; 24 continue; 25 } 26 s += w; 27 } 28 if(c >= f->n) 29 continue; 30 i = f->info+c; 31 width = i->width; 32 memdraw(b, Rect(p.x+i->left, p.y+i->top, p.x+i->left+(i[1].x-i[0].x), p.y+i->bottom), 33 color, cp, f->bits, Pt(i->x, i->top), SoverD); 34 } 35 return p; 36 } 37 38 Point 39 memsubfontwidth(Memsubfont *f, char *cs) 40 { 41 Rune c; 42 Point p; 43 uchar *s; 44 Fontchar *i; 45 int w, width; 46 47 p = Pt(0, f->height); 48 s = (uchar*)cs; 49 for(; (c=*s); p.x+=width){ 50 width = 0; 51 if(c < Runeself) 52 s++; 53 else{ 54 w = chartorune(&c, (char*)s); 55 if(w == 0){ 56 s++; 57 continue; 58 } 59 s += w; 60 } 61 if(c >= f->n) 62 continue; 63 i = f->info+c; 64 width = i->width; 65 } 66 return p; 67 }