Debian Codegraph @

texmf-dist/tex/plain/ly1/texnansi.tex

raw
1 % Copyright 2010--2018 TeX Users Group.
2 % Copyright 1994--1997 Y&Y, Inc.
3
4 % Released under the LaTeX Project Public License, any version.
5
6 % ============================================================================
7 % Code to allow plain TeX and LaTeX to fully exploit `texnansi.vec' encoding
8 % (TeX 'n ANSI) VERSION 2.8 (2018 May 25)
9 % ============================================================================
10
11 % \input texnansi in TeX source when using fonts with `TeX n ANSI' encoding.
12
13 % Note that a lot of code that already exists in plain.tex is commented out
14 % --- it is included here merely for reference.
15
16 % `plain' TeX - and `lplain' TeX - have accents hard-wired to certain codes.
17 % When a font is encoded differently, compound characters and accents move.
18 % This file deals with this for TeX 'n ANSI encoding.
19
20 % NOTE: Default is to use the 58 ready-made accented/composite characters
21 % that occur in text fonts directly, using the macros defined below.
22 % To instead build them by overprinting, use \buildcomposites.
23 % To instead link to them via pseudo ligatures, use \usecomposites.
24
25 % NOTE: texnansi.vec is designed to avoid char codes 0, 9, 10, 13, 32, 127
26 % since some brain-dead software has trouble with some of these...
27
28 % NOTE: definitions have embedded numbers that depend on the chosen encoding
29 % These will need to be changed if you use an encoding other than `TEXNANSI'
30
31 % --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
32 % First, protect against style files that make quotedbl `active'
33
34 \chardef\dblcode=\catcode`\" % save catcode of quotedbl
35 \catcode`\"=12 % make quotedbl `other'
36
37 \chardef\atcode=\catcode`\@ % save catcode of atsign
38 \catcode`\@=11 % make atsign `letter'
39 % --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
40
41 % NOTE: plain TeX (and LaTeX) has the accent character positions hardwired to:
42
43 % 16 for `dotlessi', 17 for `dotlessj', 18 for `grave',
44 % 19 for `acute', 20 for `caron', 21 for `breve',
45 % 22 for `macron', 23 for `ring', 24 for `cedilla',
46 % 25 for `germandbls', 26 for `ae', 27 for `oe',
47 % 28 for `oslash', 29 for `AE', 30 for 'OE',
48 % 31 for `Oslash', 94 for `circumflex', 95 for `dotaccent',
49 % 125 for `hungarumlaut', 126 for `tilde', 127 for `dieresis',
50 % The *real* troublesome ones are `dotaccent' and `hungarumlaut'
51 % --- and CM fonts do not have `ogonek' --- which we add here.
52 % (see page 356 of the TeX book for additional information)
53
54 % --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
55
56 % \ae, \oe, \o, \AE, \OE, \O, \ss are in same place as in TeX text
57
58 % Following constructed from pieces in CM, but exist in Type 1 text fonts
59
60 \def\aa{^^e5} \def\AA{^^c5} % aring (229), Aring (197)
61 % \def\cc{^^e7} \def\CC{^^c7} % ccedilla (231), Ccedilla (199)
62
63 % NOTE: \cc may conflict with `carbon copy' in letter.sty ...
64
65 \def\l{^^90} \def\L{^^80} % lslash (144), Lslash (128)
66
67 % TEXNANSI also has the Icelandic characters:
68
69 \def\th{^^fe} \def\TH{^^de} % thorn (254), Thorn (222)
70 \def\dh{^^f0} \def\DH{^^d0} % eth (240), Eth (208)
71
72 \def\pounds{^^a3} \def\copyright{^^a9} % 163 and 169
73 \def\registered{^^ae} \def\trademark{^^99} % 174 and 153
74 % \def\dag{^^86} \def\ddag{^^87} % dagger (134), daggerdbl (135)
75 \def\S{^^a7} \def\P{^^b6} % section (167), paragraph (182)
76
77 % Make it more convenient to use { } _ | \ glyphs direct from text font ?
78
79 % \chardef\{=`\{ \chardef\}=`\} \chardef\_=`\_
80 % \chardef\|=`\| \chardef\backslash=`\\
81
82 % --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
83
84 % Following set up for the 58 accented characters/composites in text fonts:
85
86 % aacute, acircumflex, adieresis, agrave, aring, atilde, ccedilla,
87 % eacute, ecircumflex, edieresis, egrave, iacute, icircumflex,
88 % idieresis, igrave, ntilde, oacute, ocircumflex, odieresis, ograve, otilde,
89 % scaron, uacute, ucircumflex, udieresis, ugrave, yacute, ydieresis, zcaron,
90 % Aacute, Acircumflex, Adieresis, Agrave, Aring, Atilde, Ccedilla,
91 % Eacute, Ecircumflex, Edieresis, Egrave, Iacute, Icircumflex,
92 % Idieresis, Igrave, Ntilde, Oacute, Ocircumflex, Odieresis, Ograve, Otilde,
93 % Scaron, Uacute, Ucircumflex, Udieresis, Ugrave, Yacute, Ydieresis, Zcaron,
94
95 \def\`#1{% grave
96 \if#1a^^e0\else% \char224
97 \if#1e^^e8\else% \char232
98 \if#1i^^ec\else% \char236
99 \if#1o^^f2\else% \char242
100 \if#1u^^f9\else% \char249
101 \if#1A^^c0\else% \char192
102 \if#1E^^c8\else% \char200
103 \if#1I^^cc\else% \char204
104 \if#1O^^d2\else% \char210
105 \if#1U^^d9\else% \char217
106 % \if#1{\i}^^ec\else% \char236
107 \if#1\i^^ec\else% \char236
108 {\accent18 #1}%
109 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
110
111 \def\'#1{% acute
112 \if#1a^^e1\else% \char225
113 \if#1e^^e9\else% \char233
114 \if#1i^^ed\else% \char237
115 \if#1o^^f3\else% \char243
116 \if#1u^^fa\else% \char250
117 \if#1y^^fd\else% \char253
118 \if#1A^^c1\else% \char193
119 \if#1E^^c9\else% \char201
120 \if#1I^^cd\else% \char205
121 \if#1O^^d3\else% \char211
122 \if#1U^^da\else% \char218
123 \if#1Y^^dd\else% \char221
124 % \if#1{\i}^^ed\else% \char237
125 \if#1\i^^ed\else% \char237
126 {\accent19 #1}%
127 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
128
129 \def\^#1{% circumflex
130 \if#1a^^e2\else% \char226
131 \if#1e^^ea\else% \char234
132 \if#1i^^ee\else% \char238
133 \if#1o^^f4\else% \char244
134 \if#1u^^fb\else% \char251
135 \if#1A^^c2\else% \char194
136 \if#1E^^ca\else% \char202
137 \if#1I^^ce\else% \char206
138 \if#1O^^d4\else% \char212
139 \if#1U^^db\else% \char219
140 % \if#1{\i}^^ee\else% \char238
141 \if#1\i^^ee\else% \char238
142 {\accent94 #1}%
143 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
144
145 \def\~#1{% tilde
146 \if#1a^^e3\else% \char227
147 \if#1n^^f1\else% \char241
148 \if#1o^^f5\else% \char245
149 \if#1A^^c3\else% \char195
150 \if#1N^^d1\else% \char209
151 \if#1O^^d5\else% \char213
152 {\accent126 #1}%
153 \fi\fi\fi\fi\fi\fi}
154
155 \def\"#1{% dieresis
156 \if#1a^^e4\else% \char228
157 \if#1e^^eb\else% \char235
158 \if#1i^^ef\else% \char239
159 \if#1o^^f6\else% \char246
160 \if#1u^^fc\else% \char252
161 \if#1y^^ff\else% \char255
162 \if#1A^^c4\else% \char196
163 \if#1E^^cb\else% \char203
164 \if#1I^^cf\else% \char207
165 \if#1O^^d6\else% \char214
166 \if#1U^^dc\else% \char220
167 \if#1Y^^9f\else% \char159
168 % \if#1{\i}^^ef\else% \char239
169 \if#1\i^^ef\else% \char239
170 % {\accent127 #1}%
171 {\accent168 #1}%
172 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
173
174 \def\v #1{% caron
175 \if#1s^^9a\else% \char154
176 \if#1z^^9d\else% \char157
177 \if#1S^^8a\else% \char138
178 \if#1Z^^8d\else% \char141
179 {\accent20 #1}%
180 \fi\fi\fi\fi}
181
182 \def\r #1{% ring
183 \if#1a^^e5\else% \char229
184 \if#1A^^c5\else% \char197
185 {\accent23 #1}%
186 \fi\fi}
187
188 \def\c #1{% cedilla
189 \if#1c^^e7\else% \char231
190 \if#1C^^c7\else% \char199
191 {\setbox0\hbox{#1}\ifdim\ht0=1ex\accent24 #1%
192 \else{\ooalign{\hidewidth\char24\hidewidth\crcr\unhbox0}}\fi}%
193 \fi\fi}
194
195 \def\H#1{{\accent6 #1}}% hungarumlaut % not in 125
196 \def\u#1{{\accent21 #1}}% breve
197
198 % dotaccent and macron have to be treated differently in AMS TeX
199
200 \ifx\amstexloaded@\relax%
201 \def\D#1{{\accent5 #1}} % dotaccent % not in 95
202 \def\B#1{{\accent22 #1}} % macron
203 \let\graveaccent\`
204 \let\acuteaccent\'
205 \let\tildeaccent\~
206 \let\hataccent\^
207 \let\underscore\_
208 \else
209 \def\.#1{{\accent5 #1}} % dotaccent % not in 95
210 \def\=#1{{\accent22 #1}}\fi % macron
211
212 % underline (using macron at 22)
213 \def\b#1{\oalign{#1\crcr\hidewidth
214 \vbox to.2ex{\hbox{\char22}\vss}\hidewidth}}%
215
216 % ogonek (using ogonek at 7)
217 \def\k#1{\setbox0\hbox{#1}\ifdim\ht0=1ex\accent7 #1%
218 \else{\ooalign{\hidewidth\char7\hidewidth\crcr\unhbox0}}\fi}%
219
220 % --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
221
222 % For backward compatability, provide for use of font with TeX's \accent:
223 % (It is however generally better to use ready-made accented characters, since
224 % \accent creates explicit kerning, which breaks the hyphenation machinery)
225 % NOTE: Use \buildcomposites only if you want to force accented/composite
226 % characters to be constructed by `overprinting' base and accent.
227
228 \def\buildcomposites{%
229 % following four lines are for TeX n ANSI encoding only
230 \def\.##1{{\accent5 ##1}}% dotaccent % not in 95
231 \def\H##1{{\accent6 ##1}}% hungarumlaut % not in 125
232 \def\k##1{{\accent7 ##1}}% ogonek % not in CM fonts
233 \def\"##1{{\accent168 ##1}}% dieresis % alternate to 127
234 % following are plain TeX defaults (needed only to undo \usecomposites)
235 \def\`##1{{\accent18 ##1}}% grave
236 \def\'##1{{\accent19 ##1}}% acute
237 \def\^##1{{\accent94 ##1}}% circumflex
238 \def\~##1{{\accent126 ##1}}% tilde
239 \def\=##1{{\accent22 ##1}}% macron
240 \def\v##1{{\accent20 ##1}}% caron
241 \def\u##1{{\accent21 ##1}}% breve
242 % \def\"##1{{\accent127 ##1}}% dieresis % use 168 instead
243 % underline and cedilla accents (macron at 22, cedilla at 24)
244 \def\b##1{\oalign{##1\crcr\hidewidth
245 \vbox to.2ex{\hbox{\char22}\vss}\hidewidth}}%
246 \def\c##1{\setbox0\hbox{##1}\ifdim\ht0=1ex\accent24 ##1%
247 \else{\ooalign{\hidewidth\char24\hidewidth\crcr\unhbox0}}\fi}%
248 }
249
250 % --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
251
252 % USING READY-MADE ACCENTED CHARACTERS:
253 % We can also use pre-built accented character using pseudo ligatures ---
254 % provided the TFM files for the text fonts have them wired in.
255 % The following assumes that the TFM files have the required pseudo-ligatures.
256 % Use -vadj on the command line with AFMtoTFM to set up these pseudo-ligatures.
257 % This only works for the 58 ready-made accented/composite characters.
258
259 \def\usecomposites{%
260 \chardef\`=18 % grave
261 \chardef\'=19 % acute
262 \chardef\^=94 % circumflex
263 \chardef\~=126 % tilde
264 \chardef\"=127 % dieresis % must match TFM, hence do *not* use 168 here
265 \chardef\c=24 % cedilla % only for ccedilla, Ccedilla
266 \chardef\v=20 % caron % only for scaron, zcaron, Scaron, Zcaron
267 \chardef\r=23 % ring % non-standard, for Aring and aring
268 % and some extra goodies
269 \chardef\.=5 % dotaccent % no standard accented chars use this
270 \chardef\H=6 % hungarumlaut % no standard accented chars use this
271 \chardef\k=7 % ogonek % no standard accented chars use this
272 \chardef\u=21 % breve % no standard accented chars use this
273 \chardef\==22 % macron % no standard accented chars use this
274 % \chardef\i=16 % dotlessi
275 }
276
277 % NOTE: To use the above scheme, use \'a, NOT \'{a}, and \c c, NOT \c{c}.
278
279 % --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
280
281 % \buildcomposites % build composites by overprinting base and accent
282 % \usecomposites % use 58 ready-made composites via pseudo ligatures
283
284 % Default is to use 58 ready-made composites, and build others by overprinting.
285
286 % --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
287
288 % Changes required in math macros when roman font is reencoded to `texnansi'.
289 % (An alternative is to draw the accents from the math fonts)
290
291 % Most accents are in same place as in TeX text encoding (except dotaccent)
292
293 \def\usetextaccents{
294 % \def\grave{\mathaccent"7012 } % 18 grave
295 % \def\acute{\mathaccent"7013 } % 19 acute
296 % \def\hat{\mathaccent"705E } % 94 circumflex
297 % \def\tilde{\mathaccent"707E } % 126 tilde
298 % \def\ddot{\mathaccent"707F } % 127 dieresis
299 \def\ddot{\mathaccent"70A8 } % 168 dieresis
300 % \def\bar{\mathaccent"7016 } % 22 macron
301 % \def\check{\mathaccent"7014 } % 20 caron
302 % \def\breve{\mathaccent"7015 } % 21 breve
303 \def\dot{\mathaccent"7005 } % 5 dotaccent
304 }
305
306 % Do not redefine accents in math mode when using MathTime,
307 % since MathTime uses accents in the math fonts - not those in the text font
308
309 % In LaTeX 2e check whether mathtime package has been loaded,
310 % otherwise check whether \MTMI is defined
311
312 \ifx\@ifpackageloaded\undefined\ifx\MTMI\undefined\usetextaccents\fi
313 \else\@ifpackageloaded{mathtime}{}{\usetextaccents}\fi
314
315 % **************************************************************************
316
317 % If you want to use < for `guilsinglleft' and > for `guilsinglright'
318 % then uncomment the following lines:
319
320 % \catcode`\<=\active \chardef<=139
321 % \catcode`\>=\active \chardef>=155
322
323 % If you use < for `exclamdown', > for `questiondown', and | for `emdash'
324 % then uncomment the following lines:
325
326 % \catcode`\<=\active \chardef<=161
327 % \catcode`\>=\active \chardef>=191
328 % \catcode`\|=\active \chardef|=151
329
330 % \chardef\lq=96 \chardef\rq=39
331
332 % Note that \lq and \rq also provide access to ` and '
333
334 \catcode`\@=\atcode % restore original catcode of atsign
335
336 \catcode`\"=\dblcode % restore original catcode of quotedbl
337
338 % If you use " for quotedblright then uncomment the following:
339
340 % \catcode`\"=\active \chardef"=148
341
342 % For proper hyphenation of words with accented characters we need to let
343 % TeX know how to translate words with accented characters to lower case.
344 % Hence define \lccode so that one can use them in \hyphenation{...}
345 % Just for fun, we also define \uccode, and set the \catcode to letter...
346
347 % Mostly in ISO Latin 1, accented characters (and a few special characters)
348 % occur in upper case form in the range 192 - 222, which is offset
349 % by 32 from the corresponding lower case forms in the range 224 - 254.
350
351 \bgroup
352 \newcount\n\newcount\m\n=224\m=192
353 \loop\ifnum\n<255
354 \global\catcode\n=11\global\catcode\m=11
355 \global\lccode\n=\n\global\lccode\m=\n
356 \global\uccode\m=\m\global\uccode\n=\m
357 \advance\n by1\advance\m by1\repeat
358 \egroup
359
360 % Then there are just a few odd ones in TEXNANSI that don't fit this pattern
361
362 \catcode140=11\catcode156=11 % OE, oe
363 \lccode140=156\lccode156=156
364 \uccode140=140\uccode156=140
365 \catcode159=11\catcode255=11 % Ydieresis, ydieresis
366 \lccode159=255\lccode255=255
367 \uccode159=159\uccode255=159
368 \catcode138=11\catcode154=11 % Scaron, scaron
369 \lccode138=154\lccode154=154
370 \uccode138=138\uccode154=138
371 \catcode141=11\catcode157=11 % Zcaron, zcaron
372 \lccode141=157\lccode157=157
373 \uccode157=141\uccode141=141
374 \catcode128=11\catcode144=11 % Lslash, lslash
375 \lccode128=144\lccode144=144
376 \uccode144=128\uccode128=128
377
378 \endinput