From: hull@acsu.buffalo.edu (Jon Hull)
Newsgroups: comp.windows.open-look
Subject: Re: ps->raster conversion under OW3.0?
Date: 14 Aug 92 12:37:51 GMT
Organization: State University of New York at Buffalo / CEDAR Research Group

Attached is the version of ps2bits that we have.
Our problem is that it doesn't render proportionally
spaced fonts like Times-Roman properly.
The horizontal spacing is all messed up.
Courier seems to work fine.  We haven't seen a seg fault problem.
A sample ps file is also attached.

Any advice on fixing this would be appreciated.
Thanks,
Jon Hull
hull@cs.buffalo.edu
====================
#! /bin/sh
# @(#)ps2bits 1.5.1 90/08/22
# ps2bits - PostScript to Rasterfile converter.
#

USAGE="Usage: `basename ${0}` [-in s] [-out s] [-dpi x y] [-size w h] [-gray | -color | -truecolor]"
OUT="pspage"
IN="%stdin"
DPIX=300
DPIY=300
XSIZE=8.5
YSIZE=11
DEPTH=1

export OPENWINHOME LD_LIBRARY_PATH FONTPATH
FONTPATH=$FONTPATH:$OPENWINHOME/lib/fonts
OPENWINHOME="${OPENWINHOME-/usr/openwin}"
LD_LIBRARY_PATH=${OPENWINHOME}/lib

if [ ! -f $OPENWINHOME/etc/NeWS/redbook.ps ]; then
    echo "`basename $0`: xnews is not installed correctly in $OPENWINHOME" 1>&2
    echo "	(set \$OPENWINHOME to where it is installed...)" 1>&2
    exit 1
fi

while [ ${#} -gt 0 ]; do
    case "${1}" in
	-truecolor)	shift;
		DEPTH=24
	;;
	-color)	shift;
		# Currently this gives a StaticGray colormap - I'm still
		# looking for a mechanism to get ahold of a StaticColor 
		# or PsuedoColor colormap when running -nodev
		DEPTH=8
	;;
	-gray)	shift;
		DEPTH=8
	;;
	-out)	shift;
		OUT=${1} shift
	;;
	-in)	shift;
		IN=${1} shift
	;;
	-size)	shift;
		XSIZE=${1} shift;
		YSIZE=${1} shift
	;;
	-dpi)	shift;
		DPIX=${1} shift;
		DPIY=${1} shift
	;;
	*)	echo ${USAGE};
		exit 0
	;;
    esac
done

$OPENWINHOME/bin/xnews -nodev -init "
    /beginpackage where {
	pop
	currentshared
	true setshared

	/NeWSops 50000 dict dup begin

	    /PackageType	1 def
	    /PackageName	/NeWSops def
	    /MajorVersion	3 def
	    /MinorVersion	0 def

	    initNeWSoperators
	    systemdict /initNeWSoperators undef

	    /random { rand -16 bitshift 16#7fff div } def

	    /FatalError { % string => (doesn't return)
		console exch writestring
		console flushfile
		shutdownserver
	    } def

	    /currentpacking false def
	    /setpacking { pop } def
	    (${OPENWINHOME}/etc/NeWS/basics.ps)   (r) file cvx exec
	    (${OPENWINHOME}/etc/NeWS/redbook.ps)  (r) file cvx exec
	    (${OPENWINHOME}/etc/NeWS/misc.ps)     (r) file cvx exec
	    (${OPENWINHOME}/etc/NeWS/statdict.ps) (r) file cvx exec
	end definepackage beginpackage
	setshared
    } if

    500 dict begin	% start userdict
	false setautobind
        true  setprintermatch
	/bind {} def

	/showpage { copypage erasepage initgraphics } def
	/_pageno 0 def
	/copypage {
	    /_pageno _pageno 1 add store
	    (${OUT}.)
	    _pageno 100 lt { (0) append } if
	    _pageno 10 lt { (0) append } if
	    _pageno 3 string cvs append
	    clippath writecanvas
	} def


	${DPIX} ${XSIZE} mul ${DPIY} ${YSIZE} mul ${DEPTH}
	[ ${DPIX} 72 div 0 0 ${DPIY} 72 div neg 0 7 index ]
	null buildimage setcanvas
	erasepage initgraphics

	(${IN}) (r) file cvx exec
    shutdownserver
"
=============================
%!PS-Adobe-1.0
%%CreationDate: Tue Aug 11 04:56:48 1992
%%Pages: (atend)
%%DocumentFonts: (atend)

/X{exch}def
/r{rmoveto}def
/m{moveto}def
/l{lineto}def
/rl{rlineto}def
/lc{yc X xc X l st}def
/mc{yc X xc X m}def
/el{gs /a X def a div 1 X scale cp np a xc 2 div 0 360 arc st gr}def
/ar{cp 7 2 roll np xc 5 1 roll atan 3 1 roll atan X arc st}def
/sp{yc X xc X 6 2 roll yc X xc X 6 2 roll yc X xc X 6 2 roll ct}def
/st{stroke}def
/gs{gsave}def
/gr{grestore}def
/cp{currentpoint}def
/np{newpath}def
/ct{curveto}def
/m0{0 0 moveto}def
/BP{/devps-save save def m0}def
/EP{
clear devps-save restore
showpage}def
/res 10.000000 def
/V{res neg div 792 add
currentpoint pop X
m}def
/H{res div
currentpoint X pop
moveto}def
/h{res div 0 r}def
/v{res neg div 0 X r}def
/xc{res div}def
/yc{res neg div 792 add}def
/S{X H show}def
/psize 10 def
/height 1 def
/slant 0 def
/FF{findfont X dup 12 div setlinewidth /psize X def
    [psize 0 psize height mul slant sin slant cos div mul psize height mul 0 0]
    makefont setfont}def
/shade{gs
 /dy X def
 /dx X def
 np m
 setgray
 0 dy rl
 dx 0 rl
 0 dy neg rl
 dx neg 0 rl
 closepath
 fill
gr}def
1 setlinecap
/R{/Times-Roman FF}def
%%EndProlog
10 R
%%Page: 1 1
BP
/slant 0 def
/height 1.000000 def
10 R
960 V
10 R
584(This)S
792(is)S
889(a)S
963(simple)S
1260(ditro)S
1449 H
	(f)show 10 -.5 mul h (f)show
10 R
1540(\256le)S
1698(that)S
1878(will)S
2064(demonstrate)S
2582(the)S
2734(horizontal)S
3169(spacing)S
3504(problem.)S
7920 V
EP
%%Trailer
%%DocumentFonts: Times-Roman
%%Pages: 1
Xref: sparky comp.windows.open-look:3437 comp.windows.x:15181