2 % Encoding vector, operator and procedure redefinitions for Plan 9 UTF
3 % encoding. Prologues are expected to take steps to ensure operator
4 % redefinitions given here are actually used. Current implementation
5 % assumes UTF byte streams that represent ASCII or Latin1 text.
267 /NewFontDirectory FontDirectory maxlength dict def
270 % Apparently no guarantee findfont is defined in systemdict so the obvious
272 % systemdict /findfont get exec
274 % can generate an error. So far the only exception is a VT600 (version 48.0).
277 userdict /@RealFindfont known not {
279 /@RealFindfont systemdict begin /findfont load end def
284 dup NewFontDirectory exch known not {
286 %dup systemdict /findfont get exec % not always in systemdict
287 dup userdict /@RealFindfont get exec
288 dup /Encoding get StandardEncoding eq {
289 dup length 1 add dict begin
290 {1 index /FID ne {def}{pop pop} ifelse} forall
291 /Encoding UTFLatin1Encoding def
293 Metrics /.notdef 0 put
296 /DummyFontName exch definefont
298 NewFontDirectory 3 1 roll put
300 NewFontDirectory exch get
304 % UTF string decoding for ASCII and Latin1 only:
309 % Two passes through each string with search is undoubtedly faster than
310 % PostScript that examines each byte.
323 1 index 0 get 16#40 add 0 exch put
324 dup length 0 gt {dup 0 0 put} if
329 /ashow {mark 4 1 roll UTFstring //ashow cvx exec cleartomark} bind def
330 /awidthshow {mark 7 1 roll UTFstring //awidthshow cvx exec cleartomark} bind def
331 /show {mark exch UTFstring //show cvx exec cleartomark} bind def
332 /stringwidth {UTFstring //stringwidth cvx exec} bind def
333 /widthshow {mark 5 1 roll UTFstring //widthshow cvx exec cleartomark} bind def
336 % kshow is harder - stack can't change because of the procedure.
339 /kshow dup load type /operatortype eq
340 {{UTFstring kshow} bind}
341 {{UTFstring //kshow cvx exec} bind}