% Copyright (C) 1991 Aladdin Enterprises. All rights reserved.
% Distributed by Free Software Foundation, Inc.
% This file is part of Ghostscript.
% Ghostscript is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
% to anyone for the consequences of using it or for whether it serves any
% particular purpose or works at all, unless he says so in writing. Refer
% to the Ghostscript General Public License for full details.
% Everyone is granted permission to copy, modify and redistribute
% Ghostscript, but only under the conditions described in the Ghostscript
% General Public License. A copy of this license is supposed to have been
% given to you along with Ghostscript so you can know your rights and
% responsibilities. It should be in a file named COPYING. Among other
% things, the copyright notice and this notice must be preserved on all
% Extract the ASCII text from a PostScript file. Nothing is displayed.
% Instead, lines are written to stdout as follows:
% F <height> - indicate font height
% S <x> <y> (<string>) - display a string
% <height> is an integer expressed in device pixels.
% <x> and <y> are integer device coordinates. <string> is a string
% represented with the standard PostScript escape conventions.
% The idea is similar to Glenn Reid's `distillery', only a lot more
% simple-minded, and less robust.
% Note that this code will only work properly if systemdict is writable.
% For this reason, it is normally read in by gs_init.ps before
% systemdict is made read-only.
systemdict wcheck { systemdict } { userdict } ifelse begin
% Disable the display operators.
% Image and imagemask must read the input, but do nothing.
/image { gsave nulldevice //image grestore } odef
/imagemask { gsave nulldevice //imagemask grestore } odef
% Redefine the end-of-page operators.
/copypage { (P\n) //print } odef
/showpage { copypage erasepage } odef
{ 0 currentfont /FontBBox get dup 3 get exch 1 get sub
currentfont /FontMatrix get dtransform dtransform
exch abs exch abs max round
(F ) //print //.stdout exch write==only (\n) //print
{ gsave //.show.ident setmatrix
(S ) //print currentpoint
exch round dup //.stdout exch write==only ( ) //print
exch round dup //.stdout exch write==only ( ) //print
moveto dup //.stdout exch write==only (\n) //print
grestore stringwidth rmoveto
% Redefine the other string display operators in terms of `show'.
/.show1 { ( ) dup 0 3 index put exch pop .showstring } odef
{ .show1 2 copy rmoveto } forall
exch neg exch neg rmoveto
{ 2 copy .show1 eq { 1 index 1 index rmoveto } if } forall
{ dup .show1 3 index eq { 4 index 4 index rmoveto } if
exch neg exch neg rmoveto
{ .show1 dup exec } forall pop
% Redirect the printing operators.
/.stdout (_temp_.out) (w) file def
/.stderr (_temp_.err) (w) file def
/print { //.stdout exch writestring } odef