Qs: Quikscript

What is Quikscript?

Qs (Quikscript) is a PostScript text formatting and typesetting program. It enables documents to be prepared on any type of hardware, using visible layout marks to control the appearance of the output, and produce output on a PostScript printer by dispatching Qs and the document file to the device. No processing is performed by the host hardware; all processing is done within the printer.

The advantage that Quikscript provides, other than portability, is precision of control over output. Because it is written in PostScript, it is interpreted at run-time within the printer. It is possible to create documents that modify the Quikscript program during execution. It is very easy to include other PostScript programs or fragments with Quikscript. It is possible to use special PostScript fonts, such as hand-generated ones. Graphics generated from a variety of sources can be easily included, as can text output from computer programs. It is possible to embed Quikscript within a document, such as an advertisement or an itemized account produced from a database query.

To use Quikscript, create a file containing text and visible layout marks as described in the user manual. Create a temporary file containing Qs and your text, and send this to a PostScript printer. If you do not have a PostScript printer, you can process the temporary file using a PostScript previewer such as ghostscript or gsview, which can convert it to be printed by almost any other type of printer.

What is Qse?

Qse is the Quikscript editor. Quikscript can be used without installing Qse, but it requires the use of operating-system commands to perform the operations.

Where are Qs and Qse found?

Quikscript is a remarkably short PostScript program. It is described in a manual in PDF format and in Quikscript, which can be easily printed when Qs is installed. There are other PostScript fragments that are useful with it, and a couple of C programs, all of which are described in the next section. They are all packaged into a tar file or a zip file. They are available individually in the qsdir directory.

The Quikscript editor Qse is written in Java, and its executable class files are combined into a single Jar file, along with Quikscript, the PostScript fragments and other text files. Qse is distributed as a self-installing executable:

 Unix shell scriptMS executable
Full editor, including additional font files (~4.8 Mb) Qse-install.bin Qse.exe
Editor without additional font files (~1 Mb) Qse-smallinstall.bin smallQse.exe

If you need to make changes to Quikscript, there is a brief description of how Quikscript works.

What are the individual files?

The following files are provided in the Qse.jar file, Quikscript.tar.gz, Quikscript.zip, and individually in the qsdir directory:
Qs
Quikscript program (PostScript)

qsuser.pdf
The user manual.

rotate.qs
The PostScript program to modify Quikscript to rotate every page so that output is in landscape format rather than portrait format.

draft.qs
The PostScript program to modify Quikscript so that each page will be drawn with the word "DRAFT" added in large shadow letters across the page.

border.qs
Example PostScript routine to modify Quikscript adding a border to each page.

pdffnt.qs
The PostScript program to modify the character encodings of the standard PostScript fonts so that western European characters are available using the correct ISO character codes. This differs from the standard ISOLatin1Encoding in that typesetting characters like ellipsis, trademark, florin, dagger, bullet which are not included in the ISO set are also provided.

isolatin2.qs
The PostScript program to modify the character encodings of the standard PostScript fonts so that they use an ISO-Latin-2 encoding vector. Composite characters are created from the accent marks and the base characters.

celtic2.qs
A PostScript program to modify the character encodings so that Celtic characters can be drawn. Contributed by Derek McKay, and modified by G. Freeman.

outlinft.qs
The PostScript program to set up a Helvetica font which draws characters in an outline form.

smallcap.qs
The PostScript program to set up a version of the current font with lower case letters drawn as small capitals.

dijkstra.qs
A cute font imitating a person's handwriting, good for hand-written correspondence that you can type at the keyboard!

altpagnm.qs
The PostScript routine to change the Quikscript behaviour to alternate page numbering from left to right side of page.

cntpagnm.qs
The PostScript routine to change the position of page numbers so that they will be centred at the top of the page.

2col.qs, 3col.qs
Print the document on a landscape page in two or three columns, suitable for producing a simple leaflet.

2colleaf.qs
Print the document in two columns suitable for folding as a simple leaflet. The paper will need to be trimmed at the trim marks.

3narrowcols.qs
Print the document on a portrait page in three narrow columns, using Courier font and No-Fill mode, printing the text exactly as it is in the file.

2p.qs, 2pend
Print the document two pages per sheet, side-by-side. File "2pend" should be concatenated to the end of the document to ensure that nothing is missing from the last page.

macros.qs
Example of how macros can be used with catex or catm. This example shows how to set up a structured document containing sections, dot-lists, and hanging first line lists which can be embedded.

ps_europe_subs
Character replacements in converting a Quikscript document into HTML if the European font is used.

ps_std_subs
Character replacements in converting a Quikscript document into HTML if a standard PostScript font is used.

The following files are not part of Qse.jar. They are available only in Quikscript.tar.gz, Quikscript.zip or in the qsdir directory.

epstopnm
A Unix script for converting an EPS file into a PNM image. This is most useful as a step in handling illustrations when a Quikscript document is to be converted into HTML. It relies on ghostscript being available to do the work.

epstogif
A Unix script for converting an EPS file into a GIF image. It uses epstopnm, and relies on ghostscript and pbmplus or netpbm being installed.

catex.c
A version of the UNIX "cat" command that concatenates several files into one and writes it to standard output. This version examines the content of every file, looking for the string "%include file-name%". The file ("file-name" in this example) will be included at the point it is referred to. This file may itself have references to other files which must be included. The file-name is interpreted as a path relative to the path of the file which referred to it, so will be in the same directory unless it is given as an absolute path (beginning with '/') or begins with '../', which will be interpreted in the UNIX fashion.

This is a useful tool with Quikscript since it removes the necessity for including the above PostScript pieces explicitly in every document that uses them. It also enables PostScript drawing instructions for externally prepared diagrams to be held as separate files, rather than being embedded within the document where they will ultimately appear. If the included file is modified, the whole document will automatically reflect the change when next printed.

This functionality is embedded in Qse.

catm.c
An embellishment of "catex.c", incorporating the same functionality, but intended to be used for file merging. The first file argument is a "fields" file, defining a series of values of field names to be used when "catm" repeatedly copies the remaining files to standard output. The main use of this program is in producing a series of letters or similar documents with individual names, addresses, and such fields.

This functionality is embedded in Qse.

notab.c
A simple filter program to replace tabs with a sensible amount of white space.

qsmodify.qs, qsmodify.html
A specification of how Quikscript works, for people wanting to make changes or add new features.


Recent change history

April 2008 (current) release

Qs
The 2006 release of Quikscript included a feature to cope with a flaw in the Unix spooling software CUPS. Those modifications fixed most of the problems caused by CUPS, but did not handle the situation where there was no end-of-line character at the end of file. In this case, the last page of the document was still corrupted by CUPS. This has now been fixed. A consequence of this change is that any document which includes the text %%EndDocument at the end of a line will now terminate at that point, regardless of whether it is printing on a Unix system or not. This is most unfortunate, but as this text is most unlikely to be found in normal documents, I hope that we can live with this.

Searching for a font name match previously only considered the leading characters, rather than requiring a full abbreviated name match (eg. Wng and Wng2 could be equivalent).

Qse
Specification of the special character selector has been changed to allow it to be extended to other fonts more easily.

In the documentation, the CA tag has previously been omitted.

23 February 2007 release

Qs
Qs now has modified internal processing of the top-of-column decision associated with %NP%. This corrects a bug whereby a %NP% when at the top of the second or later column will be ignored or will cause following text to be printed over the top of existing text.

Coloured background in a table where there is a change in font size between cells could lead to the lower part of some text being obliterated by the background colour. This has been partly fixed.

isolatin2.qs
This file is now included in the Qs distribution, enabling characters in Czech, Hungarian, Polish, and other Eastern European languages to be used.
celtic2.qs
This file in the Qs distribution has been revised so that documents using it can be distilled with "distillery".
distillery
Distillery has been changed to handle Type 3 fonts which use "show" or "charpath" operators in a BuildChar procedure. Previously, these could cause an infinite loop which resulted in distillery crashing.
Qse
Iso-Latin-2 is offered as an alternative encoding in the menu.

When switching from two-pages per sheet to one, the short file that had been included at the end to force output of the final page is not correctly removed.

6 December 2006 release

Qs
A change to the end-of-document processing has been introduced to cope with a flaw in the Unix spooling software, CUPS. Releases of CUPS since version 1.2.0 add the text %%EndDocument and %%EOF to the end of the document being sent to the printer. With earlier versions of Qs, this will corrupt the final page of output. Qs now checks each line of input, and if %%EndDocument is found, it treats this as the end of the input to be processed.
catex and catm
There was a flaw in both of these programs, if a long line was read. They used a fixed size buffer which would not allow %include, %DM or %M codes to be recognized if they spanned a buffer boundary. This has been replaced with a variably sized buffer which expands as required to deal with whatever input is found.
Qse
The editor has had its installation procedure greatly improved in both Unix and Microsoft Windows.

Printing problems where Duplex is not supported have been fixed.

Previously, closing all windows could sometimes leave Qse running in a useless state.

Mail-merge now allows field names to be included in quote marks, and if this occurs, the field values will have the corresponding quote marks removed before insertion into the generated document.

Windings fonts have been made available, courtesy of Microsoft.

14 October 2005 release

Qs
Unchanged, except that it is no longer restricted to non-commercial use.
Qse
  1. Numerous changes have been made to the installation procedures to make them robust and to reduce the need for hand-editing of files.
  2. The Euro symbol is now supported with three special fonts and a menu item.
  3. Mail-merge has been revised to make it more robust. The end-of-document separator can now be specified directly through the user-interface. The fields file can have the field names as the first line, removing the need for these names to be given in a separate file. File names containing spaces can be tolerated if they are surrounded by quote marks.
  4. The format of dates as produced from %DATE% can now be specified by the user.
  5. Access to a printer is simplified if Java 1.5 is available, with selection from a menu rather than by command.
  6. Saving files which use the European or Celtic font encoding will no longer cause the "%include" at the top of the document to be inexplicably removed.
  7. The file selector no longer behaves as if some mouse clicks were duplicated.
  8. The appearance of buttons in the user-interface is improved with a gradient-shaded background.


22 March 2005

Qs
  1. A bug in processing text containing %\% within a %NF% block has been fixed.

22 October 2004 release

Qs
  1. Text colour is handled more robustly. Previously, text colour could change when crossing a page boundary.
  2. Page margins modified in a multi-column document are handled correctly now.
  3. If the %PF instruction is used to change paragraph layout within a paragraph, it will take effect where the instruction is placed rather than possibly affecting preceding text.
  4. If Qs is embedded within a PostScript document, it now leaves the stack uncorrupted before terminating.
  5. A blank page is no longer generated at the end of a restricted set of pages.
Qse
  1. A new file selector has been provided giving single-click operation and enabling patterns in file names to be used.
  2. An option to allow word wrapping at the window edge has been added.
  3. Mnemonics and accelerators have been added to the menu system.
  4. Font or format selection behaviour has been tidied up, when clearing a window and when saving a file.
  5. Mail-merge now accepts a fields file containing the names of the fields on the first line, and field values on subsequent lines.
  6. Printing directly to a PostScript printer rather than through a system command is now possible if Java 1.5 or later is installed. The option of Duplex printing has been added.
catm.c
  1. Catm has been modified to take a single fields file generated from a spreadsheet, with the field names on the first line, and the field values on subsequent lines.

10 February 2003 release

Qs
  1. The EPSstart and EPSend procedures for use with embedded EPS files have been modified to allow dirty EPS files (which leave junk on the stack) to be handled.
  2. The %PM instruction with a trailing comma is now handled correctly.
  3. The %ST instruction to start a table now recognizes a trailing comma in the list of column positions to mean the right margin of the page.
  4. If the left and right margins of a background-shaded area are set, this will no longer affect the default margins for other shaded areas.
catex.exe
  1. The Micro$oft binary of the catex.c program has been brought up to date.

13 December 2002 release

Qs
  1. The layout marks %FN% to undo the most recent font change, %SZ% or %SN% to undo the most recent size change, are now handled a little differently from previous versions. A short history of changes is maintained, allowing progressive undo rather than a single level (or toggle) undo.

    This change makes it easier to modify a document, inserting at some point in the document a character or short piece of text from another font or with a different size, and revert to the previous style without needing to know what that style was, confident that the surrounding context will not be affected by the change.

    If there has been only one change, or if the history of changes is exhausted, repeating one of these undo instructions will swap between the two most recent states, the original behaviour.

    This changed behaviour may have consequences for some documents written assuming the former behaviour. The change can be disabled in Quikscript if desired by uncommenting a line near the top of Qs

    %/ToggleFont true def
    
    (remove the leading %). This will allow Qs to retain its previous behaviour. This change cannot be made dynamically (with embedded layout marks in a document), as the state of ToggleFont is required in initializing Qs.
  2. A procedure AddFont has been added to Qs, making it easier to add a new font into those available within a document. A synonym for the new font can be defined, rather than using the Uft which was provided formerly and which required knowing the precise positions in the Font table in which to insert the new font names.
  3. A bug associated with tables which span a page end has been fixed.
  4. A bug associated with multi-column output and %TB indentation when spanning a page boundary has been fixed.
  5. When %SI%...%EI% are used to add an item to the index, the case of the text is now ignored in the internal sorting mechanism. This will eliminate duplication in an index where the same word is used, in some places with a leading capital letter and others with lower-case.
  6. In situations where an index item was specified at the end of an input line, the output text could have omitted the space between words. This has now been rectified.
Qse
  1. Major changes have been made to the interface to improve the robustness and portability of this Java program.
QsToHTML
  1. A lot of work has been done to this program in an attempt to have the resulting HTML conform to 4.01 specifications, rather than relying on how it looks in a particular browser. It is not guaranteed to be perfect yet, as the rules on which tags can be placed within others are not straightforward and are difficult to map to from the more liberal Qs layout rules.
catm
  1. It is now possible to specify on the command-line the character which will separate the field values, rather than requiring it to be the Tab character.

2 January 2001 release

Qs
  1. Background colour can now be specified for a block of text with the new %BG layout marker
  2. Colour of text can be specified with %TC
  3. Background colour in a column of a table can now be specified (%BC).
  4. EPSstart / EPSend procedures have been added to simplify including EPS files.
  5. Bug in PrPagNum caused the first line of some pages to be too long.
pdffnt.qs
  1. European characters in fonts other than Times are now handled correctly.
Qse
  1. Bug in shift_left shift_right action procedures has been fixed.
  2. Expand files / preview or print now checks the entire file list for Qs
  3. Some fields respond now to Enter as equivalent to clicking on a button
  4. Unreliability of some windows with Java 1.2/1.3 on Linux is now improved.
  5. qse script now works on platforms other than Linux.
catm
  1. A bug with skipping trailing blanks from field names has been fixed.

4 November 1999 release

Qs
  1. fix a bug in the interaction between %TB and multiple columns
  2. fix a bug with an incorrect right margin in a rare situation
  3. fix a bug with %LP that allowed text to be placed beyond the right margin
  4. allow font size to change in a table without causing problems with vertical lines

QstoHTML

catm, mail-merge feature
  1. allow field replacement to call other fields, macros, or include files (recursive)
  2. allow field names to be provided in a separate file from the values
  3. allow tab separator between fields as an alternative to \n

userdoc.qs, qsuser.pdf

Qse

Celtic font

8 July 1998 release

This release of Quikscript provides several new features, which have required a revision of the internal mechanism used by Quikscript to process its input. The opportunity has also been taken to reorganize the variable initialization at the head of the file to order them alphabetically. Although the changes have been major, it is hoped that existing documents will not need to be modified to print with the new version. Only in cases where you have embedded PostScript in your document may you be at slight risk, as outlined below.

New features

%SI%...%EI%
Text can be indicated for inclusion in an index. %SI% indicates that the following text is to be recorded, and %EI% marks the end of an index item. Between these tags can be placed any text, also including layout marks which are not acted upon at this stage but held over till when the index is to be output. Current page number and possibly chapter abbreviation is recorded with the text.

%SC%...%EC%
Text can be indicated for inclusion in a table of contents. %SC% indicates that the following text is to be recorded instead of being output immediately, and %EC% marks the end of recording of contents text. Between these tags can be placed any text, also including layout marks which are not acted upon at this stage but held over till when the index is to be output. Current page number and possibly chapter abbreviation is recorded with the text.

%CA,text%
The text will be used along with page number in any index or contents item. Eg. %CA,1-% would mean pages would be represented as 1-1, 1-2, etc.

%PC%
Print the table of contents on the current page. The pages will then need to be shuffled to put it in sensible sequence with the remainder of the document.

%OC%
Output the table of contents to the output stream rather than to the printed page. The output stream might be the window in which the PostScript interpreter is being run, or it might be the serial line connecting the PostScript printer to a computer. This would be used if a document was held in several files, and the contents of each section (file) would need to be separately generated and joined into a single table by hand.

%PI%
Print the index.

%OI%
Output the index to the output stream rather than the printed page. This would be done if the index were being generated in several parts from separate chapters, which would need to be merged before being printed. It might also be wanted if the simple sorting done by Quikscript was unsatisfactory.

%SH%...%EH%
The text between the marks is to be used as page header text, to be placed beside the page number (if pages are to be numbered). This text can include layout marks, which will only be acted upon when the text is printed at the page top.

Changes

%SF% %EF%
These layout marks are reserved for possible future use, implementing footnotes.

qsmodify.qs
In order to implement the new tags, the internal mechanism for processing text has had to be revised. This has meant changing the item in the Kwrd table which previously was a boolean, replacing it with a numeric item to indicate the status of each keyword.

If you have added your own keywords to this table, you will need to read carefully the description of how Quikscript now works. The mechanism is formally documented in qsmodify.qs

Embedded PostScript
The Guide to Quikscript in the past has described how to add PostScript instructions to the text of a document, in particular for setting the page header text to appear beside the page number. With the new keywords (%SH% %EH%) the PostScript procedure (PrPagNum) for dealing with page numbering has had to be changed. This has been done in such a way that, if you have provided your own PrPagNum in some documents, you should not be disadvantaged. You should be aware of the new procedure, and in future use the new design. There is now a simpler mechanism for setting the page header text, and the font used for the header is selected differently.

Font, FontNam
These internal Quikscript tables now have extra entries for specifying your own fonts, with provision for three families instead of the previous two.

Code reorganization
The definitions of internal variables have been reordered to make them easier to find. Also, the table of keywords with associated procedures has been moved close to the top of the file. If you have made your own changes to Quikscript, you will need to search more widely to find the equivalent code if you wish to merge your changes into the new Quikscript.

Quikscript has always been free for personal use, with a licence available from the author for commercial use. Since the October 2005 release, it may now be used freely by anyone. No payment is expected, and although every effort has been made to remove errors, no legal liability is taken for any loss or damage that may be incurred from its use.

Graham Freeman
g-freeman@adfa.edu.au
14 October 2005