plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

commit 1fcdefc5854ff5708ad545eb047075838eda55ff
parent 85bfd19a7beb628f24b051d23e6c94ecc6e4babc
Author: Xiao-Yong Jin <xjin@anl.gov>
Date:   Thu, 16 Jul 2020 11:50:26 -0500

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

Diffstat:
Msrc/cmd/fontsrv/main.c | 23++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/cmd/fontsrv/main.c b/src/cmd/fontsrv/main.c @@ -287,6 +287,7 @@ xread(Req *r) Fmt fmt; XFont *f; char *data; + char *buf; Memsubfont *sf; Memimage *m; @@ -309,20 +310,24 @@ xread(Req *r) readstr(r, "font missing\n"); break; } + height = 0; + ascent = 0; + if(f->unit > 0) { + height = f->height * (int)QSIZE(path)/f->unit + 0.99999999; + ascent = height - (int)(-f->originy * (int)QSIZE(path)/f->unit + 0.99999999); + } + if(f->loadheight != nil) + f->loadheight(f, QSIZE(path), &height, &ascent); + fmtprint(&fmt, "%11d %11d\n", height, ascent); if(f->fonttext == nil) { - height = 0; - ascent = 0; - if(f->unit > 0) { - height = f->height * (int)QSIZE(path)/f->unit + 0.99999999; - ascent = height - (int)(-f->originy * (int)QSIZE(path)/f->unit + 0.99999999); - } - if(f->loadheight != nil) - f->loadheight(f, QSIZE(path), &height, &ascent); - fmtprint(&fmt, "%11d %11d\n", height, ascent); 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;