sam-fans - fans of the sam editor
 help / color / mirror / Atom feed
From: Scott Schwartz <schwartz@finch.cse.psu.edu>
To: sam-fans@hawkwind.utcs.toronto.edu
Subject: libXg font handling improvement
Date: Fri, 28 Nov 1997 17:52:38 -0500	[thread overview]
Date: Fri, 28 Nov 1997 17:52:38 -0500	[thread overview]
Message-ID: <19971128225238.6504.qmail@finch.cse.psu.edu> (raw)

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*);


                 reply	other threads:[~1997-11-29  3:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19971128225238.6504.qmail@finch.cse.psu.edu \
    --to=schwartz@finch.cse.psu.edu \
    --cc=sam-fans@hawkwind.utcs.toronto.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).