sam-fans - fans of the sam editor
 help / color / mirror / Atom feed
* libXg font handling improvement
@ 1997-11-28 22:52 Scott Schwartz
  0 siblings, 0 replies; only message in thread
From: Scott Schwartz @ 1997-11-28 22:52 UTC (permalink / raw)
  To: sam-fans

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:

<unicode.9.font {
  printf '*p9font: '; sed -e 's/$/ \\n\\/'; printf '\n'
} | xrdb -merge

xrdb '+fp' tcp/fontserver:7100	# or 'fp='

(Using the font serever also fixes a JDK1.1 bug which gives the Java
AWT runtime system bus errors if you have the temerity to use a
non-Openwin X server with Sun's "run anywhere" technology.)

*** /tmp/T0a001XK	Fri Nov 28 15:05:48 1997
--- libXg/rdfontfile.c	Fri Nov 28 15:05:27 1997
***************
*** 13,27 ****
  	return s;
  }
  
! Font *
! rdfontfile(char *name, int ldepth)
  {
! 	Font *fnt;
! 	Cachesubf *c;
! 	int fd, i;
! 	char *buf, *s, *t;
  	struct stat sbuf;
! 	unsigned long min, max;
  
  	fd = open(name, O_RDONLY);
  	if (fd < 0)
--- 13,25 ----
  	return s;
  }
  
! char *
! file2string(char* name)
  {
! 	int fd;
  	struct stat sbuf;
! 	char *buf;
! 	int i;
  
  	fd = open(name, O_RDONLY);
  	if (fd < 0)
***************
*** 44,54 ****
  		free(buf);
  		return 0;
  	}
  
! 	s = buf;
  	fnt = (Font *)malloc(sizeof(Font));
! 	if (fnt == 0)
! 		goto Err1;
  	memset((void*)fnt, 0, sizeof(Font));
  	fnt->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*);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-11-29  3:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-11-28 22:52 libXg font handling improvement Scott Schwartz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).