OSDN Git Service

d815d8d24531b104f87b8c1aca58b7cbe86b3dbf
[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-10-08 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   \bool_set_true:N \lltjp_um_patch_mathgroup_bool
15 %% Recent unicode-math (2017-10-02, v0.8g) does not have \ProvidesPackage,
16 %% So we can't use the date option of \@ifpackageloaded.
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 \bool_if:NT \lltjp_um_patch_mathgroup_bool {
34   \cs_gset:Npn \use@mathgroup #1 #2
35    {
36     %\typeout{UM <#1><#2>}
37     \mode_if_math:T % <- not sure if this is really necessary since we've just checked for mmode and raised an error if not!
38      {
39       \math@bgroup
40         \cs_if_eq:cNF {M@\f@encoding} #1 {#1}
41         \__um_switchto_literal:
42         \ltj@tempcnta=#2 \expandafter\ltj@@mathJapaneseFonts\string#1\relax%
43         \ifin@ \jfam #2 \relax \else \mathgroup #2 \relax \fi
44       \math@egroup
45      }
46    }
47 }
48 \group_end:
49
50 \ExplSyntaxOff
51
52 \endinput