diff --git a/sys/include/memdraw.h b/sys/include/memdraw.h index f1bb41e3f..62cc8cae5 100644 --- a/sys/include/memdraw.h +++ b/sys/include/memdraw.h @@ -80,6 +80,7 @@ struct Memsubfont short n; /* number of chars in font */ uchar height; /* height of bitmap */ char ascent; /* top of bitmap to baseline */ + Rune min; /* rune offset for first glyph in subfont */ Fontchar *info; /* n+1 character descriptors */ Memimage *bits; /* of font */ }; @@ -156,7 +157,7 @@ extern int memimageinit(void); * Subfont management */ extern Memsubfont* allocmemsubfont(char*, int, int, int, Fontchar*, Memimage*); -extern Memsubfont* openmemsubfont(char*); +extern Memsubfont* openmemsubfont(char*, Rune); extern void freememsubfont(Memsubfont*); extern Point memsubfontwidth(Memsubfont*, char*); extern Memsubfont* getmemdefont(void); diff --git a/sys/man/2/memdraw b/sys/man/2/memdraw index 0500a561b..865dbdd09 100644 --- a/sys/man/2/memdraw +++ b/sys/man/2/memdraw @@ -150,7 +150,7 @@ int memlineendsize(int end) .nf Memsubfont* allocmemsubfont(char *name, int n, int height, int ascent, Fontchar *info, Memimage *i) -Memsubfont* openmemsubfont(char *name) +Memsubfont* openmemsubfont(char *name, Rune min) void freememsubfont(Memsubfont *f) Point memsubfontwidth(Memsubfont *f, char *s) Memsubfont* getmemdefont(void) diff --git a/sys/src/cmd/venti/srv/graph.c b/sys/src/cmd/venti/srv/graph.c index cbad1ada2..780c674da 100644 --- a/sys/src/cmd/venti/srv/graph.c +++ b/sys/src/cmd/venti/srv/graph.c @@ -58,7 +58,7 @@ ginit(void) #ifdef PLAN9PORT smallfont = openmemsubfont(unsharp("#9/font/lucsans/lstr.10")); #else - smallfont = openmemsubfont("/lib/font/bit/lucidasans/lstr.10"); + smallfont = openmemsubfont("/lib/font/bit/lucidasans/lstr.10", 0); #endif black = memblack; blue = allocrepl(DBlue); diff --git a/sys/src/libmemdraw/openmemsubfont.c b/sys/src/libmemdraw/openmemsubfont.c index 1a17cfde6..22a644c29 100644 --- a/sys/src/libmemdraw/openmemsubfont.c +++ b/sys/src/libmemdraw/openmemsubfont.c @@ -4,7 +4,7 @@ #include Memsubfont* -openmemsubfont(char *name) +openmemsubfont(char *name, Rune min) { Memsubfont *sf; Memimage *i; @@ -45,6 +45,7 @@ openmemsubfont(char *name) free(fc); goto Err; } + sf->min = min; close(fd); free(p); return sf; diff --git a/sys/src/libmemdraw/string.c b/sys/src/libmemdraw/string.c index c0a6dc2de..69b4b5ab5 100644 --- a/sys/src/libmemdraw/string.c +++ b/sys/src/libmemdraw/string.c @@ -25,6 +25,7 @@ memimagestring(Memimage *b, Point p, Memimage *color, Point cp, Memsubfont *f, c } s += w; } + c -= f->min; if(c >= f->n) continue; i = f->info+c; @@ -58,6 +59,7 @@ memsubfontwidth(Memsubfont *f, char *cs) } s += w; } + c -= f->min; if(c >= f->n) continue; i = f->info+c;