aboutsummaryrefslogtreecommitdiff
path: root/src/libdraw/font.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-04-25 20:26:27 +0000
committerrsc <devnull@localhost>2004-04-25 20:26:27 +0000
commit4e206880423db866dd1db0622a9b4d5b0881fee1 (patch)
treec4a2b577708093741962ca07a0ffcb8cf14ce6cc /src/libdraw/font.c
parenta2c2caaafe37e119078bc88f6ebee6d338cbff46 (diff)
downloadplan9port-4e206880423db866dd1db0622a9b4d5b0881fee1.tar.gz
plan9port-4e206880423db866dd1db0622a9b4d5b0881fee1.tar.bz2
plan9port-4e206880423db866dd1db0622a9b4d5b0881fee1.zip
make it possible to access fonts without a display.
Diffstat (limited to 'src/libdraw/font.c')
-rw-r--r--src/libdraw/font.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/libdraw/font.c b/src/libdraw/font.c
index 9feffa42..d7a93545 100644
--- a/src/libdraw/font.c
+++ b/src/libdraw/font.c
@@ -161,7 +161,8 @@ cf2subfont(Cachefont *cf, Font *f)
if(f->display){
if(f->display->screenimage)
depth = f->display->screenimage->depth;
- }
+ }else
+ depth = 8;
name = subfontname(cf->name, f->name, depth);
if(name == nil)
return nil;
@@ -244,7 +245,7 @@ loadchar(Font *f, Rune r, Cacheinfo *c, int h, int noflush, char **subfontname)
}
subf->cf = cf;
- if(subf->f->ascent > f->ascent){
+ if(subf->f->ascent > f->ascent && f->display){
/* should print something? this is a mistake in the font file */
/* must prevent c->top from going negative when loading cache */
Image *b;
@@ -297,6 +298,8 @@ loadchar(Font *f, Rune r, Cacheinfo *c, int h, int noflush, char **subfontname)
c->width = fi->width;
c->x = h*f->width;
c->left = fi->left;
+ if(f->display == nil)
+ return 1;
flushimage(f->display, 0); /* flush any pending errors */
b = bufimage(f->display, 37);
if(b == 0)
@@ -355,10 +358,13 @@ fontresize(Font *f, int wid, int ncache, int depth)
Display *d;
ret = 0;
- d = f->display;
if(depth <= 0)
depth = 1;
+ d = f->display;
+ if(d == nil)
+ goto Nodisplay;
+
new = allocimage(d, Rect(0, 0, ncache*wid, f->height), CHAN1(CGrey, depth), 0, 0);
if(new == nil){
fprint(2, "font cache resize failed: %r\n");
@@ -382,6 +388,7 @@ fontresize(Font *f, int wid, int ncache, int depth)
}
freeimage(f->cacheimage);
f->cacheimage = new;
+ Nodisplay:
f->width = wid;
f->maxdepth = depth;
ret = 1;