🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.next.programmer
Article #1521

Re: getting the path representation of a character to server stdout

#1521
From: Derek Clegg
Date: Thu, 15 Oct 1992 18:15
58 lines
2219 bytes
Sean Lamont writes
> I need to get the path associated with a character or string of
> characters in a given font to be output in a form that doesn't require
> the font to be loaded on the machine.
> I messed with pathforall, but it doesn't seem to work on a NeXT (none of
> my procedures ever get called) , and it also claims to not be able to
> work with "charpath".

I'm surprised that `pathforall' doesn't work for you -- perhaps your path was  
empty for some reason?  Anyway, I've appended a simple function to get the path  
for a character.  Copy it to a `.psw' file.  Here's an example of how to call  
it:
	int count, type[1024];
	float path_list[4096];
        get_charpath("A", sizeof(path_list), sizeof(type),
                     path_list, type, &count);

Using fixed size arrays is probably bogus; you may wish to worry about that.   
Also, I'd suggest fetching the path of one character at a time, rather than the  
path of an entire string.  (Otherwise, it's difficult to separate the  
characters, and there's a greater likelihood of overflowing your arrays.)

Derek
dclegg@NeXT.com

/* Get the character path of `s'.  Return the points in `path'; `n' is the
 * length of `path'.  Return the type of the points in `type'; `m' is the
 * length of `type'.  Return the total number of path elements in `count'.
 */
defineps get_charpath(char *s; int n, m
                      | float path[n]; int type[m]; int *count)
  currentpoint newpath moveto
  0
  (s) false charpath
  {
    0 type
    exch path path
    1 add
  }
  {
    1 type
    exch path path
    1 add
  }
  {
    2 type
    6 -2 roll exch path path
    4 -2 roll exch path path
    exch path path
    1 add
  }
  {
    3 type
    1 add
  }
  pathforall
  count
endps
Technical Details
Message-ID: <5438@rosie.NeXT.COM>
Path: arc1-ca.pugleaf.net!sparky!uunet!rosie!next.com
References: <1992Oct11.235306.12151@u.washington.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!rosie!next.com
From: derek_clegg@next.com (Derek Clegg)
Newsgroups: comp.sys.next.programmer
Subject: Re: getting the path representation of a character to server stdout
Keywords: charpath, pathforall
Message-ID: <5438@rosie.NeXT.COM>
Date: 15 Oct 92 18:15:07 GMT
References: <1992Oct11.235306.12151@u.washington.edu>
Sender: news@NeXT.COM
Reply-To: derek_clegg@next.com
Lines: 58