Cyrprint
Constantine Gavrilov <const-g@optibase.com>
Cyrprint converts postscript files generated by Netscape or Mozilla. For Netscape, original pages must be in koi8 encoding. For Mozilla, original encoding can be any form of Cyrillic, since mozilla generates postscript files in unicode.
This program is used as a pass-through filter. It adds cyrillic fonts to the beginning of the file and substitutes font names in the original PS document. The substitution and addition of fonts can be controlled with styles.
A small mozprinthelp program is included for printing Mozilla generated files. The program uses iconv modules of glibc. It will convert unicode encoded postscript files to the desired encoding. It accepts just one argument - the target encoding, reading from standard input and writing to standard output. This program can be used to print Mozilla postcript files in other languages than cyrillic if you have suitable postcript fonts. Mozprinthelp is not enough by itself to convert a unicode encoded postscript file. One also has to substitute " unicodeshow" to " show" and, if necessary, substitute the font names and add the fonts. At the minimum, the conversion must do:
mozprinthelp target_encoding < somefile.ps | sed -e 's/ unicodeshow/ show/'
See the cyrptint script for additional information if you want to adapt to another language.
Cyrprint will probably not be useful for outputs generated by programs other than Netscape or Mozilla, since one needs to know what to substitute. But it can be used as an example.
The package includes cyrillic postcript fonts from ftp://ftp.kapella.gpi.ru/pub/cyrillic/psfonts. You are incouraged to look in that directory for additional solutions. The included fonts might not be the latest versions available (I downloaded them at least two years ago) but they work just fine for me.
Converted postscript files can be viewed with ghostscript or printed to a postscript printer. Ghostscript can print to other printers or convert to pdf. For best results, at least ghostscript version 6.51 is recommended. It has much improved postscript font renderer and pdf generator. With version 6.51, generated postscipt or pdf files dipslay with a quality that sometime is better than displayed with Acrobat Reader and, in general, is not worse.
- Usage
cyrnetprint [-st style] [filename] ##prints netscape generated file cyrprint [-st style] [filename] ##prints netscape generated file cyrmozprint [-st style] [filename] ##prints mozilla generated file
If you are printing a netscape generated file, run cyrprint as `cyrprint' or `cyrnetprint'. If you are printing a mozilla generated file, run cyrprint as `cyrmozprint' - the script will then run an additional unicode converter.
- Examples
-
- print command in Netscape can be specified as: `cyrnetprint|lpr'
- print command in Mozilla can be specified as: `cyrmozprint|lpr'
- print netscape.ps to a printer: `cyrnetprint netscape.ps|lpr' or
`cat netscape.ps|cyrnetprint|lpr'
- print mozilla.ps to a printer: `cyrmozprint mozilla.ps|lpr' or
`cat mozilla.ps|cyrmozprint|lpr'
- prepare a separate file for viewing or later printing:
`cynetrprint netscape.ps > out.ps'
- do the last using different fonts:
`cyrnetprint -st st1n netscape.ps > out.ps'
- last example for Mozilla generated file:
`cyrmozprint -st st1m mozilla.ps > out.ps'
What is a style?
Style is a file that may contain the following lines:
font1=string
font2=string
font3=string
font4=string
font5=string
font6=string
font7=string
font8=string
font9=string
font10=string
font11=string
font12=string
fontlist=string
Here, values for font1...font12 provide substitution names for the following fonts: Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic, Courier, Courier-Bold, Courier-Oblique, Courier-BoldOblique, Helvetica, Helvetica-Bold, Helvetica_Oblique, Helvetica-BoldOblique.
The value fontlist contains the space separted file names of the required fonts.
Any other lines are ignored.
The contributed Netscape styles are st0n, st1n, st2n, st3n. The contributed Mozilla styles are st0m, st1m, st2m, st3m, st4m, st5m. If you have more fonts or other preferences, you are welcolme to add styles.
Cyrprint program requires two environment variables. PRDIR specifies directory where the program will look for the fonts and styles. MOZPRINTHELP specifies the name (and the path) of the mozprinthelp program. Cyrprint uses default values that can be overidden by setting these environment varibales or by changing the default values in the script.
- Caveats
-
- The format of the style file changed from the previous version 1.0. It is more robust now and does not require specifying all font substitution values. Also, lines can be written in any order. If you created files for version 1.0, rewrite them in the new style.
- Mozilla currenly has a bug generating postscript files - it puts everything in proportional Times font even if the orinal document had fixed fonts. This is why the default mozilla style st0m substitutes Times-Roman and Times-Italic for cyrillic fixed Courier fonts. Times-Bold and Times-BoldItalic are substituted for Cyrillic Times fonts. This provides best results when printing books and documentation - headers, chapter names and titles are printed with prportional font and the main text with fixed font as in the original document. If you do not like this, or if your Mozilla version does not have this bug, use other Mozilla styles. The styles stm4 and stm5 substittute Times, Courier, and Helvetica fonts for Cyrilic Times, Courier and Arial variants.
- Another Mozilla printing bug - if your text is cut on the right side by 2-3 letters, use left margin of 0.2 inches when printing instead of default 0.5 inches.
