fontsrv: always compute new height and ascent for the font file

This commit is contained in:
Xiao-Yong Jin 2020-07-16 11:50:26 -05:00 committed by Dan Cross
parent 85bfd19a7b
commit 1fcdefc585

View file

@ -287,6 +287,7 @@ xread(Req *r)
Fmt fmt;
XFont *f;
char *data;
char *buf;
Memsubfont *sf;
Memimage *m;
@ -309,7 +310,6 @@ xread(Req *r)
readstr(r, "font missing\n");
break;
}
if(f->fonttext == nil) {
height = 0;
ascent = 0;
if(f->unit > 0) {
@ -319,10 +319,15 @@ xread(Req *r)
if(f->loadheight != nil)
f->loadheight(f, QSIZE(path), &height, &ascent);
fmtprint(&fmt, "%11d %11d\n", height, ascent);
if(f->fonttext == nil) {
for(i=0; i<f->nfile; i++)
fmtprint(&fmt, "0x%06x 0x%06x x%06x.bit\n", f->file[i]*SubfontSize, ((f->file[i]+1)*SubfontSize) - 1, f->file[i]*SubfontSize);
f->fonttext = fmtstrflush(&fmt);
f->nfonttext = strlen(f->fonttext);
} else {
buf = fmtstrflush(&fmt);
strncpy(f->fonttext, buf, strlen(buf)); // Do not copy the null byte.
free(buf);
}
readbuf(r, f->fonttext, f->nfonttext);
break;