1 ⟨∗LCY⟩

 2 \NeedsTeXFormat{LaTeX2e}[1998/12/01]
 3 \ProvidesFile{lcyenc.def}
 4 [2004/01/26 v3.4c Cyrillic encoding definition file]

1 Definitions for the LCY encoding

The definitions for the ‘TEX text Cyrillic’ (LCY) encoding.

The LCY encoding is an extension of the OT1 encoding; all lower 128 positions are the same (and this part of the file was taken from ot1enc.def), but most of the upper 128 positions are used for Cyrillic glyphs.

Important note: The LCY font encoding is incompatible with the L^{A}TEX 2ε standard conventions regarding uccode and lccode settings! Therefore, the LCY font encoding should not be used in a multilingual environment (for example, Russian, German, and English), because the hyphenation will be broken! Instead, use the new standard Cyrillic encodings T2A, T2B, T2C and X2 defined in the cyrillic bundle for L^{A}TEX 2ε. One can only use LCY to typeset at most bilingual Russian-English documents.

Because of this incompatibility we have to set the lccode values, which are important for TEX’s hyphenation process, to match the LCY encoding. We do not need to set the uccode and catcode values because they are unused in hyphenation process, and uppercase ↔ lowercase translation is defined via another mechanism in \MakeUppercase and \MakeLowercase commands. Again, this change of lccodes will break hyphenation for other languages with standard 8-bit font encodings! It is useless to make these changes in \extrasrussian (i.e., ‘locally’) for the same reason, so we make global changes, which are stored in the file lcydefs.tex defined below.

Note that it is not sufficient to use the LCY encoding via the fontenc package, but one also should load a file lcydefs.tex which sets lccode and other TEX registers for LCY encoding globally (breaking standard 8-bit font encodings). For this reason we created also a wrapper package ‘lcy’ which is a preferred mechanism for using the LCY font encoding, — it loads LCY encoding definition file and lcydefs.tex.

We rely on L^{A}TEX to set the \@uclclist, and thus the \NeedsTeXFormat line above.

Declare the Local Cyrillic encoding. Specify a default for the font substitution process for the LCY encoding.

 5 \DeclareFontEncoding{LCY}{}{}
 6 \DeclareFontSubstitution{LCY}{cmr}{m}{n}

Declare the accents.

 7 \DeclareTextAccent{\"}{LCY}{127}
 8 \DeclareTextAccent{\'}{LCY}{19}
 9 \DeclareTextAccent{\.}{LCY}{95}
10 \DeclareTextAccent{\=}{LCY}{22}
11 \DeclareTextAccent{\^}{LCY}{94}
12 \DeclareTextAccent{\`}{LCY}{18}
13 \DeclareTextAccent{\~}{LCY}{126}
14 \DeclareTextAccent{\H}{LCY}{125}
15 \DeclareTextAccent{\u}{LCY}{21}
16 \DeclareTextAccent{\v}{LCY}{20}
17 \DeclareTextAccent{\r}{LCY}{23}

A fake accent for the Cyrillic breve.

18 \DeclareTextCommand{\U}{LCY}[1]{\TextSymbolUnavailable{\U{#1}}#1}

Some accents have to be built by hand:

19 \DeclareTextCommand{\b}{LCY}[1]
20 {\hmode@bgroup\o@lign{\relax#1\crcr\hidewidth\sh@ft{29}%
21  \vbox to.2ex{\hbox{\char22}\vss}\hidewidth}\egroup}
22 \DeclareTextCommand{\c}{LCY}[1]
23 {\leavevmode\setbox\z@\hbox{#1}\ifdim\ht\z@=1ex\accent24 #1%
24  \else{\ooalign{\unhbox\z@\crcr\hidewidth\char24\hidewidth}}\fi}
25 \DeclareTextCommand{\d}{LCY}[1]
26 {\hmode@bgroup
27  \o@lign{\relax#1\crcr\hidewidth\sh@ft{10}.\hidewidth}\egroup}

Declare the text symbols.

28 \DeclareTextSymbol{\AE}{LCY}{29}
29 \DeclareTextSymbol{\OE}{LCY}{30}
30 \DeclareTextSymbol{\O}{LCY}{31}
31 \DeclareTextSymbol{\ae}{LCY}{26}
32 \DeclareTextSymbol{\i}{LCY}{16}
33 \DeclareTextSymbol{\j}{LCY}{17}
34 \DeclareTextSymbol{\oe}{LCY}{27}
35 \DeclareTextSymbol{\o}{LCY}{28}
36 \DeclareTextSymbol{\ss}{LCY}{25}
37 \DeclareTextSymbol{\textemdash}{LCY}{124}
38 \DeclareTextSymbol{\textendash}{LCY}{123}
39 \DeclareTextSymbol{\textexclamdown}{LCY}{60}
40 %\DeclareTextSymbol{\texthyphenchar}{LCY}{`\-}
41 %\DeclareTextSymbol{\texthyphen}{LCY}{`\-}
42 \DeclareTextSymbol{\textquestiondown}{LCY}{62}
43 \DeclareTextSymbol{\textquotedblleft}{LCY}{92}
44 \DeclareTextSymbol{\textquotedblright}{LCY}{`\"}
45 \DeclareTextSymbol{\textquoteleft}{LCY}{`\`}
46 \DeclareTextSymbol{\textquoteright}{LCY}{`\'}

Some symbols which are faked from others:

47 \DeclareTextCommand{\L}{LCY}
48 {\leavevmode\setbox\z@\hbox{L}\hb@xt@\wd\z@{\hss\@xxxii L}}
49 \DeclareTextCommand{\l}{LCY}
50 {\hmode@bgroup\@xxxii l\egroup}
51 %\DeclareTextCommand{\AA}{LCY}
52 %   {\leavevmode\setbox\z@\hbox{h}\dimen@\ht\z@\advance\dimen@-1ex%
53 %    \rlap{\raise.67\dimen@\hbox{\char23}}A}
54 %\DeclareTextCommand{\aa}{LCY}{{\accent23a}}

In the LCY encoding ‘Å’ has a hand-crafted definition:

55 \DeclareTextCompositeCommand{\r}{LCY}{A}
56 {\leavevmode\setbox\z@\hbox{!}\dimen@\ht\z@\advance\dimen@-1ex%
57  \rlap{\raise.67\dimen@\hbox{\char23}}A}

In the LCY encoding, ‘£’ and ‘$’ share a slot.

58 \DeclareTextCommand{\textdollar}{LCY}{\hmode@bgroup
59 \ifdim \fontdimen\@ne\font >\z@
60  \slshape
61 \else
62  \upshape

63 \fi
64 \char`\$\egroup}
65 \DeclareTextCommand{\textsterling}{LCY}{\hmode@bgroup
66 \ifdim \fontdimen\@ne\font >\z@
67  \itshape
68 \else
69  \fontshape{ui}\selectfont
70 \fi
71 \char`\$\egroup}

And now, the Cyrillic part of the LCY encoding:

72 \DeclareTextSymbol{\CYRA}{LCY}{128}
73 \DeclareTextSymbol{\CYRB}{LCY}{129}
74 \DeclareTextSymbol{\CYRV}{LCY}{130}
75 \DeclareTextSymbol{\CYRG}{LCY}{131}
76 \DeclareTextSymbol{\CYRD}{LCY}{132}
77 \DeclareTextSymbol{\CYRE}{LCY}{133}
78 \DeclareTextSymbol{\CYRZH}{LCY}{134}
79 \DeclareTextSymbol{\CYRZ}{LCY}{135}
80 \DeclareTextSymbol{\CYRI}{LCY}{136}
81 \DeclareTextSymbol{\CYRISHRT}{LCY}{137}
82 \DeclareTextSymbol{\CYRK}{LCY}{138}
83 \DeclareTextSymbol{\CYRL}{LCY}{139}
84 \DeclareTextSymbol{\CYRM}{LCY}{140}
85 \DeclareTextSymbol{\CYRN}{LCY}{141}
86 \DeclareTextSymbol{\CYRO}{LCY}{142}
87 \DeclareTextSymbol{\CYRP}{LCY}{143}
88 \DeclareTextSymbol{\CYRR}{LCY}{144}
89 \DeclareTextSymbol{\CYRS}{LCY}{145}
90 \DeclareTextSymbol{\CYRT}{LCY}{146}
91 \DeclareTextSymbol{\CYRU}{LCY}{147}
92 \DeclareTextSymbol{\CYRF}{LCY}{148}
93 \DeclareTextSymbol{\CYRH}{LCY}{149}
94 \DeclareTextSymbol{\CYRC}{LCY}{150}
95 \DeclareTextSymbol{\CYRCH}{LCY}{151}
96 \DeclareTextSymbol{\CYRSH}{LCY}{152}
97 \DeclareTextSymbol{\CYRSHCH}{LCY}{153}
98 \DeclareTextSymbol{\CYRHRDSN}{LCY}{154}
99 \DeclareTextSymbol{\CYRERY}{LCY}{155}
100 \DeclareTextSymbol{\CYRSFTSN}{LCY}{156}
101 \DeclareTextSymbol{\CYREREV}{LCY}{157}
102 \DeclareTextSymbol{\CYRYU}{LCY}{158}
103 \DeclareTextSymbol{\CYRYA}{LCY}{159}
104 \DeclareTextSymbol{\cyra}{LCY}{160}
105 \DeclareTextSymbol{\cyrb}{LCY}{161}
106 \DeclareTextSymbol{\cyrv}{LCY}{162}
107 \DeclareTextSymbol{\cyrg}{LCY}{163}
108 \DeclareTextSymbol{\cyrd}{LCY}{164}
109 \DeclareTextSymbol{\cyre}{LCY}{165}
110 \DeclareTextSymbol{\cyrzh}{LCY}{166}
111 \DeclareTextSymbol{\cyrz}{LCY}{167}
112 \DeclareTextSymbol{\cyri}{LCY}{168}
113 \DeclareTextSymbol{\cyrishrt}{LCY}{169}
114 \DeclareTextSymbol{\cyrk}{LCY}{170}

115 \DeclareTextSymbol{\cyrl}{LCY}{171}
116 \DeclareTextSymbol{\cyrm}{LCY}{172}
117 \DeclareTextSymbol{\cyrn}{LCY}{173}
118 \DeclareTextSymbol{\cyro}{LCY}{174}
119 \DeclareTextSymbol{\cyrp}{LCY}{175}
120 \DeclareTextSymbol{\cyrr}{LCY}{224}
121 \DeclareTextSymbol{\cyrs}{LCY}{225}
122 \DeclareTextSymbol{\cyrt}{LCY}{226}
123 \DeclareTextSymbol{\cyru}{LCY}{227}
124 \DeclareTextSymbol{\cyrf}{LCY}{228}
125 \DeclareTextSymbol{\cyrh}{LCY}{229}
126 \DeclareTextSymbol{\cyrc}{LCY}{230}
127 \DeclareTextSymbol{\cyrch}{LCY}{231}
128 \DeclareTextSymbol{\cyrsh}{LCY}{232}
129 \DeclareTextSymbol{\cyrshch}{LCY}{233}
130 \DeclareTextSymbol{\cyrhrdsn}{LCY}{234}
131 \DeclareTextSymbol{\cyrery}{LCY}{235}
132 \DeclareTextSymbol{\cyrsftsn}{LCY}{236}
133 \DeclareTextSymbol{\cyrerev}{LCY}{237}
134 \DeclareTextSymbol{\cyryu}{LCY}{238}
135 \DeclareTextSymbol{\cyrya}{LCY}{239}
136 \DeclareTextSymbol{\CYRYO}{LCY}{240}
137 \DeclareTextSymbol{\cyryo}{LCY}{241}
138 \DeclareTextSymbol{\CYRGUP}{LCY}{242}
139 \DeclareTextSymbol{\cyrgup}{LCY}{243}
140 \DeclareTextSymbol{\CYRIE}{LCY}{244}
141 \DeclareTextSymbol{\cyrie}{LCY}{245}
142 \DeclareTextSymbol{\CYRII}{LCY}{246}
143 \DeclareTextSymbol{\cyrii}{LCY}{247}
144 \DeclareTextSymbol{\CYRYI}{LCY}{248}
145 \DeclareTextSymbol{\cyryi}{LCY}{249}
146 \DeclareTextSymbol{\CYRUSHRT}{LCY}{250}
147 \DeclareTextSymbol{\cyrushrt}{LCY}{251}
148 \DeclareTextSymbol{\cyrdash}{LCY}{196}
149 \DeclareTextSymbol{\textcurrency}{LCY}{197}
150 \DeclareTextSymbol{\textnumero}{LCY}{252}
151 \DeclareTextSymbol{\guillemotleft}{LCY}{253}
152 \DeclareTextSymbol{\guillemotright}{LCY}{254}
153 \DeclareTextSymbol{\quotedblbase}{LCY}{255}

Text composites. The following declarations will not work for 8-bit chars generated via inputenc unless a dblaccnt package is used.

154 \DeclareTextComposite{\"}{LCY}{\CYRE}{240}
155 \DeclareTextComposite{\"}{LCY}{\cyre}{241}
156 \DeclareTextComposite{\U}{LCY}{\CYRI}{137}
157 \DeclareTextComposite{\U}{LCY}{\cyri}{169}
158 \DeclareTextComposite{\"}{LCY}{\CYRII}{248}
159 \DeclareTextComposite{\"}{LCY}{\cyrii}{249}
160 \DeclareTextComposite{\U}{LCY}{\CYRU}{250}
161 \DeclareTextComposite{\U}{LCY}{\cyru}{251}

162 ⟨/LCY⟩

2 Setup {cat,uc,lc,sf,math}code values for LCY font encoding

We store this setup in a separate file, lcydefs.tex, which is used also in a ‘cyrplain’ bundle for Plain TEX.

163 ⟨∗LCYdefs⟩

164 \def\letter#1 #2 {%

Do not break inputenc:

165 \ifnum\catcode#1=13\else\catcode#1=11 \catcode#2=11 \fi
166 \uccode#1=#1 \uccode#2=#1
167 \lccode#1=#2 \lccode#2=#2
168 \sfcode#1=999 \sfcode#2=1000
169 \count255=#1 \advance\count255 "7000 \mathcode#1=\count255
170 \count255=#2 \advance\count255 "7000 \mathcode#2=\count255

171 }

172 \letter 128 160
173 \letter 129 161
174 \letter 130 162
175 \letter 131 163
176 \letter 132 164
177 \letter 133 165
178 \letter 134 166
179 \letter 135 167
180 \letter 136 168
181 \letter 137 169
182 \letter 138 170
183 \letter 139 171
184 \letter 140 172
185 \letter 141 173
186 \letter 142 174
187 \letter 143 175
188 \letter 144 224
189 \letter 145 225
190 \letter 146 226
191 \letter 147 227
192 \letter 148 228
193 \letter 149 229
194 \letter 150 230
195 \letter 151 231
196 \letter 152 232
197 \letter 153 233
198 \letter 154 234
199 \letter 155 235
200 \letter 156 236
201 \letter 157 237
202 \letter 158 238
203 \letter 159 239
204 \letter 240 241
205 \letter 242 243
206 \letter 244 245
207 \letter 246 247
208 \letter 248 249

209 \letter 250 251
210 \let\letter\undefined

To avoid bad hyphenation of words delimited with non-letter signs (like quotes), we have to zero uc/lccode parameters for these non-letter signs.

211 \lccode 196=0 \uccode 196=0 \lccode 197=0 \uccode 197=0
212 \lccode 252=0 \uccode 252=0 \lccode 253=0 \uccode 253=0
213 \lccode 254=0 \uccode 254=0 \lccode 255=0 \uccode 255=0

214 ⟨/LCYdefs⟩

3 A wrapper package for the LCY encoding

215 ⟨∗wrapper⟩

216 \ProvidesPackage{lcy}[1999/06/06 v1.0 Wrapper for LCY encoding]

You can use the ‘nowarn’ option to suppress boring warning.

217 \DeclareOption{nowarn}{\let\iflcy@warn\iffalse}
218 \let\iflcy@warn\iftrue
219 \ProcessOptions
220 \iflcy@warn
221 \typeout{%
222 ****************************************************^^J%
223 * The LCY encoding will break multilingual documents^^J%
224 * because it needs non-standard uc/lccode settings.^^J%
225 * Please use T2* encodings instead.^^J%
226 ****************************************************}
227 \fi
228 \RequirePackage[LCY]{fontenc}
229 \input{lcydefs}

230 ⟨/wrapper⟩