Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_fixcpp/sys/src/libdraw/writesubfont.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
#include <draw.h>
4
 
5
static
6
void
7
packinfo(Fontchar *fc, uchar *p, int n)
8
{
9
	int j;
10
 
11
	for(j=0;  j<=n;  j++){
12
		p[0] = fc->x;
13
		p[1] = fc->x>>8;
14
		p[2] = fc->top;
15
		p[3] = fc->bottom;
16
		p[4] = fc->left;
17
		p[5] = fc->width;
18
		fc++;
19
		p += 6;
20
	}
21
}
22
 
23
int
24
writesubfont(int fd, Subfont *f)
25
{
26
	char hdr[3*12+1];
27
	uchar *data;
28
	int nb;
29
 
30
	sprint(hdr, "%11d %11d %11d ", f->n, f->height, f->ascent);
31
	if(write(fd, hdr, 3*12) != 3*12){
32
   Err:
33
		werrstr("writesubfont: bad write: %r");
34
		return -1;
35
	}
36
	nb = 6*(f->n+1);
37
	data = malloc(nb);
38
	if(data == nil)
39
		return -1;
40
	packinfo(f->info, data, f->n);
41
	if(write(fd, data, nb) != nb)
42
		goto Err;
43
	free(data);
44
	return 0;
45
}