History

20121205-1740

forsyth committed 13 years ago

Commit 63a80ccNo parent (first commit)9462 files · +1777217 −-3784Browse files

Showing the changes to libmemdraw/string.c (1 of 9462 files). Show all

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t