OSDN Git Service

fix "Command `\colon' already defined" error when fontspec is loaded without no-math...
[luatex-ja/luatexja.git] / src / patches / lltjp-xunicode.sty
1 %
2 % lltjp-xunicode.sty
3 %
4
5 \NeedsTeXFormat{LaTeX2e}
6 \ProvidesPackage{lltjp-xunicode}[2013/05/14 Patch to xunicode for LuaTeX-ja]
7
8 \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{\ifx\relax#2\relax\ltjalchar"#3\else
71  \ifx\ #2\relax\ltjalchar"#3\else
72  \expandafter\ifx\UTF@space#2\relax\ltjalchar"#3\else
73  \ifx~#2\ltjalchar"#3\else#2\ltjalchar"#1\fi\fi\fi\fi\relax}
74 \gdef\add@UTF@accents#1#2#3{#2\ltjalchar"#1\ltjalchar"#3\relax}
75 }
76 % If unicode-math is already loaded, the following error occurs:
77 %    ! Undefined control sequence.
78 %    \hbar ->\hslash
79 % Therefore temporarily set \hbar=\relax.
80 \let\ltj@tmpa\hbar
81 \let\hbar\relax
82
83 \let\ltj@tmpb\iftipaonetoken
84 \let\iftipaonetoken\relax
85 \typeout{UTFencname: \UTFencname}
86 \let\ltj@temp=\@temp
87 \edef\@temp{\noexpand\ReloadXunicode{\UTFencname}}\@temp
88 \makeatletter
89 \let\@temp=\ltj@temp\let\ltj@temp\relax
90 \let\hbar\ltj@tmpa
91 \let\iftipaonetoken\ltj@tmpb
92 \let\ltj@tmpb\relax % no more an if-token
93
94 %% ticket 30501
95 {\catcode`\!0\catcode`\\11!catcode`!2 11!catcode`!?11!catcode`!-11
96  !expandafter!gdef!csname!UTFencname \nobreakspace!endcsname{!?-\nobreakspace}%
97 }
98
99 \endinput