%% Header file for sdop PostScript output
% Created: July 06 2005
% Last update: November 16 2013

% Blank lines and lines starting with a single % are not copied to the output.

%%BeginProlog


% Ensure that the pdfmark stuff is ignored by interpreters that do not
% support it.

/pdfmark where                    % Is pdfmark already available?
   { pop }                        % Yes: do nothing (use that definition)
   {                              % No: define pdfmark as follows:
   /globaldict where              % globaldict is preferred because
       { pop globaldict }         % globaldict is always visible; else,
       { userdict }               % use userdict otherwise.
   ifelse
   /pdfmark /cleartomark load put
   }                              % Define pdfmark to remove all objects
ifelse                            % up to and including the mark object.


% ====================== Font Encoding Stuff ==================================
% For fonts that use Adobe's standard encoding (that is, normal text fonts),
% we are going to bind each font twice, to give us 512 characters to play with.
% This is sufficient to encode all existing characters in the normal fonts.

% Here are the two encoding vectors. The first 256 characters are encoded with
% the Unicode encoding.

/LowerEncoding 256 array def
LowerEncoding 0 [
% 00 - 0F
/currency/currency/currency/currency
/currency/currency/currency/currency
/currency/currency/currency/currency
/currency/currency/currency/currency
% 10 - 1F
/currency/currency/currency/currency
/currency/currency/currency/currency
/currency/currency/currency/currency
/currency/currency/currency/currency
% 20 - 2F
/space/exclam/quotedbl/numbersign
/dollar/percent/ampersand/quotesingle
/parenleft/parenright/asterisk/plus
/comma/hyphen/period/slash
% 30 - 3F
/zero/one/two/three
/four/five/six/seven
/eight/nine/colon/semicolon
/less/equal/greater/question
% 40 - 4F
/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O
% 50 - 5F
/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft
/backslash/bracketright/asciicircum/underscore
% 60 - 6F
/grave/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o
% 70 - 7F
/p/q/r/s/t/u/v/w/x/y/z/braceleft
/bar/braceright/asciitilde/currency
% 80 - 8F
/currency/currency/currency/currency
/currency/currency/currency/currency
/currency/currency/currency/currency
/currency/currency/currency/currency
% 90 - 9F
/currency/currency/currency/currency
/currency/currency/currency/currency
/currency/currency/currency/currency
/currency/currency/currency/currency
% A0 - AF
/space/exclamdown/cent/sterling
/currency/yen/brokenbar/section
/dieresis/copyright/ordfeminine/guillemotleft
/logicalnot/hyphen/registered/macron
% B0 - BF
/degree/plusminus/twosuperior/threesuperior
/acute/mu/paragraph/bullet
/cedilla/onesuperior/ordmasculine/guillemotright
/onequarter/onehalf/threequarters/questiondown
% C0 - CF
/Agrave/Aacute/Acircumflex/Atilde
/Adieresis/Aring/AE/Ccedilla
/Egrave/Eacute/Ecircumflex/Edieresis
/Igrave/Iacute/Icircumflex/Idieresis
% D0 - DF
/Eth/Ntilde/Ograve/Oacute
/Ocircumflex/Otilde/Odieresis/multiply
/Oslash/Ugrave/Uacute/Ucircumflex
/Udieresis/Yacute/Thorn/germandbls
% E0 - EF
/agrave/aacute/acircumflex/atilde
/adieresis/aring/ae/ccedilla
/egrave/eacute/ecircumflex/edieresis
/igrave/iacute/icircumflex/idieresis
% F0 - FF
/eth/ntilde/ograve/oacute
/ocircumflex/otilde/odieresis/divide
/oslash/ugrave/uacute/ucircumflex
/udieresis/yacute/thorn/ydieresis
]putinterval

% The next encoding vector uses Unicode for the first 128 characters (Latin
% Extended-A). Not all of these characters are in older Adobe-encoded fonts.
% The remaining code points in the vector are used arbitrarily for the
% remaining Adobe standardly encoded characters. This latter part of the
% encoding must be kept in step with the appropriate table in the code.

/UpperEncoding 256 array def
UpperEncoding 0 [
% 100 - 10F
/Amacron/amacron/Abreve/abreve
/Aogonek/aogonek/Cacute/cacute
/Ccircumflex/ccircumflex/Cdotaccent/cdotaccent
/Ccaron/ccaron/Dcaron/dcaron
% 110 - 11F
/Dcroat/dcroat/Emacron/emacron
/Ebreve/ebreve/Edotaccent/edotaccent
/Eogonek/eogonek/Ecaron/ecaron
/Gcircumflex/gcircumflex/Gbreve/gbreve
% 120 - 12F
/Gdotaccent/gdotaccent/Gcommaaccent/gcommaaccent
/Hcircumflex/hcircumflex/Hbar/hbar
/Itilde/itilde/Imacron/imacron
/Ibreve/ibreve/Iogonek/iogonek
% 130 - 13f
/Idotaccent/dotlessi/IJ/ij
/Jcircumflex/jcircumflex/Kcommaaccent/kcommaaccent
/kgreenlandic/Lacute/lacute/Lcommaaccent
/lcommaaccent/Lcaron/lcaron/Ldot
% 140 - 14F
/ldot/Lslash/lslash/Nacute
/nacute/Ncommaaccent/ncommaaccent/Ncaron
/ncaron/napostrophe/Eng/eng
/Omacron/omacron/Obreve/obreve
% 150 - 15F
/Ohungarumlaut/ohungarumlaut/OE/oe
/Racute/racute/Rcommaaccent/rcommaaccent
/Rcaron/rcaron/Sacute/sacute
/Scircumflex/scircumflex/Scedilla/scedilla
% 160 - 16F
/Scaron/scaron/Tcedilla/tcedilla
/Tcaron/tcaron/Tbar/tbar
/Utilde/utilde/Umacron/umacron
/Ubreve/ubreve/Uring/uring
% 170 - 17F
/Uhungarumlaut/uhungarumlaut/Uogonek/uogonek
/Wcircumflex/wcircumflex/Ycircumflex/ycircumflex
/Ydieresis/Zacute/zacute/Zdotaccent
/zdotaccent/Zcaron/zcaron/longs
% --------------------------------------------------------------------
% These are the remaining characters in the Adobe standard encoding,
% in alphabetic order (seems as good as any other).
% --------------------------------------------------------------------
% 180 - 18F
/Delta/Euro/Scommaaccent/Tcommaaccent
/breve/caron/circumflex/commaaccent
/dagger/daggerdbl/dotaccent/ellipsis
/emdash/endash/fi/fl
% 190 - 19F
/florin/fraction/greaterequal/guilsinglleft
/guilsinglright/hungarumlaut/lessequal/lozenge
/minus/notequal/ogonek/partialdiff
/periodcentered/perthousand/quotedblbase/quotedblleft
% 1A0 - 1AF
/quotedblright/quoteleft/quoteright/quotesinglbase
/radical/ring/scommaaccent/summation
/tcommaaccent/tilde/trademark/infinity
]putinterval


% Routine to initially find a font and re-encode it if necessary.
% On the stack we should have two names, for the two differently encoded
% versions of the font. When the font is not re-encoded, the two will end
% up the same. Following the two names is the font name.

% We find the font first, and then look to see if it's in the directory,
% to cope with the case of loading from an auxiliary store.

/inf{dup dup findfont 3 1 roll FontDirectory exch known {pop}{(**** Font ")print
100 string cvs print (" is not loaded ****\r\n)print stop}ifelse

% At this point we have on the stack the two names, followed by the font.
% Duplicate it, and test to see whether it uses the Adobe Standard encoding.

dup dup/Encoding get StandardEncoding eq

% If the result is true, we obey the following.

% Find the maximum length of the font's dictionary, and make two new 
% dictionaries of the same length.

{maxlength dup dict/newfont0 exch def dict/newfont1 exch def

% Copy the original font into the two new ones, ommitting only the FID.

dup
{1 index/FID eq{pop pop}{newfont0 3 1 roll put}ifelse}forall
{1 index/FID eq{pop pop}{newfont1 3 1 roll put}ifelse}forall

% Now set up the two new encodings and define the names.

newfont1/Encoding UpperEncoding put dup newfont1 definefont def
newfont0/Encoding LowerEncoding put dup newfont0 definefont def
}

% If the font does not use the Standard Encoding, we set both names to
% the unmodified font.

{3 1 roll def def}ifelse

}bind def

% ==================== End of Font Encoding Stuff =============================


% Set font from the array of fonts in the vf variable.

/Sf{vf exch get setfont}bind def

% Relative x movement for kerning

/R{0 rmoveto}bind def

% Straightforward abbreviations

/Mt/moveto load def
/RMt/rmoveto load def
/RLt/rlineto load def
/S/show load def
/Slw/setlinewidth load def
/St/stroke load def





%%EndProlog

% End of PostScript header for sdop
