Blob
1 %2 % Encoding vector, operator and procedure redefinitions for Plan 9 UTF3 % encoding. Prologues are expected to take steps to ensure operator4 % redefinitions given here are actually used. Current implementation5 % assumes UTF byte streams that represent ASCII or Latin1 text.6 %8 /UTFLatin1Encoding [9 /.notdef10 /.notdef11 /.notdef12 /.notdef13 /.notdef14 /.notdef15 /.notdef16 /.notdef17 /.notdef18 /.notdef19 /.notdef20 /.notdef21 /.notdef22 /.notdef23 /.notdef24 /.notdef25 /.notdef26 /.notdef27 /.notdef28 /.notdef29 /.notdef30 /.notdef31 /.notdef32 /.notdef33 /.notdef34 /.notdef35 /.notdef36 /.notdef37 /.notdef38 /.notdef39 /.notdef40 /.notdef41 /space42 /exclam43 /quotedbl44 /numbersign45 /dollar46 /percent47 /ampersand48 /quoteright49 /parenleft50 /parenright51 /asterisk52 /plus53 /comma54 /minus55 /period56 /slash57 /zero58 /one59 /two60 /three61 /four62 /five63 /six64 /seven65 /eight66 /nine67 /colon68 /semicolon69 /less70 /equal71 /greater72 /question73 /at74 /A75 /B76 /C77 /D78 /E79 /F80 /G81 /H82 /I83 /J84 /K85 /L86 /M87 /N88 /O89 /P90 /Q91 /R92 /S93 /T94 /U95 /V96 /W97 /X98 /Y99 /Z100 /bracketleft101 /backslash102 /bracketright103 /asciicircum104 /underscore105 /quoteleft106 /a107 /b108 /c109 /d110 /e111 /f112 /g113 /h114 /i115 /j116 /k117 /l118 /m119 /n120 /o121 /p122 /q123 /r124 /s125 /t126 /u127 /v128 /w129 /x130 /y131 /z132 /braceleft133 /bar134 /braceright135 /asciitilde136 /.notdef137 /.notdef138 /.notdef139 /.notdef140 /.notdef141 /.notdef142 /.notdef143 /.notdef144 /.notdef145 /.notdef146 /.notdef147 /.notdef148 /.notdef149 /.notdef150 /.notdef151 /.notdef152 /.notdef153 /dotlessi154 /grave155 /acute156 /circumflex157 /tilde158 /macron159 /breve160 /dotaccent161 /dieresis162 /.notdef163 /ring164 /cedilla165 /.notdef166 /hungarumlaut167 /ogonek168 /caron169 /space170 /exclamdown171 /cent172 /sterling173 /currency174 /yen175 /brokenbar176 /section177 /dieresis178 /copyright179 /ordfeminine180 /guillemotleft181 /logicalnot182 /hyphen183 /registered184 /macron185 /degree186 /plusminus187 /twosuperior188 /threesuperior189 /acute190 /mu191 /paragraph192 /periodcentered193 /cedilla194 /onesuperior195 /ordmasculine196 /guillemotright197 /onequarter198 /onehalf199 /threequarters200 /questiondown201 /Agrave202 /Aacute203 /Acircumflex204 /Atilde205 /Adieresis206 /Aring207 /AE208 /Ccedilla209 /Egrave210 /Eacute211 /Ecircumflex212 /Edieresis213 /Igrave214 /Iacute215 /Icircumflex216 /Idieresis217 /Eth218 /Ntilde219 /Ograve220 /Oacute221 /Ocircumflex222 /Otilde223 /Odieresis224 /multiply225 /Oslash226 /Ugrave227 /Uacute228 /Ucircumflex229 /Udieresis230 /Yacute231 /Thorn232 /germandbls233 /agrave234 /aacute235 /acircumflex236 /atilde237 /adieresis238 /aring239 /ae240 /ccedilla241 /egrave242 /eacute243 /ecircumflex244 /edieresis245 /igrave246 /iacute247 /icircumflex248 /idieresis249 /eth250 /ntilde251 /ograve252 /oacute253 /ocircumflex254 /otilde255 /odieresis256 /divide257 /oslash258 /ugrave259 /uacute260 /ucircumflex261 /udieresis262 /yacute263 /thorn264 /ydieresis265 ] def267 /NewFontDirectory FontDirectory maxlength dict def269 %270 % Apparently no guarantee findfont is defined in systemdict so the obvious271 %272 % systemdict /findfont get exec273 %274 % can generate an error. So far the only exception is a VT600 (version 48.0).275 %277 userdict /@RealFindfont known not {278 userdict begin279 /@RealFindfont systemdict begin /findfont load end def280 end281 } if283 /findfont {284 dup NewFontDirectory exch known not {285 dup286 %dup systemdict /findfont get exec % not always in systemdict287 dup userdict /@RealFindfont get exec288 dup /Encoding get StandardEncoding eq {289 dup length 1 add dict begin290 {1 index /FID ne {def}{pop pop} ifelse} forall291 /Encoding UTFLatin1Encoding def292 /Metrics 1 dict def293 Metrics /.notdef 0 put294 currentdict295 end296 /DummyFontName exch definefont297 } if298 NewFontDirectory 3 1 roll put299 } if300 NewFontDirectory exch get301 } bind def303 %304 % UTF string decoding for ASCII and Latin1 only:305 %306 % C2 XX => 00 XX307 % C3 XX => XX+40 00308 %309 % Two passes through each string with search is undoubtedly faster than310 % PostScript that examines each byte.311 %313 /UTFstring {314 dup {315 (\302) search {316 pop317 0 0 put318 }{pop exit} ifelse319 } loop320 dup {321 (\303) search {322 pop323 1 index 0 get 16#40 add 0 exch put324 dup length 0 gt {dup 0 0 put} if325 }{pop exit} ifelse326 } loop327 } bind def329 /ashow {mark 4 1 roll UTFstring //ashow cvx exec cleartomark} bind def330 /awidthshow {mark 7 1 roll UTFstring //awidthshow cvx exec cleartomark} bind def331 /show {mark exch UTFstring //show cvx exec cleartomark} bind def332 /stringwidth {UTFstring //stringwidth cvx exec} bind def333 /widthshow {mark 5 1 roll UTFstring //widthshow cvx exec cleartomark} bind def335 %336 % kshow is harder - stack can't change because of the procedure.337 %339 /kshow dup load type /operatortype eq340 {{UTFstring kshow} bind}341 {{UTFstring //kshow cvx exec} bind}342 ifelse def