% \iffalse meta-comment
%
% Copyright 1993-2022
% The LaTeX3 Project and any individual authors listed elsewhere
% in this file.
%
% This file is part of the Standard LaTeX `Cyrillic Bundle'.
% ----------------------------------------------------------
%
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%    https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2008 or later.
%
% The list of all files belonging to the `Cyrillic Bundle' is
% given in the file `manifest.txt'.
%
% \fi
% \iffalse
% This is the file |lcy.dtx| of the cyrillic bundle for LaTeX2e.
%
% Copyright (C) 1995-1997 Olga Lapko, Johannes L. Braams
% Copyright (C) 1998-2001 Werner Lemberg, Vladimir Volovich
%
%<*driver>
\documentclass{ltxdoc}
\begin{document}
\DocInput{lcy.dtx}
\end{document}
%</driver>
% \fi
%
%    \begin{macrocode}
%<*LCY>
\NeedsTeXFormat{LaTeX2e}[1998/12/01]
\ProvidesFile{lcyenc.def}
  [2022/06/11 v3.4e Cyrillic encoding definition file]
%    \end{macrocode}
%
% \section{Definitions for the \texttt{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 \emph{incompatible} with the
% \LaTeXe\ 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 \textsf{cyrillic}
% bundle for \LaTeXe.  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
% $\leftrightarrow$ 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 \emph{it is not sufficient to use the |LCY| encoding via the
% \textsf{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 \LaTeX\ 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.
%    \begin{macrocode}
\DeclareFontEncoding{LCY}{}{}
\DeclareFontSubstitution{LCY}{cmr}{m}{n}
%    \end{macrocode}
% Declare the accents.
%    \begin{macrocode}
\DeclareTextAccent{\"}{LCY}{127}
\DeclareTextAccent{\'}{LCY}{19}
\DeclareTextAccent{\.}{LCY}{95}
\DeclareTextAccent{\=}{LCY}{22}
\DeclareTextAccent{\^}{LCY}{94}
\DeclareTextAccent{\`}{LCY}{18}
\DeclareTextAccent{\~}{LCY}{126}
\DeclareTextAccent{\H}{LCY}{125}
\DeclareTextAccent{\u}{LCY}{21}
\DeclareTextAccent{\v}{LCY}{20}
\DeclareTextAccent{\r}{LCY}{23}
%    \end{macrocode}
% A fake accent for the Cyrillic breve.
%    \begin{macrocode}
\DeclareTextCommand{\U}{LCY}[1]{\TextSymbolUnavailable{\U{#1}}#1}
%    \end{macrocode}
% Some accents have to be built by hand:
%    \begin{macrocode}
\DeclareTextCommand{\b}{LCY}[1]
   {\hmode@bgroup\o@lign{\relax#1\crcr\hidewidth\sh@ft{29}%
    \vbox to.2ex{\hbox{\char22}\vss}\hidewidth}\egroup}
\DeclareTextCommand{\c}{LCY}[1]
   {\leavevmode\setbox\z@\hbox{#1}\ifdim\ht\z@=1ex\accent24 #1%
    \else{\ooalign{\unhbox\z@\crcr\hidewidth\char24\hidewidth}}\fi}
\DeclareTextCommand{\d}{LCY}[1]
   {\hmode@bgroup
    \o@lign{\relax#1\crcr\hidewidth\sh@ft{10}.\hidewidth}\egroup}
%    \end{macrocode}
% Declare the text symbols.
%    \begin{macrocode}
\DeclareTextSymbol{\AE}{LCY}{29}
\DeclareTextSymbol{\OE}{LCY}{30}
\DeclareTextSymbol{\O}{LCY}{31}
\DeclareTextSymbol{\ae}{LCY}{26}
\DeclareTextSymbol{\i}{LCY}{16}
\DeclareTextSymbol{\j}{LCY}{17}
\DeclareTextSymbol{\oe}{LCY}{27}
\DeclareTextSymbol{\o}{LCY}{28}
\DeclareTextSymbol{\ss}{LCY}{25}
\DeclareTextSymbol{\textemdash}{LCY}{124}
\DeclareTextSymbol{\textendash}{LCY}{123}
\DeclareTextSymbol{\textexclamdown}{LCY}{60}
%\DeclareTextSymbol{\texthyphenchar}{LCY}{`\-}
%\DeclareTextSymbol{\texthyphen}{LCY}{`\-}
\DeclareTextSymbol{\textquestiondown}{LCY}{62}
\DeclareTextSymbol{\textquotedblleft}{LCY}{92}
\DeclareTextSymbol{\textquotedblright}{LCY}{`\"}
\DeclareTextSymbol{\textquoteleft}{LCY}{`\`}
\DeclareTextSymbol{\textquoteright}{LCY}{`\'}
%    \end{macrocode}
% Some symbols which are faked from others:
%    \begin{macrocode}
\DeclareTextCommand{\L}{LCY}
   {\leavevmode\setbox\z@\hbox{L}\hb@xt@\wd\z@{\hss\@xxxii L}}
\DeclareTextCommand{\l}{LCY}
   {\hmode@bgroup\@xxxii l\egroup}
%<*AAhack>
%\DeclareTextCommand{\AA}{LCY}
%   {\leavevmode\setbox\z@\hbox{!}\dimen@\ht\z@\advance\dimen@-1ex%
%    \rlap{\raise.67\dimen@\hbox{\char23}}A}
%\DeclareTextCommand{\aa}{LCY}{{\accent23a}}
%</AAhack>
%    \end{macrocode}
%<*AAhack>
% In the |LCY| encoding `\r A' has a hand-crafted definition:
%    \begin{macrocode}
\DeclareTextCompositeCommand{\r}{LCY}{A}
   {\leavevmode\setbox\z@\hbox{!}\dimen@\ht\z@\advance\dimen@-1ex%
    \rlap{\raise.67\dimen@\hbox{\char23}}A}
%    \end{macrocode}
%</AAhack>
% In the |LCY| encoding, `\pounds' and `\$' share a slot.
%    \begin{macrocode}
\DeclareTextCommand{\textdollar}{LCY}{\hmode@bgroup
   \ifdim \fontdimen\@ne\font >\z@
      \slshape
   \else
      \upshape
   \fi
   \char`\$\egroup}
\DeclareTextCommand{\textsterling}{LCY}{\hmode@bgroup
   \ifdim \fontdimen\@ne\font >\z@
      \itshape
   \else
      \fontshape{ui}\selectfont
   \fi
   \char`\$\egroup}
%    \end{macrocode}
% And now, the Cyrillic part of the |LCY| encoding:
%    \begin{macrocode}
\DeclareTextSymbol{\CYRA}{LCY}{128}
\DeclareTextSymbol{\CYRB}{LCY}{129}
\DeclareTextSymbol{\CYRV}{LCY}{130}
\DeclareTextSymbol{\CYRG}{LCY}{131}
\DeclareTextSymbol{\CYRD}{LCY}{132}
\DeclareTextSymbol{\CYRE}{LCY}{133}
\DeclareTextSymbol{\CYRZH}{LCY}{134}
\DeclareTextSymbol{\CYRZ}{LCY}{135}
\DeclareTextSymbol{\CYRI}{LCY}{136}
\DeclareTextSymbol{\CYRISHRT}{LCY}{137}
\DeclareTextSymbol{\CYRK}{LCY}{138}
\DeclareTextSymbol{\CYRL}{LCY}{139}
\DeclareTextSymbol{\CYRM}{LCY}{140}
\DeclareTextSymbol{\CYRN}{LCY}{141}
\DeclareTextSymbol{\CYRO}{LCY}{142}
\DeclareTextSymbol{\CYRP}{LCY}{143}
\DeclareTextSymbol{\CYRR}{LCY}{144}
\DeclareTextSymbol{\CYRS}{LCY}{145}
\DeclareTextSymbol{\CYRT}{LCY}{146}
\DeclareTextSymbol{\CYRU}{LCY}{147}
\DeclareTextSymbol{\CYRF}{LCY}{148}
\DeclareTextSymbol{\CYRH}{LCY}{149}
\DeclareTextSymbol{\CYRC}{LCY}{150}
\DeclareTextSymbol{\CYRCH}{LCY}{151}
\DeclareTextSymbol{\CYRSH}{LCY}{152}
\DeclareTextSymbol{\CYRSHCH}{LCY}{153}
\DeclareTextSymbol{\CYRHRDSN}{LCY}{154}
\DeclareTextSymbol{\CYRERY}{LCY}{155}
\DeclareTextSymbol{\CYRSFTSN}{LCY}{156}
\DeclareTextSymbol{\CYREREV}{LCY}{157}
\DeclareTextSymbol{\CYRYU}{LCY}{158}
\DeclareTextSymbol{\CYRYA}{LCY}{159}
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareTextSymbol{\cyra}{LCY}{160}
\DeclareTextSymbol{\cyrb}{LCY}{161}
\DeclareTextSymbol{\cyrv}{LCY}{162}
\DeclareTextSymbol{\cyrg}{LCY}{163}
\DeclareTextSymbol{\cyrd}{LCY}{164}
\DeclareTextSymbol{\cyre}{LCY}{165}
\DeclareTextSymbol{\cyrzh}{LCY}{166}
\DeclareTextSymbol{\cyrz}{LCY}{167}
\DeclareTextSymbol{\cyri}{LCY}{168}
\DeclareTextSymbol{\cyrishrt}{LCY}{169}
\DeclareTextSymbol{\cyrk}{LCY}{170}
\DeclareTextSymbol{\cyrl}{LCY}{171}
\DeclareTextSymbol{\cyrm}{LCY}{172}
\DeclareTextSymbol{\cyrn}{LCY}{173}
\DeclareTextSymbol{\cyro}{LCY}{174}
\DeclareTextSymbol{\cyrp}{LCY}{175}
\DeclareTextSymbol{\cyrr}{LCY}{224}
\DeclareTextSymbol{\cyrs}{LCY}{225}
\DeclareTextSymbol{\cyrt}{LCY}{226}
\DeclareTextSymbol{\cyru}{LCY}{227}
\DeclareTextSymbol{\cyrf}{LCY}{228}
\DeclareTextSymbol{\cyrh}{LCY}{229}
\DeclareTextSymbol{\cyrc}{LCY}{230}
\DeclareTextSymbol{\cyrch}{LCY}{231}
\DeclareTextSymbol{\cyrsh}{LCY}{232}
\DeclareTextSymbol{\cyrshch}{LCY}{233}
\DeclareTextSymbol{\cyrhrdsn}{LCY}{234}
\DeclareTextSymbol{\cyrery}{LCY}{235}
\DeclareTextSymbol{\cyrsftsn}{LCY}{236}
\DeclareTextSymbol{\cyrerev}{LCY}{237}
\DeclareTextSymbol{\cyryu}{LCY}{238}
\DeclareTextSymbol{\cyrya}{LCY}{239}
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareTextSymbol{\CYRYO}{LCY}{240}
\DeclareTextSymbol{\cyryo}{LCY}{241}
\DeclareTextSymbol{\CYRGUP}{LCY}{242}
\DeclareTextSymbol{\cyrgup}{LCY}{243}
\DeclareTextSymbol{\CYRIE}{LCY}{244}
\DeclareTextSymbol{\cyrie}{LCY}{245}
\DeclareTextSymbol{\CYRII}{LCY}{246}
\DeclareTextSymbol{\cyrii}{LCY}{247}
\DeclareTextSymbol{\CYRYI}{LCY}{248}
\DeclareTextSymbol{\cyryi}{LCY}{249}
\DeclareTextSymbol{\CYRUSHRT}{LCY}{250}
\DeclareTextSymbol{\cyrushrt}{LCY}{251}
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareTextSymbol{\cyrdash}{LCY}{196}
\DeclareTextSymbol{\textcurrency}{LCY}{197}
\DeclareTextSymbol{\textnumero}{LCY}{252}
\DeclareTextSymbol{\guillemotleft}{LCY}{253}
\DeclareTextSymbol{\guillemetleft}{LCY}{253}
\DeclareTextSymbol{\guillemotright}{LCY}{254}
\DeclareTextSymbol{\guillemetright}{LCY}{254}
\DeclareTextSymbol{\quotedblbase}{LCY}{255}
%    \end{macrocode}
% Text composites. The following declarations will not work for 8-bit
% chars generated via |inputenc| unless a |dblaccnt| package is used.
%    \begin{macrocode}
\DeclareTextComposite{\"}{LCY}{\CYRE}{240}
\DeclareTextComposite{\"}{LCY}{\cyre}{241}
\DeclareTextComposite{\U}{LCY}{\CYRI}{137}
\DeclareTextComposite{\U}{LCY}{\cyri}{169}
\DeclareTextComposite{\"}{LCY}{\CYRII}{248}
\DeclareTextComposite{\"}{LCY}{\cyrii}{249}
\DeclareTextComposite{\U}{LCY}{\CYRU}{250}
\DeclareTextComposite{\U}{LCY}{\cyru}{251}
%</LCY>
%    \end{macrocode}
%
% \section{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.
%
%    \begin{macrocode}
%<*LCYdefs>
\def\letter#1 #2 {%
%    \end{macrocode}
% Do not break inputenc:
%    \begin{macrocode}
  \ifnum\catcode#1=13\else\catcode#1=11 \catcode#2=11 \fi
  \uccode#1=#1 \uccode#2=#1
  \lccode#1=#2 \lccode#2=#2
  \sfcode#1=999 \sfcode#2=1000
  \count255=#1 \advance\count255 "7000 \mathcode#1=\count255
  \count255=#2 \advance\count255 "7000 \mathcode#2=\count255
}
%    \end{macrocode}
%
%    \begin{macrocode}
\letter 128 160
\letter 129 161
\letter 130 162
\letter 131 163
\letter 132 164
\letter 133 165
\letter 134 166
\letter 135 167
\letter 136 168
\letter 137 169
\letter 138 170
\letter 139 171
\letter 140 172
\letter 141 173
\letter 142 174
\letter 143 175
\letter 144 224
\letter 145 225
\letter 146 226
\letter 147 227
\letter 148 228
\letter 149 229
\letter 150 230
\letter 151 231
\letter 152 232
\letter 153 233
\letter 154 234
\letter 155 235
\letter 156 236
\letter 157 237
\letter 158 238
\letter 159 239
\letter 240 241
\letter 242 243
\letter 244 245
\letter 246 247
\letter 248 249
\letter 250 251
\let\letter\undefined
%    \end{macrocode}
% 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.
%    \begin{macrocode}
\lccode 196=0 \uccode 196=0 \lccode 197=0 \uccode 197=0
\lccode 252=0 \uccode 252=0 \lccode 253=0 \uccode 253=0
\lccode 254=0 \uccode 254=0 \lccode 255=0 \uccode 255=0
%</LCYdefs>
%    \end{macrocode}
%
% \section{A wrapper package for the \texttt{LCY} encoding}
%
%    \begin{macrocode}
%<*wrapper>
\ProvidesPackage{lcy}[1999/06/06 v1.0 Wrapper for LCY encoding]
%    \end{macrocode}
% You can use the `\textsf{nowarn}' option to suppress boring warning.
%    \begin{macrocode}
\DeclareOption{nowarn}{\let\iflcy@warn\iffalse}
\let\iflcy@warn\iftrue
\ProcessOptions
\iflcy@warn
\typeout{%
****************************************************^^J%
* The LCY encoding will break multilingual documents^^J%
* because it needs non-standard uc/lccode settings.^^J%
* Please use T2* encodings instead.^^J%
****************************************************}
\fi
\RequirePackage[LCY]{fontenc}
\input{lcydefs}
%</wrapper>
%    \end{macrocode}
\endinput
