diff options
| author | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
| commit | 37da2899f40661e3e9631e497da8dc59b971cbd0 (patch) | |
| tree | cbc6d4680e347d906f5fa7fca73214418741df72 /libdraw/writesubfont.c | |
| parent | 54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff) | |
20060303a
Diffstat (limited to 'libdraw/writesubfont.c')
| -rw-r--r-- | libdraw/writesubfont.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/libdraw/writesubfont.c b/libdraw/writesubfont.c new file mode 100644 index 00000000..af7f0dc5 --- /dev/null +++ b/libdraw/writesubfont.c @@ -0,0 +1,45 @@ +#include "lib9.h" +#include "draw.h" +#include "kernel.h" + +static +void +packinfo(Fontchar *fc, uchar *p, int n) +{ + int j; + + for(j=0; j<=n; j++){ + p[0] = fc->x; + p[1] = fc->x>>8; + p[2] = fc->top; + p[3] = fc->bottom; + p[4] = fc->left; + p[5] = fc->width; + fc++; + p += 6; + } +} + +int +writesubfont(int fd, Subfont *f) +{ + char hdr[3*12+1]; + uchar *data; + int nb; + + sprint(hdr, "%11d %11d %11d ", f->n, f->height, f->ascent); + if(libwrite(fd, hdr, 3*12) != 3*12){ + Err: + kwerrstr("writesubfont: bad write: %r"); + return -1; + } + nb = 6*(f->n+1); + data = malloc(nb); + if(data == nil) + return -1; + packinfo(f->info, data, f->n); + if(libwrite(fd, data, nb) != nb) + goto Err; + free(data); + return 0; +} |
