mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-27 11:52:03 +00:00
Rewrite /lib/font/bit to $PLAN9/font when open fails.
This commit is contained in:
parent
a3c5df578f
commit
e6f4b2e311
1 changed files with 22 additions and 1 deletions
|
@ -9,9 +9,27 @@ openfont(Display *d, char *name)
|
||||||
{
|
{
|
||||||
Font *fnt;
|
Font *fnt;
|
||||||
int fd, i, n;
|
int fd, i, n;
|
||||||
char *buf;
|
char *buf, *nambuf, *root;
|
||||||
|
|
||||||
|
nambuf = 0;
|
||||||
fd = open(name, OREAD);
|
fd = open(name, OREAD);
|
||||||
|
|
||||||
|
if(fd < 0 && strncmp(name, "/lib/font/bit/", 14) == 0){
|
||||||
|
root = getenv("PLAN9");
|
||||||
|
if(root == nil)
|
||||||
|
return 0;
|
||||||
|
nambuf = malloc(strlen(root)+5+strlen(name+13)+1);
|
||||||
|
if(nambuf == nil)
|
||||||
|
return 0;
|
||||||
|
strcpy(nambuf, root);
|
||||||
|
strcat(nambuf, "/font");
|
||||||
|
strcat(nambuf, name+13);
|
||||||
|
if((fd = open(nambuf, OREAD)) < 0){
|
||||||
|
free(nambuf);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
name = nambuf;
|
||||||
|
}
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -19,6 +37,7 @@ openfont(Display *d, char *name)
|
||||||
buf = malloc(n+1);
|
buf = malloc(n+1);
|
||||||
if(buf == 0){
|
if(buf == 0){
|
||||||
close(fd);
|
close(fd);
|
||||||
|
free(nambuf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
buf[n] = 0;
|
buf[n] = 0;
|
||||||
|
@ -26,9 +45,11 @@ openfont(Display *d, char *name)
|
||||||
close(fd);
|
close(fd);
|
||||||
if(i != n){
|
if(i != n){
|
||||||
free(buf);
|
free(buf);
|
||||||
|
free(nambuf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
fnt = buildfont(d, buf, name);
|
fnt = buildfont(d, buf, name);
|
||||||
free(buf);
|
free(buf);
|
||||||
|
free(nambuf);
|
||||||
return fnt;
|
return fnt;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue