From 1fcdefc5854ff5708ad545eb047075838eda55ff Mon Sep 17 00:00:00 2001 From: Xiao-Yong Jin Date: Thu, 16 Jul 2020 11:50:26 -0500 Subject: [PATCH] fontsrv: always compute new height and ascent for the font file --- src/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 index 54cd52a8..fd629801 100644 --- 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; infile; 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;