HOME



FONTS

I had chosen to use the vary basic fonts; Times-Roman and Times-Italic. I Thought that when I was using this fonts I would not have to bater about fonts. The program would automatic use the build-in fonts. I found out that it was not going to be that simple. The problem came in with my languish, Danish. I use the special Danish characters , , , , , . This letters, I found out, have names in PostScript. They are called AE, Oslach, Aring, ae, oslach, aring. and they do not display just by taping the keyboard key as it does in a plain text document. (If your keyboard is set up for it) The AE, ae and the Oslach, oslach was not so difficult to find out about. In Appendix E in the PostScript Language Reference Manual (PLRM) (You can find it online with google.) is a overview of keys and encodings for the Adobe Standard Latin Character Set. Here I cold see the encodings for this characters:

= \341

= \351

= \361

= \371

But the Aring and the aring was marked with a "-" which means that this character is UN-encoded. I did not understand what to do with this until I got some hint from person who was helping me and with that hint I was able to find a Journal on the Internet, dialing with exactly this problem. It is a very good and pedagogical Journal and it is only 10 pages with little text on each page. If you use special characters like in French, Norwegian, Swedish, German, Danish etc. You can use the instructions in this Journal. Go to the URL

http://www.acumentraining.com/AcumenJournal.html

Scroll down to the November 2001 Journal. Download the zip file. Unpack it (use unzip or pkunzip or winzip or mc->F2 etc. ) It contains a PDF that you can view with 'gv' or an other PDF viewer. The PDF document contains two lessens it is the second of the two and it starts on page 16. The heading is "Reencoding Fonts, Part 1. Basically you use the PostScript name of the character to re-encode it. Here is the programming example that they use in the article. They use some Spanish letters for this example, but the principal is exactly the same for other unencoded characters. And the Journal even provides you with an over view of characters and names on one of the last pages. So "John Deubert's Acumen Journal" thank you for this nice help.


/Helvetica findfont dup %finding the Helvetica font
length dict             %Create a new dictionary the same size
copy begin              %Copy Helv. into the new dict and move the
                        	%new dict. to the dict stack.

/Encoding Encoding 256 array copy def %Make a writable copy of Encoding
%Encoding 1 /aring put
%Encoding 2 /Aring put
Encoding 1 /oacute put	%Put new character names into Encoding
Encoding 2 /aacute put
Encoding 3 /eacute put
Encoding 4 /questiondown put

/Helvetica-Esp currentdict definefont pop %Turn current dict into a 
 						%new font
end			%Remove the dict from the dict stack
/Helvetica-Esp 18 selectfont

72 600 moveto

(\004D\001nde est\002 el camino a San Jos\003 ) show

showpage


PREPROCESSING WITH SHELL SCRIPT.

It is a bit inconvenient to typeset with these escape encodings, typing numbers like /305 in my text. Therefor I typeset my program source "normally" from the keyboard and then afterward I run it through a little shell script to substitute the Danish letters in my PostScript source code with the corresponding PostScript encodings. This script will only work if you use some kind of UNIX (Linux Free BSD etc.) Place note that this script is for the Danich encodings and it assume that the character 'Aring' is encoded as /001 and 'aring' is encoded as /002 in your PostScript code:

Note: Before you go on I should inform you that I have had a comment on this shell script part from Chapman Flack it seems that my shell script solution is a little roundabout. Read Chapman Flacks comment here.

#!/bin/sh 
#Script to substitute local languish characters with the 
#corresponding Postscript encodings

sed -e 's//\\361/g' $1 |sed -e 's//\\371/g' > ret1.ps;
sed -e 's//\\002/g' ret1.ps |sed -e 's//\\341/g' >ret2.ps;
sed -e 's//\\351/g' ret2.ps |sed -e 's//\\001/g' >>tmp.ps;
rm ret2.ps;
rm ret1.ps;
echo "Now your document is in 'tmp.ps'. If you use 'gv' give; 
'gv tmp.ps' to preview it."


If you want to use this lithe script (you will have to edit it if you are not Danish). Save it as pure text. Lets call it "prepr".

The very first time you use this script you will have to do:

chmod +x prepr

To use it you do:

prepr my.ps

gv tmp.ps

I would work in my.ps and then anytime i want to view or print I would use 'prepr' on my program code before viewing or printing. There is a small note on shell scripts at the bottom of the text and image page on this site.

CODING FONT COLORS

For my book I use lots of deferent font colors. In PostScript you change the font colors with a call like for this

0.134 0.473 0.790 setrgbcolor

and the changes takes place until you give a new color or you restore the original settings with 'grestore'. As you can see there is tree numbers separated by 'space' the first is the value for the read color the next is value for green and the last is value fore blue. Minimal value is 0 and maximum value is 1. It is not ease to find a color I like from looking at a number. Therefore I find the color's in a image program where I can see them. I use GIMP but it is the same in many other image program. In GIMP the colors is also made out of three values red, green and blue, but here the maximum value is 255 while the minimum is 0. To translate from the GIMP color value to the PostScript color value I do a this calculation fore each of the three colors the read, the green and the blue:

For read value = 35
Do: 35 / (devided) 255 = 0.137 (and some more dicimals but this is suficiant)

For green value = 5
Do: 5 / (devided) 255 = 0.019

For blue value = 104
Do: 104 / (devided) 255 = 0.407

So the postscript eqivalent of

rgb 35 5 104

Will be:

0.137 0.019 0.407 setrgbcolor

THE GHOSTSCRIPT FONT

Ghostscript depends upon a font packages called 'gsfont'. I thought it would be nice to know which font is available when 'gsfont' is available. Chapman Flack did some nice commands on my pages and I asked him how I could know witch fonts is available and how they look. Here is his Answer:



To get a list of the available fonts:

(*) {=} 128 string /Font resourceforall

To see what they all look like (will show a LOT of pages):

(prfont.ps) runlibfile

(*) {DoFont} 128 string /Font resourceforall

You could see all the fonts on a printer the same way: just delete the first line (runlibfile) and instead cat the file prfont.ps from the ghostscript lib directory, with the resourceforall line following after. Of course it will use a LOT of paper.

If you study prfont.ps you can also write a procedure like DoFont that only shows a sample of characters instead of all the characters in the font, and you could use that to get an idea of what all the fonts look like, without printing such a huge number of pages.

Regards, -Chap"



I like to explane this just a bit sins it took me a while to understand. Ghostscrip has its own interface. When you do the command 'gs' it opens its own commando prompt. Now the normal shell commends is not in use any more instead it is Ghostscript commands which I do not understand much of. But the above commands form Chapman Flack is exactly such ghostscript commands that is supposed to be done in the ghostscript prompt. To end the ghostscript prompt type 'quit' and press 'enter'.

/Mikkel


site map