Extract a character path? 
Author Message
 Extract a character path?

Greetings,

I am trying to write a text raytracer with Renderman in my (copious) free time.  
Seeing as though Renderman doesn't know about text, I need to convert character  
paths from postscript to something Renderman will understand, which looks like  
a bunch of Bezier patches/meshes.

So... How does one get character paths out of Postscript?  I've looked at  
charpath, which supposedly pushes the path for the string on the stack, but I  
do not know how to extract the path from the stack in the form of many bezier  
curves that I can use.

How does one do this?

Many thanks in advance,

Brian Hobbs
Pencom Software



Mon, 04 Dec 1995 22:47:14 GMT  
 Extract a character path?

: So... How does one get character paths out of Postscript?  I've looked at  
: charpath, which supposedly pushes the path for the string on the stack, but I  
: do not know how to extract the path from the stack in the form of many bezier  
: curves that I can use.

: How does one do this?

I believe charpath leaves the path not on the stack, but in the current
path (appropriately enough :-).  You may try the operator "pathforall"
to elaborate that path.  Be warned, however, that proprietary fonts
exploit a copy-protection feature that disables pathforall.



Tue, 05 Dec 1995 10:31:58 GMT  
 Extract a character path?

|>
|>Greetings,
|>
|>I am trying to write a text raytracer with Renderman in my (copious) free time.  
|>Seeing as though Renderman doesn't know about text, I need to convert character  
|>paths from Postscript to something Renderman will understand, which looks like  
|>a bunch of Bezier patches/meshes.
|>
|>So... How does one get character paths out of Postscript?  I've looked at  
|>charpath, which supposedly pushes the path for the string on the stack, but I  
|>do not know how to extract the path from the stack in the form of many bezier  
|>curves that I can use.
|>
|>How does one do this?
|>

MY solution:
---------------------------------------------------
%!
% upath.ps
% Create a outline list of a font
%

% if writesystemdict is allowed :)

% /printfilename (Times-Roman.pp) def

/ofile false def

/beginfile { /pfile printfilename (w) file def /ofile true def } bind def

/endfile { pfile closefile /ofile false def } bind def

/p {
   ofile
   { pfile exch writestring }
   { print }
   ifelse

Quote:
} bind def

/scratch 255 string def

/cc 1 string def

/pnum { ( ) p
% round
% cvi
 scratch cvs p } bind def

/NL { (\012) p } def

/pm { (m) p exch pnum pnum NL } bind def

/pl { (l) p exch pnum pnum NL } bind def

/pc { (u) p 6 4 roll exch pnum pnum 4 2 roll exch pnum pnum exch
      pnum pnum NL } bind def

/pp { (c) p NL } def

/ppforall {
   {pm}{pl}{pc}{pp} pathforall

Quote:
} bind def

/pchar {
   newpath 0 0 moveto true charpath
%   flattenpath
   ppforall

Quote:
} bind def

/oldpfont {
   (% File created by ABPSoft PS2Outline) p NL
   (f ) p dup scratch cvs p NL
   findfont 1000 scalefont setfont
   0 1 255 {
      /i exch def
      ofile { i scratch cvs print (\015) print } if
      (b) p i pnum NL
      cc 0 i put cc pchar
      (e) p NL
   } for

Quote:
} def

/pfont {
   % This version has to modify the encoding vector of the font
   % Because not every StandardEncoding is writeable (GhostScript)
   % and not every Interpreter allows writes to the systemdict, we workaround
   % this with a copy of the font
   % Save the current vm status
   save exch
   (%P01 File created by ABPSoft PS2Outline) p NL
   (f ") p dup scratch cvs p (") p NL
   % make a writeable copy of the encoding vector
   /encoding StandardEncoding 256 array copy def
   % make up a copy of the font ...
   findfont /font exch def
   /newfont font maxlength dict def
   font { exch dup /FID ne {exch newfont 3 1 roll put}{pop pop}ifelse} forall
   % give him the writeable encoding
   newfont /Encoding encoding put
   % and enter it into the fontdirectory
   /temporary-font newfont definefont 1000 scalefont setfont
   currentfont /CharStrings get {
      % we can only read the names in the CharStrings dict
      % so trash the values
      pop
      % enter this typeface name into Encoding[0]
      dup encoding exch 0 exch put
      % write out the name
      (b ") p scratch cvs p (") p NL
      % and ppforall character 0
      (\000) pchar
      (e) p NL
   } forall
   % remove all our trash
   restore
Quote:
} bind def

--------------------------------------------------------------

Call it f.i.:

--------------------------------------------------------------
%!
% analyze all the following fonts and produce .pp files of them
%

(upath.ps) run

/writefont {beginfile pfont endfile} bind def
/into {/printfilename exch def} bind def

/Times-Roman            (Times-Roman.pp)                into writefont
% /Times-Bold           (Times-Bold.pp)                 into writefont
% /Times-Italic         (Times-Italic.pp)               into writefont

[...]
---------------------------------------------------------------

But, of course, be sure to NOT conflict with the license agreement with
your font vendor. I.e., don't resell this results, use them only for your
own purpose.

Run this conversion with Ghostscript >= 2.6 or the Amiga post library

--
+-o-+--------------------------------------------------------------+-o-+
| o |                \\\-  Brain Inside -///                       | o |
| o |                    ^^^^^^^^^^^^^^^                           | o |

+-o-+--------------------------------------------------------------+-o-+



Tue, 05 Dec 1995 21:00:57 GMT  
 Extract a character path?
  If you have a Type 1 font on disk as a .PFB or .PFA file, you can
convert all the outlines in the font to regular, unencrypted,
postscript code (with (r)curveto instead of rrcurveto, etc.)  with the
UNTYPE1 program written by nsomebody at DEC; since no postscript
interpreter is involved, all protections are ignored.  This program is
{*filter*} around somewhere on the net; ask archie.
--



Tue, 05 Dec 1995 22:56:06 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Extract Files Full Path

2. Extracting ASCII code from Characters

3. Extracting the last N characters of a string

4. Incorrect characters with PATH on Postscript printer

5. Retrieving a font character path

6. Clipping to path enclosed by character ?

7. getting the path representation of a character to server stdout

8. Converting logical paths to UNC paths

9. Long Path Names give Runtime error 76 - Path not found

10. Paths -- Creating File Path with several levels -- VBScript

11. Converting logical paths to UNC paths

12. Adding path to Path entry

 

 
Powered by phpBB® Forum Software