blob: 234764e3439166a3a68062ef6c9224361b84ea92 [file] [log] [blame]
% Encoding vector, operator and procedure redefinitions for Plan 9 UTF
% encoding. Prologues are expected to take steps to ensure operator
% redefinitions given here are actually used. Current implementation
% assumes UTF byte streams that represent ASCII or Latin1 text.
/UTFLatin1Encoding [
/.notdef % was space
] def
/NewFontDirectory FontDirectory maxlength dict def
% Apparently no guarantee findfont is defined in systemdict so the obvious
% systemdict /findfont get exec
% can generate an error. So far the only exception is a VT600 (version 48.0).
userdict /@RealFindfont known not {
userdict begin
/@RealFindfont systemdict begin /findfont load end def
} if
/findfont {
dup NewFontDirectory exch known not {
%dup systemdict /findfont get exec % not always in systemdict
dup userdict /@RealFindfont get exec
dup /Encoding get StandardEncoding eq {
dup length 1 add dict begin
{1 index /FID ne {def}{pop pop} ifelse} forall
/Encoding UTFLatin1Encoding def
/Metrics 1 dict def
Metrics /.notdef 0 put
/DummyFontName exch definefont
} if
NewFontDirectory 3 1 roll put
} if
NewFontDirectory exch get
} bind def
% Assume A0, except for A0A0 which is replaced by 20A0, can be ignored.
% Works with ASCII or Latin1 because A0 has been re-encoded as a zero
% width non-printing character.
/UTFstring {
dup {
(\240\240) search {
0 16#20 put
}{pop exit} ifelse
} loop
} bind def
/ashow {mark 4 1 roll UTFstring //ashow cvx exec cleartomark} bind def
/awidthshow {mark 7 1 roll UTFstring //awidthshow cvx exec cleartomark} bind def
/show {mark exch UTFstring //show cvx exec cleartomark} bind def
/stringwidth {UTFstring //stringwidth cvx exec} bind def
/widthshow {mark 5 1 roll UTFstring //widthshow cvx exec cleartomark} bind def
% kshow is harder - stack can't change because of the procedure.
/kshow dup load type /operatortype eq
{{UTFstring kshow} bind}
{{UTFstring //kshow cvx exec} bind}
ifelse def