History

a

Russ Cox committed 21 years ago

Commit 934846f1 parent 0189e66382 files · +62610 −-4Browse files

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

Unified · Split

libmemdraw/string.c+68−0
@@ -0,0 +1,68 @@
1+#include <u.h>
2+#include <libc.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+ i = &(f->info[c]);
32+ width = i->width;
33+ 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),
34+ color, cp, f->bits, Pt(i->x, i->top), SoverD);
35+ }
36+ return p;
37+}
38+
39+Point
40+memsubfontwidth(Memsubfont *f, char *cs)
41+{
42+ Rune c;
43+ Point p;
44+ uchar *s;
45+ Fontchar *i;
46+ int w, width;
47+
48+ p = Pt(0, f->height);
49+ s = (uchar*)cs;
50+ for(; c=*s; p.x+=width){
51+ width = 0;
52+ if(c < Runeself)
53+ s++;
54+ else{
55+ w = chartorune(&c, (char*)s);
56+ if(w == 0){
57+ s++;
58+ continue;
59+ }
60+ s += w;
61+ }
62+ if(c >= f->n)
63+ continue;
64+ i = f->info+c;
65+ width = i->width;
66+ }
67+ return p;
68+}

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