[comp.lang.postscript] An exmaple composite font

amanda@mermaid.intercon.com (Amanda Walker) (02/03/90)

This is a little messy as PostScript code goes, but I thought it would be
useful to someone.  I've been tinkering with TeX DVI->PS drivers in my
copious spare time :-), and I decided to try re-encoding a PostScript font
into the standard TeX encoding vector, so that I wouldn't have to have
two separate copies of latex.tex sitting around, differing only in accents
and math character definitions.  Here's my first effort, which combines
characters from Times-Roman and Symbol with some hand-written character
descriptions (for dotless j and the ffi & ffl ligatures).  The resulting
font has an encoding vector identical to cmr10.  Writing a TFM file is
left as an exercise for the reader...

Cut here and at the end (there is some code at the end which you can
un-comment to get a font chart)

-----------------------------CUT HERE------------------------------
%!PS
/DVIEncoding [	% The conventional TeX text encoding vector
 /Gamma /Delta /Theta /Lambda /Xi /Pi /Sigma /Upsilon
 /Phi /Psi /Omega /ff /fi /fl /ffi /ffl
 /dotlessi /dotlessj /grave /acute /caron /breve /macron /ring
 /cedilla /germandbls /ae /oe /oslash /AE /OE /Oslash

 /space /exclam /quotedblright /numbersign
 /dollar /percent /ampersand /quoteright
 /parenleft /parenright /asterisk /plus /comma /hyphen /period /slash
 /zero /one /two /three /four /five /six /seven
 /eight /nine /colon /semicolon /exclamdown /equal /questiondown /question

 /at /A /B /C /D /E /F /G /H /I /J /K /L /M /N /O /P /Q /R /S /T /U /V /W
 /X /Y /Z /bracketleft /quotedblleft /bracketright /circumflex /dotaccent

 /quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o
 /p /q /r /s /t /u /v /w
 /x /y /z /endash /emdash /hungarumlaut /tilde /dieresis

% positions 128-255 are not currently used in standard TeX.

 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
] def

/bdf { bind def } bind def

20 dict begin
	/FontType 3 def
	/FontMatrix [.001 0 0 .001 0 0] def
	/FontBBox [0 0 1000 1000] def
	/FontName /TeX-Times-Roman def
	/Encoding DVIEncoding def
	/BaseFonts [
		/Times-Roman findfont 1000 scalefont
		/Symbol findfont 1000 scalefont
	] def
	/String 1 string def
	/sf {	% font character sf (prints character of specfied base font)
		String exch 0 exch put
		BaseFonts exch get setfont
		String stringwidth
		0 0 moveto String false charpath flattenpath pathbbox
		6 copy setcachedevice
		0 0 moveto String show
	} bdf
	/CharProcs 256 dict def
	CharProcs begin
		/.notdef { } def
		/Gamma { 1 8#107 sf } bdf
		/Delta { 1 8#104 sf } bdf
		/Theta { 1 8#121 sf } bdf
		/Lambda { 1 8#114 sf } bdf
		/Xi { 1 8#130 sf } bdf
		/Pi { 1 8#120 sf } bdf
		/Sigma { 1 8#123 sf } bdf
		/Upsilon { 1 8#241 sf } bdf
		/Phi { 1 8#106 sf } bdf
		/Psi { 1 8#131 sf } bdf
		/Omega { 1 8#127 sf } bdf
		/ff {
			(ff) stringwidth exch 50 sub exch
			0 0 moveto (ff) false charpath flattenpath pathbbox
			exch 50 sub exch
			6 copy setcachedevice
			0 0 moveto (f) show -50 0 rmoveto (f) show
		} def
		/fi { 0 8#256 sf } bdf
		/fl { 0 8#257 sf } bdf
		/ffi {
			(f\256) stringwidth exch 50 sub exch
			0 0 moveto (f\256) false charpath flattenpath pathbbox
			exch 50 sub exch
			6 copy setcachedevice
			0 0 moveto (f) show -50 0 rmoveto (\256) show
		} def
		/ffl {
			(f\257) stringwidth exch 50 sub exch
			0 0 moveto (f\257) false charpath flattenpath pathbbox
			exch 50 sub exch
			6 copy setcachedevice
			0 0 moveto (f) show -50 0 rmoveto (\257) show
		} def
		/dotlessi { 0 8#365 sf } bdf
		/dotlessj {
			(j) stringwidth
			0 0 moveto (j) false charpath flattenpath pathbbox
			6 copy setcachedevice newpath
			0 0 moveto (\365) false charpath flattenpath pathbbox
			newpath -1000 -1000 moveto
			dup -1000 exch lineto
			1000 exch lineto
			1000 -1000 lineto
			closepath clip
			pop pop pop
			0 0 moveto (j) show
		} def
		/grave { 0 8#301 sf } bdf
		/acute { 0 8#302 sf } bdf
		/caron { 0 8#317 sf } bdf
		/breve { 0 8#306 sf } bdf
		/macron { 0 8#305 sf } bdf
		/ring { 0 8#312 sf } bdf
		/cedilla { 0 8#313 sf } bdf
		/germandbls { 0 8#373 sf } bdf
		/ae { 0 8#361 sf } bdf
		/oe { 0 8#372 sf } bdf
		/oslash { 0 8#371 sf } bdf
		/AE { 0 8#341 sf } bdf
		/OE { 0 8#352 sf } bdf
		/Oslash { 0 8#351 sf } bdf
		/quotedblright { 0 8#272 sf } bdf
		/exclamdown { 0 8#241 sf } bdf
		/questiondown { 0 8#277 sf } bdf
		/quotedblleft { 0 8#252 sf } bdf
		/circumflex { 0 8#303 sf } bdf
		/dotaccent { 0 8#307 sf } bdf
		/endash { 0 8#261 sf } bdf
		/emdash { 0 8#320 sf } bdf
		/hungarumlaut { 0 8#315 sf } bdf
		/tilde { 0 8#304 sf } bdf
		/dieresis { 0 8#310 sf } bdf
	end
	/BuildChar {
		exch begin
		BaseFonts 0 get setfont
		dup Encoding exch get
		dup CharProcs exch known
			{ CharProcs exch get exch pop exec }
			{ pop String exch 0 exch put
			  String stringwidth
			  newpath 0 0 moveto String false charpath
			  flattenpath pathbbox
			  setcachedevice
			  0 0 moveto
			  String show
			} ifelse
		end
	} def
	currentdict
end
dup /FontName get exch definefont pop

%/Times-Roman findfont 12 scalefont setfont
%72 720 moveto (TeX-Times-Roman at 12pt) show
%/TeX-Times-Roman findfont 12 scalefont setfont
%/s ( ) def
%72 700 translate
%0 1 7 {
%    /y exch def
%    0 1 15 {
%	/x exch def
%	x 24 mul y -24 mul moveto s 0 y 16 mul x add put s show
%    } for
%} for
%
%showpage

--------------------------------CUT HERE---------------------------------

Enjoy,
--
Amanda Walker
InterCon Systems Corporation

"Many of the truths we cling to depend greatly upon our own point of view."
	--Obi-Wan Kenobi in "Return of the Jedi"