2 \ProvidesPackage{luatexja-preset}[2024-03-30 Japanese font presets]
4 \RequirePackage{expl3,l3keys2e}
5 \RequirePackage{luatexja}
9 \msg_new:nnn { luatexja-preset }{ ltj-fontspec }{
10 The~ luatexja-fontspec~ package~ is~ loaded~ already.~
11 Hence~ we~ ignore~ `nfssonly'~option.
13 \msg_new:nnn { luatexja-preset }{ no-font }{
14 Font~ #1~ (#2)~ is~ not~found.~ Hence~ I~ substitute~ #3~ (#4)~ for~ it.
16 \msg_new:nnn { luatexja-preset }{ scale }{
17 Japanese~fonts~will~be~scaled~by~#1.
20 \msg_new:nnn { luatexja-preset }{ exist-preset-nooverwrite }{
21 The~ preset~ `#1'~ is~ already~ defined.~
22 To~ redefine~ this~ preset,~ use~ \str_use:N \c_backslash_str ltjnewpreset*~ instead.
24 \msg_new:nnn { luatexja-preset }{ exist-preset-overwrite }{
25 The~ preset~ `#1'~ is~ redefined.
28 \msg_new:nnn { luatexja-preset }{ illegal-preset-name }{
29 The~ preset~ `#1'~ cannot~ be~ defined,~
30 since~ the~ luatexja-preset~ package~ an~ option~ with~ the~ same~ name.
33 \seq_new:N \g__ltjpreset_presets_seq
35 \keys_define:nn { luatexja-preset }{
37 \PassOptionsToPackage { \l_keys_key_str } { luatexja-fontspec },
38 scale .code:n = \gdef\Cjascale{#1},
40 \renewcommand\jttdefault{\gtdefault}\@ltj@match@familytrue
41 \PassOptionsToPackage { match } { luatexja-fontspec },
42 match .value_forbidden:n = true,
43 __custom .bool_set:N = \g__ltjpreset_custom_bool, __custom .groups:n = { preset },
44 __office .bool_set:N = \g__ltjpreset_office_bool, __office .groups:n = { preset },
45 __noembed .bool_set:N = \g__ltjpreset_noembed_bool, __noembed .groups:n = { preset },
47 \cs_new:Nn \__ltjpreset_declare_option:nn {
48 \keys_define:nn { luatexja-preset }{
50 #1 .value_forbidden:n = true
53 \cs_new:Nn \ltjpreset_declare_preset:nn {
54 \keys_define:nn { luatexja-preset }{
56 #1 .value_forbidden:n = true, #1 .groups:n = { preset },
58 \seq_put_right:Nn \g__ltjpreset_presets_seq { #1 }
60 \cs_generate_variant:Nn \ltjpreset_declare_preset:nn {ne}
61 \cs_new:Nn \__ltjpreset_declare_bool_option:nn {
62 \bool_new:c { g__ltjpreset_#1_bool }
63 \bool_set_false:c { g__ltjpreset_#1_bool }
64 \keys_define:nn { luatexja-preset }{
65 #1 .bool_set:c = { g__ltjpreset_#1_bool },
66 #2 .bool_set_inverse:c = { g__ltjpreset_#1_bool },
67 #1 .default:n = true, #2 .default:n = true,
72 \__ltjpreset_declare_bool_option:nn { nfssonly }{ fontspec }
73 \__ltjpreset_declare_bool_option:nn { bold }{ nobold }
74 \__ltjpreset_declare_bool_option:nn { expert }{ noexpert }
75 \__ltjpreset_declare_bool_option:nn { deluxe }{ nodeluxe }
76 \__ltjpreset_declare_bool_option:nn { nocheck }{ check }
79 \tl_new:N \__ltjpreset_use_jfm_yoko_tl % 使用する JFM(横)
80 \tl_set:Nn \__ltjpreset_use_jfm_yoko_tl {\ltj@stdyokojfm}
81 \tl_new:N \__ltjpreset_use_jfm_tate_tl % 使用する JFM(縦)
82 \tl_set:Nn \__ltjpreset_use_jfm_tate_tl {\ltj@stdtatejfm}
83 \__ltjpreset_declare_option:nn{jis}{\tl_set:Nn \__ltjpreset_use_jfm_yoko_tl {jis}} % jis
84 \__ltjpreset_declare_option:nn{ujis}{\tl_set:Nn \__ltjpreset_use_jfm_yoko_tl {ujis}} % ujis
87 \tl_new:N \l__ltjpreset_kanji_shape_tl
88 \__ltjpreset_declare_option:nn{90jis}{ \tl_set:Nn \l__ltjpreset_kanji_shape_tl { , CJKShape=JIS1990 }} % 90jis
89 \__ltjpreset_declare_option:nn{jis90}{ \tl_set:Nn \l__ltjpreset_kanji_shape_tl { , CJKShape=JIS1990 }} % 90jis
90 \__ltjpreset_declare_option:nn{jis2004}{\tl_set:Nn \l__ltjpreset_kanji_shape_tl { , CJKShape=JIS2004 }} % jis2004
91 \__ltjpreset_declare_option:nn{2004jis}{\tl_set:Nn \l__ltjpreset_kanji_shape_tl { , CJKShape=JIS2004 }} % jis2004
94 \prop_new:N \g__ltjpreset_font_prop
95 \keys_define:nn { luatexja-preset } {
97 \prop_put:Nnn \g__ltjpreset_font_prop { mc-l } {#1}
98 \prop_put:Nnn \g__ltjpreset_font_prop { mc-m } {#1}
99 \prop_put:Nnn \g__ltjpreset_font_prop { mc-b } {#1},
100 mc .groups:n = { preset }, mc .value_required:n = true,
102 \prop_put:Nnn \g__ltjpreset_font_prop { mc-b } {#1},
103 mc-bx .groups:n = { preset }, mc-bx .value_required:n = true,
105 \prop_put:Nnn \g__ltjpreset_font_prop { gt-u } {#1}
106 \prop_put:Nnn \g__ltjpreset_font_prop { gt-d } {#1}
107 \prop_put:Nnn \g__ltjpreset_font_prop { gt-b } {#1}
108 \prop_put:Nnn \g__ltjpreset_font_prop { gt-eb } {#1},
110 \prop_put:Nnn \g__ltjpreset_font_prop { gt-b } {#1},
111 gt-m .code:n = % gtfamily , medium series
112 \prop_put:Nnn \g__ltjpreset_font_prop { gt-u } {#1}
113 \prop_put:Nnn \g__ltjpreset_font_prop { gt-d } {#1},
114 gt .groups:n = { preset }, gt .value_required:n = true,
115 gt-m .groups:n = { preset }, gt-m .value_required:n = true,
116 gt-bx .groups:n = { preset }, gt-bx .value_required:n = true,
118 \cs_set:Nn \ltjpreset_define_preset_prop:n {
119 \keys_define:nn { luatexja-preset } {
120 #1 .code:n = \prop_put:Non \g__ltjpreset_font_prop { #1 } { ##1 },
121 #1 .groups:n = { preset }, #1 .value_required:n = true,
124 \ltjpreset_define_preset_prop:n { mc-l }
125 \ltjpreset_define_preset_prop:n { mc-m }
126 \ltjpreset_define_preset_prop:n { mc-b }
127 \ltjpreset_define_preset_prop:n { gt-u }
128 \ltjpreset_define_preset_prop:n { gt-d }
129 \ltjpreset_define_preset_prop:n { gt-b }
130 \ltjpreset_define_preset_prop:n { gt-eb}
131 \ltjpreset_define_preset_prop:n { mg-m }
133 \cs_new:Nn \__ltjpreset_set_uni:nn {
134 mc = #1, gt = #2, mc-b = #2, mg-m = #2,
135 __custom = false, __office = false, __noembed = false,
137 \cs_new:Npn \__ltjpreset_set_office:nn #1 #2{
138 mc = #1, mc-b = HGMinchoE ,
139 gt-d = HGGothicM , gt-b = HGGothicE ,
140 gt-u = #2 , gt-eb = HGSoeiKakugothicUB ,
141 mg-m = HGMaruGothicMPRO,
142 __custom = false, __office = true, __noembed = false,
148 \keys_define:nn { luatexja-preset }{
149 custom .meta:n = { #1, __custom = true, },
150 custom .value_required:n = true,
151 jfm_yoko .tl_set:N = \__ltjpreset_use_jfm_yoko_tl,
152 jfm_tate .tl_set:N = \__ltjpreset_use_jfm_tate_tl,
157 \ltjpreset_declare_preset:ne{kozuka-pro}{
158 mc-m = KozMinPro-Regular, mc-b = KozMinPro-Bold,
159 gt-d = KozGoPro-Regular, gt-b = KozGoPro-Bold,
160 gt-u = KozGoPro-Medium, gt-eb = KozGoPro-Heavy,
161 mg-m = KozGoPro-Heavy, mc-l = KozMinPro-Light,
162 __custom = false, __office = false, __noembed = false,
165 \ltjpreset_declare_preset:ne{kozuka-pr6}{
166 mc-m = KozMinProVI-Regular, mc-b = KozMinProVI-Bold,
167 gt-d = KozGoProVI-Regular, gt-b = KozGoProVI-Bold,
168 gt-u = KozGoProVI-Medium, gt-eb = KozGoProVI-Heavy,
169 mg-m = KozGoProVI-Heavy, mc-l = KozMinProVI-Light,
170 __custom = false, __office = false, __noembed = false,
173 \ltjpreset_declare_preset:ne{kozuka-pr6n}{
174 mc-m = KozMinPr6N-Regular, mc-b = KozMinPr6N-Bold,
175 gt-d = KozGoPr6N-Regular, gt-b = KozGoPr6N-Bold,
176 gt-u = KozGoPr6N-Medium, gt-eb = KozGoPr6N-Heavy,
177 mg-m = KozGoPr6N-Heavy, mc-l = KozMinPr6N-Light,
178 __custom = false, __office = false, __noembed = false,
182 \ltjpreset_declare_preset:ne{hiragino-pro}{
183 mc-m = HiraMinPro-W3, mc-b = HiraMinPro-W6,
184 gt-d = HiraKakuPro-W3, gt-b = HiraKakuPro-W6,
185 gt-u = HiraKakuPro-W6, gt-eb = HiraKakuStd-W8,
186 mg-m = HiraMaruPro-W4, mc-l = HiraMinPro-W2,
187 __custom = false, __office = false, __noembed = false,
189 \ltjpreset_declare_preset:ne{hiragino-pron}{
190 mc-m = HiraMinProN-W3, mc-b = HiraMinProN-W6,
191 gt-d = HiraKakuProN-W3, gt-b = HiraKakuProN-W6,
192 gt-u = HiraKakuProN-W6, gt-eb = HiraKakuStdN-W8,
193 mg-m = HiraMaruProN-W4, mc-l = HiraMinProN-W2,
194 __custom = false, __office = false, __noembed = false,
198 \ltjpreset_declare_preset:ne{bizud}{
199 mc = BIZ-UDMinchoM.ttc,
200 gt-d = BIZ-UDGothicR.ttc, gt-b = BIZ-UDGothicB.ttc,
201 gt-u = BIZ-UDGothicR.ttc, gt-eb = BIZ-UDGothicB.ttc,
202 mg-m = BIZ-UDGothicB.ttc,
203 __custom = false, __office = false, __noembed = false,
205 \ltjpreset_declare_preset:ne{morisawa-pro}{
206 mc = A-OTF-RyuminPro-Light.otf, mc-b = A-OTF-FutoMinA101Pro-Bold.otf,
207 gt-d = A-OTF-GothicBBBPro-Medium.otf , gt-b = A-OTF-FutoGoB101Pro-Bold.otf,
208 gt-u = A-OTF-GothicBBBPro-Medium.otf , gt-eb = A-OTF-MidashiGoPro-MB31.otf,
209 mg-m = A-OTF-Jun101Pro-Light.otf,
210 __custom = false, __office = false, __noembed = false,
212 \ltjpreset_declare_preset:ne{morisawa-pr6n}{
213 mc = A-OTF-RyuminPr6N-Light.otf, mc-b = A-OTF-FutoMinA101Pr6N-Bold.otf,
214 gt-d = A-OTF-GothicBBBPr6N-Medium.otf , gt-b = A-OTF-FutoGoB101Pr6N-Bold.otf,
215 gt-u = A-OTF-GothicBBBPr6N-Medium.otf , gt-eb = A-OTF-MidashiGoPr6N-MB31.otf,
216 mg-m = A-OTF-ShinMGoPr6N-Light.otf,
217 __custom = false, __office = false, __noembed = false,
221 \ltjpreset_declare_preset:ne{yu-win}{
222 mc-m = YuMincho-Regular, mc-b = YuMincho-Demibold,
223 gt-d = YuGothic-Regular, gt-b = YuGothic-Bold,
224 gt-u = YuGothic-Regular, gt-eb = YuGothic-Bold,
225 mg-m = YuGothic-Bold, mc-l = YuMincho-Light,
226 __custom = false, __office = false, __noembed = false,
229 \ltjpreset_declare_preset:ne{yu-win10}{
230 mc-m = YuMincho-Regular, mc-b = YuMincho-Demibold,
231 gt-d = YuGothic-Regular, gt-b = YuGothic-Bold,
232 gt-u = YuGothic-Medium, gt-eb = YuGothic-Bold,
233 mg-m = YuGothic-Bold, mc-l = YuMincho-Light,
234 __custom = false, __office = false, __noembed = false,
238 % according to http://support.apple.com/kb/HT5944
239 \ltjpreset_declare_preset:ne{yu-osx}{
240 mc = YuMincho~Medium, mc-b = YuMincho~Demibold,
241 gt-d = YuGothic~Medium, gt-u = YuGothic~Medium,
242 gt-b = YuGothic~Bold, gt-eb = YuGothic~Bold,
243 mg-m = YuGothic~Bold,
244 __custom = false, __office = false, __noembed = false,
248 \ltjpreset_declare_preset:ne{moga-mobo}{
249 mc = Moga90Mincho, mc-b = Moga90Mincho~Bold,
250 gt-d = Moga90Gothic, gt-b = Moga90Gothic~Bold,
251 gt-u = Moga90Gothic, gt-eb = Moga90Gothic~Bold,
253 __custom = false, __office = false, __noembed = false,
255 \ltjpreset_declare_preset:ne{moga-mobo-ex}{
256 mc = MogaEx90Mincho, mc-b = MogaEx90Mincho~Bold,
257 gt-d = MogaEx90Gothic, gt-b = MogaEx90Gothic~Bold,
258 gt-u = MogaEx90Gothic, gt-eb = MogaEx90Gothic~Bold,
259 mg-m = MoboEx90Gothic,
260 __custom = false, __office = false, __noembed = false,
264 \ltjpreset_declare_preset:ne{ume}{
266 gt-d = Ume~Gothic, gt-b = Ume~Gothic~O5,
267 gt-u = Ume~Gothic~O5, gt-eb = Ume~Gothic~O5,
268 mg-m = Ume~Gothic~O4,
269 __custom = false, __office = false, __noembed = false,
272 % Source Han {Serif,Sans}
273 \ltjpreset_declare_preset:ne{sourcehan}{
274 mc-m = Source~Han~Serif~Regular,
275 mc-b = Source~Han~Serif~Bold,
276 gt-d = Source~Han~Sans~Regular,
277 gt-b = Source~Han~Sans~Bold,
278 gt-u = Source~Han~Sans~Medium,
279 gt-eb = Source~Han~Sans~Heavy,
280 mg-m = Source~Han~Sans~Medium,
281 mc-l = Source~Han~Serif~Light,
282 __custom = false, __office = false, __noembed = false,
284 \ltjpreset_declare_preset:ne{sourcehan-jp}{
285 mc-m = Source~Han~Serif~JP~Regular,
286 mc-b = Source~Han~Serif~JP~Bold,
287 gt-d = Source~Han~Sans~JP~Regular,
288 gt-b = Source~Han~Sans~JP~Bold,
289 gt-u = Source~Han~Sans~JP~Medium,
290 gt-eb = Source~Han~Sans~JP~Heavy,
291 mg-m = Source~Han~Sans~JP~Medium,
292 mc-l = Source~Han~Serif~JP~Light,
293 __custom = false, __office = false, __noembed = false,
295 \ltjpreset_declare_preset:ne{noto-otc}{
296 mc-m = Noto~Serif~CJK~Regular,
297 mc-b = Noto~Serif~CJK~Bold,
298 gt-d = Noto~Sans~CJK~Regular,
299 gt-b = Noto~Sans~CJK~Bold,
300 gt-u = Noto~Sans~CJK~Medium,
301 gt-eb = Noto~Sans~CJK~Black,
302 mg-m = Noto~Sans~CJK~Medium,
303 mc-l = Noto~Serif~CJK~Light,
304 __custom = false, __office = false, __noembed = false,
306 \ltjpreset_declare_preset:ne{noto-otf}{
307 mc-m = Noto~Serif~CJK~JP~Regular,
308 mc-b = Noto~Serif~CJK~JP~Bold,
309 gt-d = Noto~Sans~CJK~JP~Regular,
310 gt-b = Noto~Sans~CJK~JP~Bold,
311 gt-u = Noto~Sans~CJK~JP~Medium,
312 gt-eb = Noto~Sans~CJK~JP~Black,
313 mg-m = Noto~Sans~CJK~JP~Medium,
314 mc-l = Noto~Serif~CJK~JP~Light,
315 __custom = false, __office = false, __noembed = false,
317 \ltjpreset_declare_preset:ne{noto}{
320 \ltjpreset_declare_preset:ne{noto-jp}{
321 mc-m = Noto~Serif~JP~Regular,
322 mc-b = Noto~Serif~JP~Bold,
323 gt-d = Noto~Sans~JP~Regular,
324 gt-b = Noto~Sans~JP~Bold,
325 gt-u = Noto~Sans~JP~Medium,
326 gt-eb = Noto~Sans~JP~Black,
327 mg-m = Noto~Sans~JP~Medium,
328 mc-l = Noto~Serif~JP~Light,
329 __custom = false, __office = false, __noembed = false,
332 % HaranoAji {Mincho, Gothic}
333 \ltjpreset_declare_preset:ne{haranoaji}{
334 mc-m = HaranoAjiMincho-Regular.otf,
335 mc-b = HaranoAjiMincho-Bold.otf,
336 gt-d = HaranoAjiGothic-Regular.otf,
337 gt-b = HaranoAjiGothic-Bold.otf,
338 gt-u = HaranoAjiGothic-Medium.otf,
339 gt-eb = HaranoAjiGothic-Heavy.otf,
340 mg-m = HaranoAjiGothic-Medium.otf,
341 mc-l = HaranoAjiMincho-Light.otf,
342 __custom = false, __office = false, __noembed = false,
347 \ltjpreset_declare_preset:ne{ipa}{
348 \__ltjpreset_set_uni:nn { IPAMincho } { IPAGothic }
350 \ltjpreset_declare_preset:ne{ipaex}{
351 \__ltjpreset_set_uni:nn { IPAExMincho } { IPAExGothic }
353 \ltjpreset_declare_preset:ne{ms}{
354 \__ltjpreset_set_uni:nn { MS-Mincho } { MS-Gothic }
357 % {ipa,ipaex,ms}-dx % Office 付属フォントを利用
358 \ltjpreset_declare_preset:ne{ipaex-hg}{
359 \__ltjpreset_set_office:nn { IPAExMincho } { IPAExGothic }
361 \ltjpreset_declare_preset:ne{ipa-hg}{
362 \__ltjpreset_set_office:nn { IPAMincho } { IPAGothic }
364 \ltjpreset_declare_preset:ne{ms-hg}{
365 \__ltjpreset_set_office:nn { MS-Mincho } { MS-Gothic }
370 \ltjpreset_declare_preset:ne{noembed}{
371 \__ltjpreset_set_uni:nn { Ryumin-Light } { GothicBBB-Medium },
372 __custom = false, __office = false, __noembed = true,
375 \keys_set:nn {luatexja-preset} { haranoaji } %% old: ipaex
376 \ProcessKeysOptions { luatexja-preset }
377 \@ifpackageloaded{luatexja-fontspec}{
378 \bool_if:NT \g__ltjpreset_nfssonly_bool
379 { \msg_warning:nn { luatexja-preset }{ ltj-fontspec } }
380 \bool_set_false:N \g__ltjpreset_nfssonly_bool
383 %%%%%%%% main routine
385 \cs_new:Nn \__ltjpreset_extract_fonts: {
386 %% MogaMincho の場合は 90 をつける/はずす
387 \bool_if:NF \g__ltjpreset_custom_bool {
388 \tl_set:Nn \l_tmpa_tl {, CJKShape=JIS2004 }
389 \tl_if_eq:NNT \l__ltjpreset_kanji_shape_tl \l_tmpa_tl {
390 \tl_set:Ne \l_tmpb_tl { \prop_item:Nn \g__ltjpreset_font_prop { mc-m } }
391 \tl_if_in:NnT \l_tmpb_tl { Moga90Mincho } {
392 \prop_clear:N \l_tmpa_prop
393 \prop_map_inline:Nn \g__ltjpreset_font_prop {
394 \tl_set:Nn \l_tmpb_tl { ##2 } \tl_remove_all:Nn \l_tmpb_tl {90}
395 \prop_put:Nne \l_tmpa_prop { ##1 } { \tl_use:N \l_tmpb_tl }
397 \prop_set_eq:NN \g__ltjpreset_font_prop \l_tmpa_prop
399 \tl_if_in:NnT \l_tmpb_tl { MogaEx90Mincho } {
400 \prop_clear:N \l_tmpa_prop
401 \prop_map_inline:Nn \g__ltjpreset_font_prop {
402 \tl_set:Nn \l_tmpb_tl { ##2 } \tl_remove_all:Nn \l_tmpb_tl {90}
403 \prop_put:Nne \l_tmpa_prop { ##1 } { \tl_use:N \l_tmpb_tl }
405 \prop_set_eq:NN \g__ltjpreset_font_prop \l_tmpa_prop
410 \cs_set:Ne \__ltjpreset_font_mc_l: { \prop_item:Nn \g__ltjpreset_font_prop { mc-l } }
411 \cs_set:Ne \__ltjpreset_font_mc_m: { \prop_item:Nn \g__ltjpreset_font_prop { mc-m } }
412 \cs_set:Ne \__ltjpreset_font_mc_b: { \prop_item:Nn \g__ltjpreset_font_prop { mc-b } }
413 \cs_set:Ne \__ltjpreset_font_gt_m: { \prop_item:Nn \g__ltjpreset_font_prop { gt-d } }
414 \cs_set:Ne \__ltjpreset_font_gt_u: { \prop_item:Nn \g__ltjpreset_font_prop { gt-u } }
415 \cs_set:Ne \__ltjpreset_font_gt_b: { \prop_item:Nn \g__ltjpreset_font_prop { gt-b } }
416 \cs_set:Ne \__ltjpreset_font_gt_eb: { \prop_item:Nn \g__ltjpreset_font_prop { gt-eb } }
417 \cs_set:Ne \__ltjpreset_font_mg_m: { \prop_item:Nn \g__ltjpreset_font_prop { mg-m } }
418 %% HG 系フォント + JIS2004/90JIS のときはフォント名を置換
419 \bool_if:nT { !\g__ltjpreset_custom_bool && \g__ltjpreset_office_bool } {
420 \tl_set:Nn \l_tmpa_tl {, CJKShape=JIS2004 }
421 \tl_if_eq:NNT \l__ltjpreset_kanji_shape_tl \l_tmpa_tl {
422 \cs_set:Ne \__ltjpreset_font_mc_b: { hgrme04.ttc }
423 \cs_set:Ne \__ltjpreset_font_gt_b: { hgrge04.ttc }
424 \cs_set:Ne \__ltjpreset_font_gt_eb: { hgrsgu04.ttc }
425 \cs_set:Ne \__ltjpreset_font_mg_m: { hgrsmp04.ttf }
426 \cs_set_eq:NN \__ltjpreset_font_gt_m: \__ltjpreset_font_gt_u:
427 % HG ゴシックM のときはそうはいかないので 1 ウェイト時のゴシック体を使う
429 \tl_set:Nn \l_tmpa_tl {, CJKShape=JIS1990 }
430 \tl_if_eq:NNT \l__ltjpreset_kanji_shape_tl \l_tmpa_tl {
431 \cs_set:Ne \__ltjpreset_font_mc_b: { hgrme.ttc }
432 \cs_set:Ne \__ltjpreset_font_gt_b: { hgrge.ttc }
433 \cs_set:Ne \__ltjpreset_font_gt_eb: { hgrsgu.ttc }
434 \cs_set:Ne \__ltjpreset_font_mg_m: { hgrsmp.ttf }
438 \tl_set:Ne \l_tmpa_tl { \__ltjpreset_font_mc_l: }
439 \tl_if_empty:NT \l_tmpa_tl {\tl_set:Nn \l_tmpa_tl {~}}
440 \cs_set:Ne \__ltjpreset_font_mc_l: {
441 \tl_if_blank:nTF \l_tmpa_tl { \__ltjpreset_font_mc_m: } {\tl_use:N \l_tmpa_tl }
444 \bool_if:NTF \g__ltjpreset_deluxe_bool {
445 \bool_if:NT \g__ltjpreset_bold_bool {
446 \cs_set_eq:NN \__ltjpreset_font_mc_b: \__ltjpreset_font_gt_b:
449 \bool_if:NTF \g__ltjpreset_bold_bool
450 { \cs_set_eq:NN \__ltjpreset_font_gt_m: \__ltjpreset_font_gt_b: }
451 { \cs_set_eq:NN \__ltjpreset_font_gt_m: \__ltjpreset_font_gt_u: }
452 \cs_set_eq:NN \__ltjpreset_font_gt_b: \__ltjpreset_font_gt_m:
453 \cs_set_eq:NN \__ltjpreset_font_mc_b: \__ltjpreset_font_gt_m:
457 %%%%%%%% フォント名を \l__ltjpreset_font_name: に格納
458 \clist_new:N \l__ltjpreset_extensions_clist
459 \clist_set:Nn \l__ltjpreset_extensions_clist {.otf,.ttf,.OTF,.TTF,.ttc,.TTC}
460 \prg_new_conditional:Nnn \__ltjpreset_if_detect_external:n {TF} {
461 \clist_map_inline:Nn \l__ltjpreset_extensions_clist {
462 \bool_set_false:N \l_tmpa_bool
463 \tl_if_in:nnT {#1 <= end_of_string} {##1 <= end_of_string}
464 { \bool_set_true:N \l_tmpa_bool \clist_map_break: }
466 \bool_if:NTF \l_tmpa_bool \prg_return_true: \prg_return_false:
468 \cs_new:Nn \__ltjpreset_wrap_fontname:n {
469 \__ltjpreset_if_detect_external:nTF { #1 }
470 { \cs_set:Nn \l__ltjpreset_font_name: { [#1] } }
471 { \cs_set:Nn \l__ltjpreset_font_name: { "#1" } }
473 \cs_generate_variant:Nn \__ltjpreset_wrap_fontname:n { e }
476 \cs_new:Nn \__ltjpreset_substitute:nnnn {
478 \suppressfontnotfounderror=1
479 \cs_if_exist:cTF { __ltjpreset_font_#1_#2: } {
480 \bool_if:NF \g__ltjpreset_nocheck_bool {
481 \__ltjpreset_wrap_fontname:e { \cs:w __ltjpreset_font_#1_#2: \cs_end: }
482 \font \g__ltjpreset_font_test: = \l__ltjpreset_font_name:\relax
483 \ifx \g__ltjpreset_font_test: \nullfont
484 \msg_warning:nneeee { luatexja-preset }{ no-font }
485 { \cs:w __ltjpreset_font_#1_#2: \cs_end: }{ #1/#2 }
486 { \cs:w __ltjpreset_font_#3_#4: \cs_end: }{ #3/#4 }
487 \cs_gset_eq:cc { __ltjpreset_font_#1_#2: } { __ltjpreset_font_#3_#4: }
490 } { \cs_gset_eq:cc { __ltjpreset_font_#1_#2: } { __ltjpreset_font_#3_#4: } }
494 %%%%%%%% deluxe (\mgfamily はあとで定義)
495 \bool_if:NTF \g__ltjpreset_deluxe_bool {
496 \cs_new:Nn \__ltjpreset_check_deluxe_existence: {
497 \__ltjpreset_substitute:nnnn { gt } { eb } { gt } { b }
498 \__ltjpreset_substitute:nnnn { mg } { m } { gt } { b }
499 \__ltjpreset_substitute:nnnn { mc } { l } { mc } { m }
502 \DeclareRobustCommand\ltseries { \not@math@alphabet\ltseries\relax\fontseries\ltdefault\selectfont }
504 \DeclareRobustCommand\ebseries { \not@math@alphabet\ebseries\relax\fontseries\ebdefault\selectfont }
505 \DeclareRobustCommand\gtebfamily { \gtfamily\fontseries{\ebdefault}\selectfont }
506 \DeclareTextFontCommand{\textlt}{\ltseries}
507 \DeclareTextFontCommand{\texteb}{\ebseries}
509 \cs_set_eq:NN \__ltjpreset_check_deluxe_existence: \prg_do_nothing:
512 \int_new:N \g__ltjpreset_applycount_int
514 \bool_if:NTF \g__ltjpreset_nfssonly_bool {
515 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
517 \cs_if_exist:NF \Cjascale {
519 \fontsize{16}{16}\selectfont
520 \cs_gset:Npx \Cjascale { \fp_to_decimal:n {\zw / 16} }
524 \fp_compare:nNnF \Cjascale = 1
525 { \msg_warning:nne { luatexja-preset }{ scale }{ \Cjascale } }
527 % {1: encoding}{2: family}{3: series}{4: shape}{5: fontname}{6: feature}{7: scale}
528 \cs_new:Nn \__ltjpreset_declare_font_shape:nnnnnnn {
529 \DeclareFontShape{#1}{#2}{#3}{#4}{ <-> s*[#7]
530 \bool_if:NT \g__ltjpreset_noembed_bool {psft:} #5
531 ;-kern \tl_use:N \l__ltjpreset_kanji_shape_tl; #6 } {}
533 \cs_new:Nn \__ltjpreset_define_family:nnn {
534 \__ltjpreset_wrap_fontname:e { #3 }
535 \__ltjpreset_declare_font_shape:nnnnnnn { JY3 }
536 { ltjp #1 \int_to_arabic:n { \g__ltjpreset_applycount_int }} { #2 } { n }
537 { \l__ltjpreset_font_name: : jfm=\tl_use:N \__ltjpreset_use_jfm_yoko_tl }
538 { script=hani \bool_if:NT \g__ltjpreset_expert_bool { ;+hkna } }
540 \__ltjpreset_declare_font_shape:nnnnnnn { JT3 }
541 { ltjp #1 \int_to_arabic:n { \g__ltjpreset_applycount_int }} { #2 } { n }
542 { \l__ltjpreset_font_name: : jfm=\tl_use:N \__ltjpreset_use_jfm_tate_tl }
543 { script=hani \bool_if:NT \g__ltjpreset_expert_bool { ;+vkna } }
545 \bool_if:NT \g__ltjpreset_expert_bool {
546 \__ltjpreset_declare_font_shape:nnnnnnn { JY3 }
547 { ltjp #1 \int_to_arabic:n { \g__ltjpreset_applycount_int }} { #2 } { rb }
548 { \l__ltjpreset_font_name: : jfm=\tl_use:N \__ltjpreset_use_jfm_yoko_tl } { script=kana; +ruby }
550 \__ltjpreset_declare_font_shape:nnnnnnn { JT3 }
551 { ltjp #1 \int_to_arabic:n { \g__ltjpreset_applycount_int }} { #2 } { rb }
552 { \l__ltjpreset_font_name: : jfm=\tl_use:N \__ltjpreset_use_jfm_tate_tl } { script=kana; +ruby }
555 \cs_if_exist:NT \ltjpreset_define_family_hook_nfssonly:nnn
556 { \ltjpreset_define_family_hook_nfssonly:nnn { #1 } { #2 } { #3 } }
558 \bool_if:NT \g__ltjpreset_deluxe_bool {
559 \let\mgfamily\undefined
560 \DeclareRobustCommand\mgfamily {
561 \not@math@alphabet\mgfamily\relax
562 \kanjifamily{ltjpmg \int_to_arabic:n { \g__ltjpreset_applycount_int }}\selectfont
564 \DeclareTextFontCommand{\textmg}{\mgfamily}
566 \bool_if:NT \g__ltjpreset_expert_bool {
567 \DeclareRobustCommand\rubyfamily { \kanjishape{rb}\selectfont }
570 \cs_new:Nn \__ltjpreset_do_fontset: { \group_begin:
572 \xdef\mcdefault{ltjpmc \int_to_arabic:n { \g__ltjpreset_applycount_int }}
573 \xdef\gtdefault{ltjpgt \int_to_arabic:n { \g__ltjpreset_applycount_int }}
574 \DeclareKanjiFamily{JY3}{\mcdefault}{}
575 \DeclareKanjiFamily{JT3}{\mcdefault}{}
576 \DeclareKanjiFamily{JY3}{\gtdefault}{}
577 \DeclareKanjiFamily{JT3}{\gtdefault}{}
578 \unless\ifltj@disablejfam
579 \SetSymbolFont{mincho}{normal}{JY3}{\mcdefault}{m}{n}
580 \SetSymbolFont{mincho}{bold}{JY3}{\mcdefault}{b}{n}
581 \DeclareMathAlphabet{\mathgt}{JY3}{\gtdefault}{m}{n}
583 \bool_if:NT \g__ltjpreset_deluxe_bool {
584 \DeclareKanjiFamily{JY3}{ltjpmg \int_to_arabic:n { \g__ltjpreset_applycount_int }}{}
585 \DeclareKanjiFamily{JT3}{ltjpmg \int_to_arabic:n { \g__ltjpreset_applycount_int }}{}
588 \tl_set:Nn \l_tmpa_tl {, CJKShape=JIS1990 }
589 \tl_if_eq:NNT \l__ltjpreset_kanji_shape_tl \l_tmpa_tl {
590 \tl_set:Nn \l__ltjpreset_kanji_shape_tl { ;+jp90 }
592 \tl_set:Nn \l_tmpa_tl {, CJKShape=JIS2004 }
593 \tl_if_eq:NNT \l__ltjpreset_kanji_shape_tl \l_tmpa_tl {
594 \tl_set:Ne \l__ltjpreset_kanji_shape_tl { ;+jp04 }
596 \__ltjpreset_define_family:nnn {mc} {m} {\__ltjpreset_font_mc_m:}
597 \__ltjpreset_define_family:nnn {mc} {bx} {\__ltjpreset_font_mc_b:}
598 \__ltjpreset_define_family:nnn {mc} {b} {\__ltjpreset_font_mc_b:}
599 \__ltjpreset_define_family:nnn {gt} {m} {\__ltjpreset_font_gt_m:}
600 \__ltjpreset_define_family:nnn {gt} {bx} {\__ltjpreset_font_gt_b:}
601 \__ltjpreset_define_family:nnn {gt} {b} {\__ltjpreset_font_gt_b:}
603 \bool_if:NT \g__ltjpreset_deluxe_bool {
604 \__ltjpreset_define_family:nnn {mc} {l} {\__ltjpreset_font_mc_l:}
605 \__ltjpreset_define_family:nnn {gt} {eb} {\__ltjpreset_font_gt_eb:}
606 \__ltjpreset_define_family:nnn {mg} {m} {\__ltjpreset_font_mg_m:}
610 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
613 \RequirePackage{luatexja-fontspec}
615 \msg_warning:nne { luatexja-preset }{ scale }{ \Cjascale }
616 \tl_new:N \l__ltjpreset_add_features_tl
618 \bool_if:NT \g__ltjpreset_expert_bool {
619 \cs_set:Npn \rubyfamily { \addjfontfeatures {
620 Style=Ruby , YokoFeatures={RawFeature=-hkna} , TateFeatures={RawFeature=-vkna}
623 \addjfontfeature{ Kerning=Off }
625 \cs_new:Nn \__ltjpreset_do_fontset: { \group_begin:
626 \tl_gset:Ne \l__ltjpreset_add_features_tl {
627 \tl_use:N \l__ltjpreset_kanji_shape_tl,
628 YokoFeatures = { JFM = \tl_use:N \__ltjpreset_use_jfm_yoko_tl },
629 TateFeatures = { JFM = \tl_use:N \__ltjpreset_use_jfm_tate_tl },
630 Script=CJK, \bool_if:NT \g__ltjpreset_noembed_bool { , NoEmbed }
633 \bool_if:NT \g__ltjpreset_expert_bool {
634 \tl_put_left:Nn \l__ltjpreset_add_features_tl {
635 , YokoFeatures = {Style = HorizontalKana}, TateFeatures = {Style = VerticalKana}
639 \bool_if:NT \g__ltjpreset_deluxe_bool {
640 FontFace={l}{n}{ Font = \__ltjpreset_font_mc_l:,
641 \cs_if_exist:NT \ltjpreset_define_family_hook_fontspec:nnn {
642 \ltjpreset_define_family_hook_fontspec:nnn
643 { mc } { l } { \__ltjpreset_font_mc_l: }
647 BoldFont = \__ltjpreset_font_mc_b: \tl_use:N \l__ltjpreset_add_features_tl,
648 \cs_if_exist:NT \ltjpreset_define_family_hook_fontspec:nnn {
649 UprightFeatures = { \ltjpreset_define_family_hook_fontspec:nnn
650 { mc } { m } { \__ltjpreset_font_mc_m: } },
651 BoldFeatures = { \ltjpreset_define_family_hook_fontspec:nnn
652 { mc } { b } { \__ltjpreset_font_mc_b: } },
654 ] { \__ltjpreset_font_mc_m: }
656 \bool_if:NT \g__ltjpreset_deluxe_bool {
657 FontFace={eb}{n}{ Font = \__ltjpreset_font_gt_eb:,
658 \cs_if_exist:NT \ltjpreset_define_family_hook_fontspec:nnn {
659 \ltjpreset_define_family_hook_fontspec:nnn
660 { gt } { eb } { \__ltjpreset_font_gt_eb: }
664 BoldFont = \__ltjpreset_font_gt_b: \tl_use:N \l__ltjpreset_add_features_tl,
665 \cs_if_exist:NT \ltjpreset_define_family_hook_fontspec:nnn {
666 UprightFeatures = { \ltjpreset_define_family_hook_fontspec:nnn
667 { gt } { m } { \__ltjpreset_font_gt_m: } },
668 BoldFeatures = { \ltjpreset_define_family_hook_fontspec:nnn
669 { gt } { b } { \__ltjpreset_font_gt_b: } },
671 ] { \__ltjpreset_font_gt_m: }
672 \bool_if:NT \g__ltjpreset_deluxe_bool {
674 \bool_if_exist:NTF \setfontfamily {
675 \setjfontfamily \mgfamily [
676 BoldFont = \__ltjpreset_font_mg_m: \tl_use:N \l__ltjpreset_add_features_tl,
677 \cs_if_exist:NT \ltjpreset_define_family_hook_fontspec:nnn {
678 \ltjpreset_define_family_hook_fontspec:nnn
679 { mg } { m } { \__ltjpreset_font_mg_m: },
681 ] { \__ltjpreset_font_mg_m: }
683 \newjfontfamily \mgfamily [
684 BoldFont = \__ltjpreset_font_mg_m: \tl_use:N \l__ltjpreset_add_features_tl,
685 \cs_if_exist:NT \ltjpreset_define_family_hook_fontspec:nnn {
686 \ltjpreset_define_family_hook_fontspec:nnn
687 { mg } { m } { \__ltjpreset_font_mg_m: },
689 ] { \__ltjpreset_font_mg_m: }
691 \DeclareTextFontCommand{\textmg}{\mgfamily}
694 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
698 \@ifstar{\__ltjpreset_new_preset:nnn{ true }}{\__ltjpreset_new_preset:nnn{ false }}}
699 \cs_set:Nn \__ltjpreset_new_preset:nnn {
700 \keys_if_exist:nnTF { luatexja-preset } { #2 } {
701 \seq_if_in:NnTF \g__ltjpreset_presets_seq { #2 } {
702 \bool_if:cTF { c_ #1 _bool } {
703 \msg_warning:nnn { luatexja-preset }{ exist-preset-overwrite } { #2 }
704 \keys_define:nn { luatexja-preset } {
705 #2 .meta:n = { #3, __custom = true, __noembed = false, __office = false, },
706 #2 .value_forbidden:n = true, #2 .groups:n = { preset },
709 \msg_error:nnn { luatexja-preset }{ exist-preset-nooverwrite } { #2 }
712 \msg_error:nnn { luatexja-preset }{ illegal-preset-name } { #2 }
715 \keys_define:nn { luatexja-preset } {
716 #2 .meta:n = { #3, __custom = true, __noembed = false, __office = false, },
717 #2 .value_forbidden:n = true, #2 .groups:n = { preset },
719 \seq_put_right:Nn \g__ltjpreset_presets_seq { #2 }
724 \cs_set:Npn \ltjapplypreset #1 {
725 \int_gincr:N \g__ltjpreset_applycount_int
726 \keys_set_groups:nnn { luatexja-preset } { preset } { #1 }
727 % \prop_map_inline:Nn \g__ltjpreset_font_prop {\typeout{ [##1] = "##2" } }
728 \__ltjpreset_extract_fonts:
729 \__ltjpreset_check_deluxe_existence:
730 \__ltjpreset_do_fontset:
736 \@onlypreamble\ltjnewpreset
737 \@onlypreamble\ltjapplypreset