From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from finch.cse.psu.edu ([130.203.12.29]) by hawkwind.utcs.utoronto.ca with SMTP id <24696>; Fri, 28 Nov 1997 22:56:25 -0500 Received: (qmail 6505 invoked by uid 991); 28 Nov 1997 22:52:38 -0000 Message-ID: <19971128225238.6504.qmail@finch.cse.psu.edu> Date: Fri, 28 Nov 1997 17:52:38 -0500 To: sam-fans@hawkwind.utcs.toronto.edu Subject: libXg font handling improvement Date: Fri, 28 Nov 1997 17:52:38 -0500 From: Scott Schwartz Hi, As you know, libXg looks for fonts based on a filename, normally given in your xdefaults file, containing a Plan 9 style font map. That works if and only if all your X clients have the same filesystem namespace. Normally, with local NFS, that's the case, but if you ever log into some remote machine and try to run sam or 9term, the fonts probably won't be where sam has been told to look. So this patch arranges to store the font map in the X resources database. Combined with using the x font server to hold the actual fonts, this makes things work fairly nicely, without recourse to the filesystem(s). In my xinitrc I run the following to set things up: name = (char *)malloc(strlen(name)+1); if (fnt->name==0) --- 42,75 ---- free(buf); return 0; } + return buf; + } ! Font * ! rdfontfile(char *name, int ldepth) ! { ! return rdfontstring(name, file2string(name), ldepth); ! } ! ! Font* ! rdfontstring(char *name, char *s, int ldepth) ! { ! Font *fnt; ! Cachesubf *c; ! int i; ! char *buf, *t; ! struct stat sbuf; ! unsigned long min, max; ! ! buf = s; ! if (buf == 0) ! return 0; fnt = (Font *)malloc(sizeof(Font)); ! if (fnt == 0) { ! Err1: ! free(buf); ! return 0; ! } memset((void*)fnt, 0, sizeof(Font)); fnt->name = (char *)malloc(strlen(name)+1); if (fnt->name==0) *** /tmp/T0a001XK Fri Nov 28 15:05:48 1997 --- libXg/xtbinit.c Thu Nov 20 19:52:10 1997 *************** *** 181,187 **** font = 0; subfont = 0; if (fontname) { ! font = rdfontfile(fontname, screen.ldepth); if (!font || charwidth(font, (Rune) ' ') == 0) { subfont = getsubfont(fontname); if (!subfont) --- 181,189 ---- font = 0; subfont = 0; if (fontname) { ! font = (fontname[0] == '.' || fontname[0] == '/') ! ? rdfontfile(fontname, screen.ldepth) ! : rdfontstring("p9font", fontname, screen.ldepth); if (!font || charwidth(font, (Rune) ' ') == 0) { subfont = getsubfont(fontname); if (!subfont) *** /tmp/T0a001XK Fri Nov 28 15:05:48 1997 --- include/libg.h Thu Nov 20 19:43:54 1997 *************** *** 203,208 **** --- 203,209 ---- extern int bitbltclip(void*); extern Subfont* getsubfont(char*); extern Font *rdfontfile(char*, int); + extern Font *rdfontstring(char*, char*, int); extern void ffree(Font*); extern Font *mkfont(Subfont*); extern void subffree(Subfont*);