summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ucs/utils/autofe.sty
blob: 98ecacda7475433a0d2a36656da40136f162e891 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
%%
%% This is file `autofe.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ucs.dtx  (with options: `autofe.sty')
%% 
%% Copyright 2001 Dominique Unruh  <unruh@ut.ee>
%% Copyright 2013 Wolfgang Jeltsch <wolfgang@cs.ioc.ee>
%% 
%% This program is provided under the terms of the LaTeX Project Public License with some
%% modifications. See the file LICENSE for information.
%% 
\ProvidesPackage{autofe}[2002/12/17 Automatic switching of fontencodings]

\let\autofe@mode1

\let\autofe@DeclareTextCommand\DeclareTextCommand
\def\DeclareTextCommand{\autofe@parse@declaretextcommand\autofe@DeclareTextCommand}
\let\autofe@ProvideTextCommand\ProvideTextCommand
\def\ProvideTextCommand{\autofe@parse@declaretextcommand\autofe@ProvideTextCommand}
\let\autofe@DeclareTextSymbol\DeclareTextSymbol

\def\autofe@parse@declaretextcommand#1#2#3{%
  \@ifnextchar[%
  {\autofe@parse@declaretextcommand@a{#1}{#2}{#3}}%
  {\autofe@parse@declaretextcommand@dd{#1}{#2}{#3}}}
\def\autofe@parse@declaretextcommand@a#1#2#3[#4]{%
  \@ifnextchar[%
  {\autofe@parse@declaretextcommand@aa{#1}{#2}{#3}{#4}}%
  {\autofe@parse@declaretextcommand@ad{#1}{#2}{#3}{#4}}}

\def\autofe@parse@declaretextcommand@aa#1#2#3#4[#5]#6{%
  %{\toks255{#1{#2}{#3}[#4][#5]{#6}}\typeout{Running \the\toks255}}%
  \ifx\autofe@mode0\else\expandafter\autofe@defdef\expandafter{#3}{\autofe@ProvideTextCommand{#2}{?}[#4][#5]}{#6}\fi
  #1{#2}{#3}[#4][#5]{#6}%
}
\def\autofe@parse@declaretextcommand@ad#1#2#3#4#5{%
  %{\toks255{#1{#2}{#3}[#4]{#5}}\typeout{Running \the\toks255}}%
  \ifx\autofe@mode0\else\expandafter\autofe@defdef\expandafter{#3}{\autofe@ProvideTextCommand{#2}{?}[#4]}{#5}\fi
  #1{#2}{#3}[#4]{#5}%
}
\def\autofe@parse@declaretextcommand@dd#1#2#3#4{%
  %{\toks255{#1{#2}{#3}{#4}}\typeout{Running \the\toks255}}%
  \ifx\autofe@mode0\else\expandafter\autofe@defdef\expandafter{#3}{#1{#2}{?}}{#4}\fi
  #1{#2}{#3}{#4}%
}
\def\DeclareTextSymbol#1#2#3{%
  %{\toks255{\autofe@DeclareTextSymbol{#1}{#2}{#3}}\typeout{Running \the\toks255}}%
  \ifx\autofe@mode0\else\expandafter\autofe@defdef\expandafter{#2}{\autofe@ProvideTextCommand{#1}{?}}{\char#3}\fi
  \autofe@DeclareTextSymbol{#1}{#2}{#3}%
}

\def\autofe@defdef#1#2#3{%
  \begingroup
    \def\temp@a{#1}\def\temp@b{?}%
    \ifx\temp@a\temp@b
      \let\temp@a\@gobbletwo
    \else
      \ifx\autofe@mode1%
        \let\temp@a\@firstoftwo
      \else
        \let\temp@a\@secondoftwo
      \fi
    \fi
  \expandafter\endgroup
  \temp@a
  {#2{{\fontencoding{#1}\selectfont#3}}}%
  {#2{\fontencoding{#1}\selectfont#3}}%
}

\def\autofe@options{}
\def\autofe@add@fe#1{\g@addto@macro\autofe@options{\RequirePackage[#1]{fontenc}}}
\DeclareOption{global}{\g@addto@macro\autofe@options{\let\autofe@mode2}}
\DeclareOption{local}{\g@addto@macro\autofe@options{\let\autofe@mode1}}
\DeclareOption{off}{\g@addto@macro\autofe@options{\let\autofe@mode0}}
\DeclareOption*{\expandafter\autofe@add@fe\expandafter{\CurrentOption}}
\ProcessOptions*

\typeout{\meaning\autofe@options}
\autofe@options

\let\autofe@options\undefined
\let\autofe@add@fe\undefined