OSDN Git Service

Improve \ltj@pkgpatch in luatexja-latex.sty.
[luatex-ja/luatexja.git] / src / patches / lltjp-xunicode.sty
1 %
2 % lltjp-xunicode.sty
3 %
4
5 \NeedsTeXFormat{LaTeX2e}
6 \ProvidesPackage{lltjp-xunicode}[2011/11/22 Patch to xunicode for LuaLaTeX-ja]
7
8 \def\UTFencname{EU2}\def\XeTeXpicfile{}
9 \RequirePackage{xunicode,luatexja}
10 {\catcode`\"=12
11 \gdef\check@hexcom@digits@#1#2#3#4#5@!@#6#7#8{%
12  \ifx @#4\relax
13   \UTFacc@warning@{insufficient hex digits #7 for #6-\string#8}%
14  \else
15   \ifcat \active\noexpand#8%
16    \ifx\add@flag\@ne %
17     \expandafter\def\csname\UTFencname\string#8\endcsname{\ltjalchar"#1#2#3#4\relax}%
18     \ifx\unDeFiNed@#8%
19      \ifx\cf@encoding\UTFencname
20       \DeclareTextCommand{#8}{OT1}{\undefined}%
21      \else
22       \DeclareTextCommand{#8}{\cf@encoding}{\undefined}%
23      \fi
24     \else {% macro #8 exists already ...
25       \let\protect\noexpand
26       \edef\UTF@testi{#8}\def\UTF@testii{#8}%
27       \ifx\UTF@testi\UTF@testii\aftergroup\UTF@ignore
28       \else\aftergroup\UTF@doit\fi
29      }%
30      \iffalse
31       % ... but when it isn't robust, make it so
32       \expandafter\let\csname?-\string#8\endcsname#8\relax
33       \edef\next@UTF@{{\cf@encoding}%
34         {\expandafter\noexpand\csname?-\string#8\endcsname}}%
35       \expandafter\DeclareTextCommand\expandafter
36          {\expandafter#8\expandafter}\next@UTF@
37      \fi
38     \fi %
39    \else % \add@flag \z@
40     \expandafter\global\expandafter
41       \let\csname\UTFencname\string#8\endcsname\relax
42    \fi % end of \add@flag switch
43   \else % not active catcode --- shouldn't happen
44   % \typeout{*** did you really mean #8 ? ***}%
45    \ifx\add@flag\@ne %
46     \edef\tmp@name{\expandafter\string\csname\UTFencname\endcsname
47       \expandafter\string\csname#8\endcsname}%
48     \expandafter\def\csname\tmp@name\endcsname{\ltjalchar"#1#2#3#4\relax}%
49     \ifx\cf@encoding\UTFencname
50      \expandafter\DeclareTextCommand\expandafter
51        {\csname#8\endcsname}{OT1}{\undefined}%
52     \else
53      \expandafter\DeclareTextCommand\expandafter
54        {\csname#8\endcsname}{\cf@encoding}{\undefined}%
55     \fi
56    \else % \add@flag \z@
57     \expandafter\global\expandafter\let\csname#8\endcsname\relax
58    \fi % end of \add@flag switch
59   \fi % end of \ifcat
60  \fi}
61 \gdef\check@hex@digits@#1#2#3#4#5@!@#6#7#8#9{%
62  \ifx @#4\relax
63   \UTFacc@warning@{insufficient hex digits #7 for #6-\string#8#9}%
64  \else
65   \def\UTFchar{\ltjalchar"#1#2#3#4\relax}%
66   \expandafter\expandafter\expandafter\declare@utf@composite
67   \expandafter\expandafter\expandafter
68    {\expandafter\csname#6\endcsname}{\UTFchar}{#8}{#9}\relax
69  \fi}
70 %\gdef\add@UTF@accent#1#2#3{#2\ltjalchar"#1\relax}
71 \gdef\add@UTF@accent#1#2#3{\ifx\relax#2\relax\ltjalchar"#3\else
72  \ifx\ #2\relax\ltjalchar"#3\else
73  \expandafter\ifx\UTF@space#2\relax\ltjalchar"#3\else
74  \ifx~#2\ltjalchar"#3\else#2\ltjalchar"#1\fi\fi\fi\fi\relax}
75 \gdef\add@UTF@accents#1#2#3{#2\ltjalchar"#1\ltjalchar"#3\relax}
76 }
77 % If unicode-math is already loaded, the following error occurs:
78 %    ! Undefined control sequence.
79 %    \hbar ->\hslash 
80 % Therefore temporarily set \hbar=\relax.
81 \let\ltj@tmpa\hbar
82 \let\hbar\relax
83 \ReloadXunicode{EU2}
84 \makeatletter
85 \let\hbar\ltj@tmpa
86 \endinput
87
88 %% the following patch is needed to xunicode.sty:
89 %% 
90 --- /opt/texlive/2011/texmf-dist/tex/xelatex/xunicode/xunicode.sty      2011-09-12 08:31:47.000000000 +0900
91 +++ xunicode.sty        2011-11-16 22:06:17.061413113 +0900
92 @@ -1475,7 +1475,11 @@
93  
94  \newtoks\tipasavetokens
95  \newtoks\tipachecktokens
96 +
97 +\fi
98  \newif\iftipaonetoken
99 +\expandafter\ifx\csname ReloadXunicode\endcsname\relax
100 +
101  \def\tipalasttoken{!@! do nothing with this !@!}
102  \def\tipacatchonechar#1{\begingroup
103   \def\textipa##1{##1}% prevent recursion