OSDN Git Service

luatexja-preset: simplify code
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sat, 29 Jul 2017 11:06:51 +0000 (20:06 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sat, 29 Jul 2017 11:06:51 +0000 (20:06 +0900)
src/addons/luatexja-preset.sty

index 1b9f0d4..0c67c9d 100644 (file)
 
 
 %%%%%%%% 存在判定
 
 
 %%%%%%%% 存在判定
-\msg_new:nnn { luatexja-preset }{ no-font }{
-  Font~ for~ #1~ (#2)~ is~ not~found.~ Hence~ I~ substitute~ #3~ (#4)~ for~ it.
-}
-\bool_if:NT \l_ltjpreset_deluxe_bool {
+\cs_new:Nn \ltjpreset_substitute:nnnn {
   \group_begin:
     \suppressfontnotfounderror=1
   \group_begin:
     \suppressfontnotfounderror=1
-    \font \l_ltjpreset_font_test: = "\ltjpreset_font_gt_eb:"\relax
-    \ifx \l_ltjpreset_font_test: \nullfont
-      \msg_warning:nnxxxx { luatexja-preset }{ no-font }
-        { \ltjpreset_font_gt_eb: }{ gt/eb }{ \ltjpreset_font_gt_bx: }{ gt/bx }
-      \cs_gset_eq:NN \ltjpreset_font_gt_eb: \ltjpreset_font_gt_bx:
-    \fi
-    \font \l_ltjpreset_font_test: = "\ltjpreset_font_mc_l:"\relax
-    \ifx \l_ltjpreset_font_test: \nullfont
-      \msg_warning:nnxxxx { luatexja-preset }{ no-font }
-        { \ltjpreset_font_mc_l: }{ mc/l }{ \ltjpreset_font_mc_m: }{ mc/m }
-      \cs_gset_eq:NN \ltjpreset_font_mc_l: \ltjpreset_font_mc_m:
-    \fi
-    \font \l_ltjpreset_font_test: = "\ltjpreset_font_mg_m:"\relax
+    \font \l_ltjpreset_font_test: = "\cs:w ltjpreset_font_#1_#2: \cs_end:"\relax
     \ifx \l_ltjpreset_font_test: \nullfont
       \msg_warning:nnxxxx { luatexja-preset }{ no-font }
     \ifx \l_ltjpreset_font_test: \nullfont
       \msg_warning:nnxxxx { luatexja-preset }{ no-font }
-        { \ltjpreset_font_mg_m: }{ mg/m }{ \ltjpreset_font_gt_bx: }{ gt/bx }
-      \cs_gset_eq:NN \ltjpreset_font_mg_m: \ltjpreset_font_gt_bx:
+        { \cs:w ltjpreset_font_#1_#2: \cs_end: }{ #1/#2 }
+        { \cs:w ltjpreset_font_#3_#4: \cs_end: }{ #3/#4 }
+      \cs_gset_eq:cc { ltjpreset_font_#1_#2: } { ltjpreset_font_#3_#4: }
     \fi
   \group_end:
 }
 
     \fi
   \group_end:
 }
 
+\msg_new:nnn { luatexja-preset }{ no-font }{
+  Font~ for~ #1~ (#2)~ is~ not~found.~ Hence~ I~ substitute~ #3~ (#4)~ for~ it.
+}
+\bool_if:NT \l_ltjpreset_deluxe_bool {
+  \ltjpreset_substitute:nnnn { gt } { eb } { gt } { bx }
+  \ltjpreset_substitute:nnnn { mg } { m  } { gt } { bx }
+  \ltjpreset_substitute:nnnn { mc } { l  } { mc } { m  }
+}
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%% nfss only
 \bool_if:NTF \l_ltjpreset_nfssonly_bool {
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%% nfss only
 \bool_if:NTF \l_ltjpreset_nfssonly_bool {