summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luatexja/patches/lltjp-unicode-math.sty
blob: 2642dd1e4f9c3a0e6b0493dcff27299fe42fd894 (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
%
% lltjp-unicode-math.sty
%

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{lltjp-unicode-math}[2017/11/12 Patch to unicode-math for LuaTeX-ja]

\RequirePackage{unicode-math,luatexja}

\ExplSyntaxOn

\group_begin:
  \bool_new:N \lltjp_um_patch_mathgroup_bool
  \bool_set_true:N \lltjp_um_patch_mathgroup_bool
%% Recent unicode-math (2017-10-02, v0.8g) does not have \ProvidesPackage,
%% So we can't use the date option of \@ifpackageloaded.
  \cs_gset:Nn \__um_define_math_chars: {
    \group_begin:
      \cs_set:Npn \__um_sym:nnn ##1##2##3
       {
        \tl_if_in:nnT
         { \mathord \mathalpha \mathbin \mathrel \mathpunct \mathop \mathfence }
         {##3}
        {
          \exp_last_unbraced:NNx \cs_gset_eq:NN ##2 { \Ucharcat ##1 ~ 12 ~ }
          \ltjsetmathletter{ ##1 }
        }
       }
      \__um_input_math_symbol_table:
    \group_end:
  }

\bool_if:NT \lltjp_um_patch_mathgroup_bool {
  \cs_gset:Npn \use@mathgroup #1 #2
   {
    %\typeout{UM <#1><#2>}
    \mode_if_math:T % <- not sure if this is really necessary since we've just checked for mmode and raised an error if not!
     {
      \math@bgroup
        \cs_if_eq:cNF {M@\f@encoding} #1 {#1}
        \__um_switchto_literal:
        \ltj@tempcnta=#2 \expandafter\ltj@@mathJapaneseFonts\string#1\relax%
        \ifin@ \jfam #2 \relax \else \mathgroup #2 \relax \fi
      \math@egroup
     }
   }
}
\group_end:

\ExplSyntaxOff

\endinput