🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #226

help: using NeWS to convert ps to a bitmap

#226
From: Jon Hull
Date: Fri, 07 Aug 1992 16:51
141 lines
3912 bytes
A version of the ps2bits script is attached.
The intended use of this script is to 
convert a postscript version of a document 
into a sunraster image.  This works great when
a Courier font is used.  However, when Times-Roman
is used, the horizontal spacing in the output 
image is erratic.  Some characters come out fine
but others overlap, either partially or totally,
the preceding character.  Vertical spacing is perfect.

As I am only casually familiar with postscript
and totally unfamiliar with news, any
advice you could offer would be greatly appreciated.
Even just a pointer in a good direction 
would be useful.

Printer matching has been investigated but doesn't
seem to be the problem.

Thanks,
Jon Hull
hull@cs.buffalo.edu
716-636-3195 (voice)
716-636-3966 (fax)
================
#! /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
OPENWINHOME="${OPENWINHOME-/usr/openwin}"
OPENWINHOME=/util/newsprint/small_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
	/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
"
Technical Details
Message-ID: <BsMHH5.JtI@acsu.buffalo.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!rutgers!ub!acsu.buffalo.edu!usenet

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!rutgers!ub!acsu.buffalo.edu!usenet
From: hull@acsu.buffalo.edu (Jon Hull)
Newsgroups: comp.lang.postscript
Subject: help: using NeWS to convert ps to a bitmap
Message-ID: <BsMHH5.JtI@acsu.buffalo.edu>
Date: 7 Aug 92 16:51:04 GMT
Sender: nntp@acsu.buffalo.edu
Organization: State University of New York at Buffalo / CEDAR Research Group
Lines: 141
Nntp-Posting-Host: antares.cs.buffalo.edu