diff options
author | rsc <devnull@localhost> | 2003-09-30 17:47:42 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2003-09-30 17:47:42 +0000 |
commit | ed7c8e8d02c02bdbff1e88a6d8d1419f39af48ad (patch) | |
tree | ebcd32d20b0df2584bce713fefa87620ecd1cce7 /src/libdraw/mkfont.c | |
parent | b2cfc4e2e71d0f0a5113ddfbd93c8285cc4d74e4 (diff) | |
download | plan9port-ed7c8e8d02c02bdbff1e88a6d8d1419f39af48ad.tar.gz plan9port-ed7c8e8d02c02bdbff1e88a6d8d1419f39af48ad.tar.bz2 plan9port-ed7c8e8d02c02bdbff1e88a6d8d1419f39af48ad.zip |
Initial import.
Diffstat (limited to 'src/libdraw/mkfont.c')
-rw-r--r-- | src/libdraw/mkfont.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/libdraw/mkfont.c b/src/libdraw/mkfont.c new file mode 100644 index 00000000..df6b0ec2 --- /dev/null +++ b/src/libdraw/mkfont.c @@ -0,0 +1,55 @@ +#include <u.h> +#include <libc.h> +#include <draw.h> + +/* + * Cobble fake font using existing subfont + */ +Font* +mkfont(Subfont *subfont, Rune min) +{ + Font *font; + Cachefont *c; + + font = malloc(sizeof(Font)); + if(font == 0) + return 0; + memset(font, 0, sizeof(Font)); + font->display = subfont->bits->display; + font->name = strdup("<synthetic>"); + font->ncache = NFCACHE+NFLOOK; + font->nsubf = NFSUBF; + font->cache = malloc(font->ncache * sizeof(font->cache[0])); + font->subf = malloc(font->nsubf * sizeof(font->subf[0])); + if(font->name==0 || font->cache==0 || font->subf==0){ + Err: + free(font->name); + free(font->cache); + free(font->subf); + free(font->sub); + free(font); + return 0; + } + memset(font->cache, 0, font->ncache*sizeof(font->cache[0])); + memset(font->subf, 0, font->nsubf*sizeof(font->subf[0])); + font->height = subfont->height; + font->ascent = subfont->ascent; + font->age = 1; + font->sub = malloc(sizeof(Cachefont*)); + if(font->sub == 0) + goto Err; + c = malloc(sizeof(Cachefont)); + if(c == 0) + goto Err; + font->nsub = 1; + font->sub[0] = c; + c->min = min; + c->max = min+subfont->n-1; + c->offset = 0; + c->name = 0; /* noticed by freeup() and agefont() */ + c->subfontname = 0; + font->subf[0].age = 0; + font->subf[0].cf = c; + font->subf[0].f = subfont; + return font; +} |