+ \cs_gset:cpn { \tl_use:N \l_tmpa_tl } #1 = "#2 \q_nil {%"
+ \group_begin:
+ %\typeout {um: \string#1, \int_from_hex:n {#2}, #2}% <- for debug
+ \char_set_lccode:nn { `! } { "#2 }%"
+ \tex_lowercase:D {
+ \tl_set:Nn \l_tmpa_tl { \relax
+ \ifmmode!\else{\directlua{tex.globaldefs = 0}\ltj@allalchar!}\fi}
+ \cs_gset_eq:NN #1 \l_tmpa_tl
+ }
+ \ltjsetmathletter{ \int_from_hex:n {#2} }
+ \group_end:
+ }
+}
+
+\bool_if:NT \lltjp_um_patch_mathgroup_bool {
+ \cs_gset:Npn \use@mathgroup #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
+ }
+ }
+}