libdraw: add 2*font syntax for scaled fonts
An experiment. Change-Id: I40660a211b8372701597d80f7e86917e94cccbaa Reviewed-on: https://plan9port-review.googlesource.com/1161 Reviewed-by: Russ Cox <rsc@swtch.com>
This commit is contained in:
parent
32dc15fa62
commit
77f23268f7
7 changed files with 77 additions and 5 deletions
|
|
@ -9,10 +9,15 @@ Font*
|
|||
openfont(Display *d, char *name)
|
||||
{
|
||||
Font *fnt;
|
||||
int fd, i, n;
|
||||
int fd, i, n, scale;
|
||||
char *buf, *nambuf;
|
||||
|
||||
nambuf = 0;
|
||||
scale = 1;
|
||||
if('1' <= name[0] && name[0] <= '9' && name[1] == '*') {
|
||||
scale = name[0] - '0';
|
||||
name += 2;
|
||||
}
|
||||
fd = open(name, OREAD);
|
||||
|
||||
if(fd < 0 && strncmp(name, "/lib/font/bit/", 14) == 0){
|
||||
|
|
@ -54,6 +59,12 @@ openfont(Display *d, char *name)
|
|||
fnt = buildfont(d, buf, name);
|
||||
free(buf);
|
||||
free(nambuf);
|
||||
if(scale != 1) {
|
||||
fnt->scale = scale;
|
||||
fnt->height *= scale;
|
||||
fnt->ascent *= scale;
|
||||
fnt->width *= scale;
|
||||
}
|
||||
return fnt;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue