OSDN Git Service

ec5aecfdd771b143667efc1ffad0645fc5c03e73
[luatex-ja/luatexja.git] / src / patches / lltjp-unicode-math.sty
1 %
2 % lltjp-unicode-math.sty
3 %
4
5 \NeedsTeXFormat{LaTeX2e}
6 \ProvidesPackage{lltjp-unicode-math}[2017/05/05 Patch to unicode-math for LuaTeX-ja]
7
8 \RequirePackage{unicode-math,luatexja}
9
10 \ExplSyntaxOn
11
12 \group_begin:
13   \bool_new:N \lltjp_um_patch_mathgroup_bool
14 \@ifpackagelater{unicode-math}{2015/09/24}{%
15 %%%%%%%% 2015/09/24 0.8c
16   \bool_set_true:N \lltjp_um_patch_mathgroup_bool
17   \cs_gset:Nn \__um_define_math_chars: {
18     \group_begin:
19       \cs_set:Npn \__um_sym:nnn ##1##2##3
20        {
21         \tl_if_in:nnT
22          { \mathord \mathalpha \mathbin \mathrel \mathpunct \mathop \mathfence }
23          {##3}
24         {
25           \exp_last_unbraced:NNx \cs_gset_eq:NN ##2 { \Ucharcat ##1 ~ 12 ~ }
26           \ltjsetmathletter{ ##1 }
27         }
28        }
29       \__um_input_math_symbol_table:
30     \group_end:
31   }
32 }{
33   \cs_if_exist:cTF { __um_cs_set_eq_active_char:Nw } {
34     \tl_set:Nn \l_tmpa_tl { __um_cs_set_eq_active_char:Nw }
35     \bool_set_true:N \lltjp_um_patch_mathgroup_bool
36   }{
37     \tl_set:Nn \l_tmpa_tl { um_cs_set_eq_active_char:Nw }
38   }
39   \cs_gset:cpn { \tl_use:N \l_tmpa_tl } #1 = "#2 \q_nil {%"
40     \group_begin:
41       %\typeout {um: \string#1, \int_from_hex:n {#2}, #2}% <- for debug
42       \char_set_lccode:nn { `! } { "#2 }%"
43       \tex_lowercase:D {
44         \tl_set:Nn \l_tmpa_tl {  \relax
45           \ifmmode!\else{\directlua{tex.globaldefs = 0}\ltj@allalchar!}\fi}
46         \cs_gset_eq:NN #1 \l_tmpa_tl
47       }
48       \ltjsetmathletter{ \int_from_hex:n {#2} }
49     \group_end:
50   }
51 }
52
53 \bool_if:NT \lltjp_um_patch_mathgroup_bool {
54   \cs_gset:Npn \use@mathgroup #1 #2
55    {
56     \mode_if_math:T % <- not sure if this is really necessary since we've just checked for mmode and raised an error if not!
57      {
58       \math@bgroup
59         \cs_if_eq:cNF {M@\f@encoding} #1 {#1}
60         \__um_switchto_literal:
61         \ltj@tempcnta=#2 \expandafter\ltj@@mathJapaneseFonts\string#1\relax%
62         \ifin@ \jfam #2 \relax \else \mathgroup #2 \relax \fi
63       \math@egroup
64      }
65    }
66 }
67 \group_end:
68
69 \ExplSyntaxOff
70
71 \endinput