diff options
author | Russ Cox <rsc@swtch.com> | 2015-07-03 10:57:42 -0400 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2015-08-27 00:36:32 +0000 |
commit | 775cb933ecea6361717ef1def27b5d9e90c385fd (patch) | |
tree | 54ddbbe2d08575ba2d3de54fdeab57da74d7a4c7 /src/cmd/fontsrv | |
parent | a78b1841be06709756d7fd3ccb6abac3a14a3cdb (diff) | |
download | plan9port-775cb933ecea6361717ef1def27b5d9e90c385fd.tar.gz plan9port-775cb933ecea6361717ef1def27b5d9e90c385fd.tar.bz2 plan9port-775cb933ecea6361717ef1def27b5d9e90c385fd.zip |
fontsrv: use 64 chars per subfont instead of 256
Makes loading faster, and makes larger sizes not too wide.
Change-Id: I076c83fdb9577c1e596de45558f38ea93e3a2a31
Reviewed-on: https://plan9port-review.googlesource.com/1360
Reviewed-by: Russ Cox <rsc@swtch.com>
Diffstat (limited to 'src/cmd/fontsrv')
-rw-r--r-- | src/cmd/fontsrv/a.h | 7 | ||||
-rw-r--r-- | src/cmd/fontsrv/main.c | 12 | ||||
-rw-r--r-- | src/cmd/fontsrv/x11.c | 2 |
3 files changed, 13 insertions, 8 deletions
diff --git a/src/cmd/fontsrv/a.h b/src/cmd/fontsrv/a.h index 67a7b365..3344d28e 100644 --- a/src/cmd/fontsrv/a.h +++ b/src/cmd/fontsrv/a.h @@ -2,11 +2,16 @@ typedef struct XFont XFont; XFont *xfont; int nxfont; +enum { + SubfontSize = 32, + SubfontMask = (1<<16)/SubfontSize - 1, +}; + struct XFont { char *name; int loaded; - uchar range[256]; // range[i] == whether to have subfont i<<8 to (i+1)<<8. + uchar range[(1<<16)/SubfontSize]; // range[i] == whether to have subfont i*SubfontSize to (i+1)*SubfontSize - 1. int nrange; int unit; double height; diff --git a/src/cmd/fontsrv/main.c b/src/cmd/fontsrv/main.c index 5a43ef15..b00802d8 100644 --- a/src/cmd/fontsrv/main.c +++ b/src/cmd/fontsrv/main.c @@ -54,7 +54,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) & 0xFF) +#define QRANGE(p) (((p) >> 29) & SubfontMask) 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 @@ -109,7 +109,7 @@ dostat(vlong path, Qid *qid, Dir *dir) break; case Qsubfontfile: - snprint(buf, sizeof buf, "x%02llx00.bit", QRANGE(path)); + snprint(buf, sizeof buf, "x%04x.bit", (int)QRANGE(path)*SubfontSize); name = buf; break; } @@ -191,9 +191,9 @@ xwalk1(Fid *fid, char *name, Qid *qid) goto NotFound; p++; n = strtoul(p, &p, 16); - if(p != name+5 || (n&0xFF) != 0 || strcmp(p, ".bit") != 0 || !f->range[(n>>8) & 0xFF]) + if(p != name+5 || n%SubfontSize != 0 || strcmp(p, ".bit") != 0 || !f->range[(n/SubfontSize) & SubfontMask]) goto NotFound; - path += Qsubfontfile - Qsizedir + qpath(0, 0, 0, 0, (n>>8) & 0xFF); + path += Qsubfontfile - Qsizedir + qpath(0, 0, 0, 0, (n/SubfontSize) & SubfontMask); break; } Found: @@ -329,7 +329,7 @@ xread(Req *r) for(i=0; i<nelem(f->range); i++) { if(f->range[i] == 0) continue; - fmtprint(&fmt, "0x%04x 0x%04x x%04x.bit\n", i<<8, (i<<8) + 0xFF, i<<8); + fmtprint(&fmt, "0x%04x 0x%04x x%04x.bit\n", i*SubfontSize, ((i+1)*SubfontSize) - 1, i*SubfontSize); } data = fmtstrflush(&fmt); readstr(r, data); @@ -339,7 +339,7 @@ xread(Req *r) f = &xfont[QFONT(path)]; load(f); if(r->fid->aux == nil) { - r->fid->aux = mksubfont(f, f->name, QRANGE(path)<<8, (QRANGE(path)<<8)+0xFF, QSIZE(path), QANTIALIAS(path)); + r->fid->aux = mksubfont(f, f->name, QRANGE(path)*SubfontSize, ((QRANGE(path)+1)*SubfontSize)-1, QSIZE(path), QANTIALIAS(path)); if(r->fid->aux == nil) { responderrstr(r); return; diff --git a/src/cmd/fontsrv/x11.c b/src/cmd/fontsrv/x11.c index 8245d0f7..f106d253 100644 --- a/src/cmd/fontsrv/x11.c +++ b/src/cmd/fontsrv/x11.c @@ -86,7 +86,7 @@ load(XFont *f) for(charcode=FT_Get_First_Char(face, &glyph_index); glyph_index != 0; charcode=FT_Get_Next_Char(face, charcode, &glyph_index)) { - int idx = charcode>>8; + int idx = charcode/SubfontSize; if(charcode > 0xffff) break; |