From 5f0fa185d0a978b45de5bf206193769596c056b5 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 26 May 2020 11:36:59 -0400 Subject: fontsrv: handle non-BMP runes on X11 Have to adjust algorithms to deal with much larger number of subfont files as well. --- src/cmd/fontsrv/main.c | 53 ++++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 30 deletions(-) (limited to 'src/cmd/fontsrv/main.c') diff --git a/src/cmd/fontsrv/main.c b/src/cmd/fontsrv/main.c index ebab6249..b2189be9 100644 --- a/src/cmd/fontsrv/main.c +++ b/src/cmd/fontsrv/main.c @@ -52,7 +52,7 @@ enum #define QFONT(p) (((p) >> 4) & 0xFFFF) #define QSIZE(p) (((p) >> 20) & 0xFF) #define QANTIALIAS(p) (((p) >> 28) & 0x1) -#define QRANGE(p) (((p) >> 29) & SubfontMask) +#define QRANGE(p) (((p) >> 29) & 0xFFFFFF) static int sizes[] = { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 24, 28 }; static vlong @@ -102,7 +102,7 @@ dostat(vlong path, Qid *qid, Dir *dir) case Qfontfile: f = &xfont[QFONT(path)]; load(f); - length = 11+1+11+1+f->nrange*(6+1+6+1+9+1); + length = 11+1+11+1+f->nfile*(6+1+6+1+9+1); name = "font"; break; @@ -189,9 +189,9 @@ xwalk1(Fid *fid, char *name, Qid *qid) goto NotFound; p++; n = strtoul(p, &p, 16); - if(p != name+5 || n%SubfontSize != 0 || strcmp(p, ".bit") != 0 || !f->range[(n/SubfontSize) & SubfontMask]) + if(p < name+5 || p > name+5 && name[1] == '0' || n%SubfontSize != 0 || n/SubfontSize >= MaxSubfont || strcmp(p, ".bit") != 0 || !f->range[n/SubfontSize]) goto NotFound; - path += Qsubfontfile - Qsizedir + qpath(0, 0, 0, 0, (n/SubfontSize) & SubfontMask); + path += Qsubfontfile - Qsizedir + qpath(0, 0, 0, 0, n/SubfontSize); break; } Found: @@ -229,7 +229,6 @@ sizegen(int i, Dir *d, void *v) vlong path; Fid *fid; XFont *f; - int j; fid = v; path = fid->qid.path; @@ -240,15 +239,10 @@ sizegen(int i, Dir *d, void *v) i--; f = &xfont[QFONT(path)]; load(f); - for(j=0; jrange); j++) { - if(f->range[j] == 0) - continue; - if(i == 0) { - path += Qsubfontfile - Qsizedir; - path += qpath(0, 0, 0, 0, j); - goto Done; - } - i--; + if(i < f->nfile) { + path += Qsubfontfile - Qsizedir; + path += qpath(0, 0, 0, 0, f->file[i]); + goto Done; } return -1; @@ -315,23 +309,22 @@ 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); - for(i=0; irange); i++) { - if(f->range[i] == 0) - continue; - fmtprint(&fmt, "0x%04x 0x%04x x%04x.bit\n", i*SubfontSize, ((i+1)*SubfontSize) - 1, i*SubfontSize); + 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%04x 0x%04x x%04x.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); } - data = fmtstrflush(&fmt); - readstr(r, data); - free(data); + readbuf(r, f->fonttext, f->nfonttext); break; case Qsubfontfile: f = &xfont[QFONT(path)]; -- cgit v1.2.3