🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.news
Article #408

ps2bits fix

#408
From: Don Hopkins
Date: Fri, 14 Aug 1992 21:13
154 lines
4580 bytes
> From: lwv26@cas.org (Larry W. Virden, x2487)
>
> Recently several folks have mentioned the ps2bits script, which uses OW to
> create Sun raster files.  This script works for monospace fonts like Courier
> but has horizontal spacing problems for fonts like Times-Roman.  Would one
> of you kind people be willing to take a look at the small bit of NeWS code
> and see what it is in the script which is causing the problem?  I can forward
> along another copy of the most recent version of the script to anyone
> willing to take a look at it.

> From: hull@cs.Buffalo.EDU (Jon Hull)
>
> [...] they know what the bug is and it is not in the news server but
> in the ps2bits script itself.  He also said that they aren't
> supposed to say how to fix the bug because of some problem with the
> TypeScalar license.

I looked into the problem and found a fix.  Add the following lines to
ps2bits, right before the line that says "end definepackage
beginpackage".  By the way, this is for educational purposes only,
don't actually *use* it, because certain managers at Sun don't want
you to get the most out of OpenWindows, and you might hurt their
feelings.

	-Don

	    /filepathparse {
		[ exch (:) { search { 3 1 roll } { exit } ifelse } loop ]
	    } def
	    (${OPENWINHOME}/etc/NeWS/loadmaps.ps) (r) file cvx exec

Oh hell, here's the whole fixed ps2bits script, in case you don't have it.

#! /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/xnews}"
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
	    /filepathparse {
		[ exch (:) { search { 3 1 roll } { exit } ifelse } loop ]
	    } def
	    (${OPENWINHOME}/etc/NeWS/loadmaps.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: <HOPKINS.92Aug14221309@delta9.turing.ac.uk>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!turing!coulin!hopkins

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!turing!coulin!hopkins
From: hopkins@turing.ac.uk (Don Hopkins)
Newsgroups: comp.windows.news,comp.lang.postscript,comp.sys.sun.apps
Subject: ps2bits fix
Message-ID: <HOPKINS.92Aug14221309@delta9.turing.ac.uk>
Date: 14 Aug 92 21:13:09 GMT
Sender: usenet@turing.ac.uk (Usenet for nntp)
Organization: The Turing Institute, Ltd.
Lines: 154