2 \ProvidesPackage{luatexja-preset}[2020-06-14 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 \keys_set_known:noN { ltjpreset-presets } { \tl_use:N \l_keys_tl } \l_tmpa_tl
38 \tl_if_empty:NT \l_tmpa_tl {
39 \PassOptionsToPackage { \l_tmpa_tl } { luatexja-fontspec }
41 scale .code:n = \gdef\Cjascale{#1},
43 \renewcommand\jttdefault{\gtdefault}\@ltj@match@familytrue
44 \PassOptionsToPackage { match } { luatexja-fontspec },
45 match .value_forbidden:n = true,
46 __custom .bool_set:N = \g__ltjpreset_custom_bool, __custom .groups:n = { preset },
47 __office .bool_set:N = \g__ltjpreset_office_bool, __office .groups:n = { preset },
48 __noembed .bool_set:N = \g__ltjpreset_noembed_bool, __noembed .groups:n = { preset },
50 \cs_new:Nn \__ltjpreset_declare_option:nn {
51 \keys_define:nn { luatexja-preset }{
53 #1 .value_forbidden:n = true
56 \cs_new:Nn \ltjpreset_declare_preset:nn {
57 \keys_define:nn { luatexja-preset }{
59 #1 .value_forbidden:n = true, #1 .groups:n = { preset },
61 \seq_put_right:Nn \g__ltjpreset_presets_seq { #1 }
63 \cs_generate_variant:Nn \ltjpreset_declare_preset:nn {nx}
64 \cs_new:Nn \__ltjpreset_declare_bool_option:nn {
65 \bool_new:c { g__ltjpreset_#1_bool }
66 \bool_set_false:c { g__ltjpreset_#1_bool }
67 \keys_define:nn { luatexja-preset }{
68 #1 .bool_set:c = { g__ltjpreset_#1_bool },
69 #2 .bool_set_inverse:c = { g__ltjpreset_#1_bool },
70 #1 .default:n = true, #2 .default:n = true,
75 \__ltjpreset_declare_bool_option:nn { nfssonly }{ fontspec }
76 \__ltjpreset_declare_bool_option:nn { bold }{ nobold }
77 \__ltjpreset_declare_bool_option:nn { expert }{ noexpert }
78 \__ltjpreset_declare_bool_option:nn { deluxe }{ nodeluxe }
79 \__ltjpreset_declare_bool_option:nn { nocheck }{ check }
82 \tl_new:N \__ltjpreset_use_jfm_yoko_tl % 使用する JFM(横)
83 \tl_set:Nn \__ltjpreset_use_jfm_yoko_tl {\ltj@stdyokojfm}
84 \tl_new:N \__ltjpreset_use_jfm_tate_tl % 使用する JFM(縦)
85 \tl_set:Nn \__ltjpreset_use_jfm_tate_tl {\ltj@stdtatejfm}
86 \__ltjpreset_declare_option:nn{jis}{\tl_set:Nn \__ltjpreset_use_jfm_yoko_tl {jis}} % jis
87 \__ltjpreset_declare_option:nn{ujis}{\tl_set:Nn \__ltjpreset_use_jfm_yoko_tl {ujis}} % ujis
90 \tl_new:N \l__ltjpreset_kanji_shape_tl
91 \__ltjpreset_declare_option:nn{90jis}{ \tl_set:Nn \l__ltjpreset_kanji_shape_tl { , CJKShape=JIS1990 }} % 90jis
92 \__ltjpreset_declare_option:nn{jis90}{ \tl_set:Nn \l__ltjpreset_kanji_shape_tl { , CJKShape=JIS1990 }} % 90jis
93 \__ltjpreset_declare_option:nn{jis2004}{\tl_set:Nn \l__ltjpreset_kanji_shape_tl { , CJKShape=JIS2004 }} % jis2004
94 \__ltjpreset_declare_option:nn{2004jis}{\tl_set:Nn \l__ltjpreset_kanji_shape_tl { , CJKShape=JIS2004 }} % jis2004
97 \prop_new:N \g__ltjpreset_font_prop
98 \keys_define:nn { luatexja-preset } {
100 \prop_put:Nnn \g__ltjpreset_font_prop { mc-l } {#1}
101 \prop_put:Nnn \g__ltjpreset_font_prop { mc-m } {#1}
102 \prop_put:Nnn \g__ltjpreset_font_prop { mc-b } {#1},
103 mc .groups:n = { preset }, mc .value_required:n = true,
105 \prop_put:Nnn \g__ltjpreset_font_prop { mc-b } {#1},
107 \prop_put:Nnn \g__ltjpreset_font_prop { gt-u } {#1}
108 \prop_put:Nnn \g__ltjpreset_font_prop { gt-d } {#1}
109 \prop_put:Nnn \g__ltjpreset_font_prop { gt-b } {#1}
110 \prop_put:Nnn \g__ltjpreset_font_prop { gt-eb } {#1},
112 \prop_put:Nnn \g__ltjpreset_font_prop { gt-b } {#1},
113 gt-m .code:n = % gtfamily , medium series
114 \prop_put:Nnn \g__ltjpreset_font_prop { gt-u } {#1}
115 \prop_put:Nnn \g__ltjpreset_font_prop { gt-d } {#1},
117 gt .groups:n = { preset }, gt .value_required:n = true,
118 gt-m .groups:n = { preset }, gt-m .value_required:n = true,
120 \cs_set:Nn \ltjpreset_define_preset_prop:n {
121 \keys_define:nn { luatexja-preset } {
122 #1 .code:n = \prop_put:Non \g__ltjpreset_font_prop { #1 } { ##1 },
123 #1 .groups:n = { preset }, #1 .value_required:n = true,
126 \ltjpreset_define_preset_prop:n { mc-l }
127 \ltjpreset_define_preset_prop:n { mc-m }
128 \ltjpreset_define_preset_prop:n { mc-b }
129 \ltjpreset_define_preset_prop:n { gt-u }
130 \ltjpreset_define_preset_prop:n { gt-d }
131 \ltjpreset_define_preset_prop:n { gt-b }
132 \ltjpreset_define_preset_prop:n { gt-eb}
133 \ltjpreset_define_preset_prop:n { mg-m }
135 \cs_new:Nn \__ltjpreset_set_uni:nn {
136 mc = #1, gt = #2, mc-b = #2, mg-m = #2,
137 __custom = false, __office = false, __noembed = false,
139 \cs_new:Npn \__ltjpreset_set_office:nn #1 #2{
140 mc = #1, mc-b = HGMinchoE ,
141 gt-d = HGGothicM , gt-b = HGGothicE ,
142 gt-u = #2 , gt-eb = HGSoeiKakugothicUB ,
143 mg-m = HGMaruGothicMPRO,
144 __custom = false, __office = true, __noembed = false,
150 \keys_define:nn { luatexja-preset }{
151 custom .meta:n = { #1, __custom = true, },
152 custom .value_required:n = true,
153 jfm_yoko .tl_set:N = \__ltjpreset_use_jfm_yoko_tl,
154 jfm_tate .tl_set:N = \__ltjpreset_use_jfm_tate_tl,
159 \ltjpreset_declare_preset:nx{kozuka-pro}{
160 mc-m = KozMinPro-Regular, mc-b = KozMinPro-Bold,
161 gt-d = KozGoPro-Regular, gt-b = KozGoPro-Bold,
162 gt-u = KozGoPro-Medium, gt-eb = KozGoPro-Heavy,
163 mg-m = KozGoPro-Heavy, mc-l = KozMinPro-Light,
164 __custom = false, __office = false, __noembed = false,
167 \ltjpreset_declare_preset:nx{kozuka-pr6}{
168 mc-m = KozMinProVI-Regular, mc-b = KozMinProVI-Bold,
169 gt-d = KozGoProVI-Regular, gt-b = KozGoProVI-Bold,
170 gt-u = KozGoProVI-Medium, gt-eb = KozGoProVI-Heavy,
171 mg-m = KozGoProVI-Heavy, mc-l = KozMinProVI-Light,
172 __custom = false, __office = false, __noembed = false,
175 \ltjpreset_declare_preset:nx{kozuka-pr6n}{
176 mc-m = KozMinPr6N-Regular, mc-b = KozMinPr6N-Bold,
177 gt-d = KozGoPr6N-Regular, gt-b = KozGoPr6N-Bold,
178 gt-u = KozGoPr6N-Medium, gt-eb = KozGoPr6N-Heavy,
179 mg-m = KozGoPr6N-Heavy, mc-l = KozMinPr6N-Light,
180 __custom = false, __office = false, __noembed = false,
184 \ltjpreset_declare_preset:nx{hiragino-pro}{
185 mc-m = HiraMinPro-W3, mc-b = HiraMinPro-W6,
186 gt-d = HiraKakuPro-W3, gt-b = HiraKakuPro-W6,
187 gt-u = HiraKakuPro-W6, gt-eb = HiraKakuStd-W8,
188 mg-m = HiraMaruPro-W4, mc-l = HiraMinPro-W2,
189 __custom = false, __office = false, __noembed = false,
191 \ltjpreset_declare_preset:nx{hiragino-pron}{
192 mc-m = HiraMinProN-W3, mc-b = HiraMinProN-W6,
193 gt-d = HiraKakuProN-W3, gt-b = HiraKakuProN-W6,
194 gt-u = HiraKakuProN-W6, gt-eb = HiraKakuStdN-W8,
195 mg-m = HiraMaruProN-W4, mc-l = HiraMinProN-W2,
196 __custom = false, __office = false, __noembed = false,
200 \ltjpreset_declare_preset:nx{bizud}{
201 mc = BIZ-UDMinchoM.ttc,
202 gt-d = BIZ-UDGothicR.ttc, gt-b = BIZ-UDGothicB.ttc,
203 gt-u = BIZ-UDGothicR.ttc, gt-eb = BIZ-UDGothicB.ttc,
204 mg-m = BIZ-UDGothicB.ttc,
205 __custom = false, __office = false, __noembed = false,
207 \ltjpreset_declare_preset:nx{morisawa-pro}{
208 mc = A-OTF-RyuminPro-Light.otf, mc-b = A-OTF-FutoMinA101Pro-Bold.otf,
209 gt-d = A-OTF-GothicBBBPro-Medium.otf , gt-b = A-OTF-FutoGoB101Pro-Bold.otf,
210 gt-u = A-OTF-GothicBBBPro-Medium.otf , gt-eb = A-OTF-MidashiGoPro-MB31.otf,
211 mg-m = A-OTF-Jun101Pro-Light.otf,
212 __custom = false, __office = false, __noembed = false,
214 \ltjpreset_declare_preset:nx{morisawa-pr6n}{
215 mc = A-OTF-RyuminPr6N-Light.otf, mc-b = A-OTF-FutoMinA101Pr6N-Bold.otf,
216 gt-d = A-OTF-GothicBBBPr6N-Medium.otf , gt-b = A-OTF-FutoGoB101Pr6N-Bold.otf,
217 gt-u = A-OTF-GothicBBBPr6N-Medium.otf , gt-eb = A-OTF-MidashiGoPr6N-MB31.otf,
218 mg-m = A-OTF-Jun101Pr6N-Light.otf,
219 __custom = false, __office = false, __noembed = false,
223 \ltjpreset_declare_preset:nx{yu-win}{
224 mc-m = YuMincho-Regular, mc-b = YuMincho-Demibold,
225 gt-d = YuGothic-Regular, gt-b = YuGothic-Bold,
226 gt-u = YuGothic-Regular, gt-eb = YuGothic-Bold,
227 mg-m = YuGothic-Bold, mc-l = YuMincho-Light,
228 __custom = false, __office = false, __noembed = false,
231 \ltjpreset_declare_preset:nx{yu-win10}{
232 mc-m = YuMincho-Regular, mc-b = YuMincho-Demibold,
233 gt-d = YuGothic-Regular, gt-b = YuGothic-Bold,
234 gt-u = YuGothic-Medium, gt-eb = YuGothic-Bold,
235 mg-m = YuGothic-Bold, mc-l = YuMincho-Light,
236 __custom = false, __office = false, __noembed = false,
240 % according to http://support.apple.com/kb/HT5944
241 \ltjpreset_declare_preset:nx{yu-osx}{
242 mc = YuMincho~Medium, mc-b = YuMincho~Demibold,
243 gt-d = YuGothic~Medium, gt-u = YuGothic~Medium,
244 gt-b = YuGothic~Bold, gt-eb = YuGothic~Bold,
245 mg-m = YuGothic~Bold,
246 __custom = false, __office = false, __noembed = false,
250 \ltjpreset_declare_preset:nx{moga-mobo}{
251 mc = Moga90Mincho, mc-b = Moga90Mincho~Bold,
252 gt-d = Moga90Gothic, gt-b = Moga90Gothic~Bold,
253 gt-u = Moga90Gothic, gt-eb = Moga90Gothic~Bold,
255 __custom = false, __office = false, __noembed = false,
257 \ltjpreset_declare_preset:nx{moga-mobo-ex}{
258 mc = MogaEx90Mincho, mc-b = MogaEx90Mincho~Bold,
259 gt-d = MogaEx90Gothic, gt-b = MogaEx90Gothic~Bold,
260 gt-u = MogaEx90Gothic, gt-eb = MogaEx90Gothic~Bold,
261 mg-m = MoboEx90Gothic,
262 __custom = false, __office = false, __noembed = false,
266 \ltjpreset_declare_preset:nx{ume}{
268 gt-d = Ume~Gothic, gt-b = Ume~Gothic~O5,
269 gt-u = Ume~Gothic~O5, gt-eb = Ume~Gothic~O5,
270 mg-m = Ume~Gothic~O4,
271 __custom = false, __office = false, __noembed = false,
274 % Source Han {Serif,Sans}
275 \ltjpreset_declare_preset:nx{sourcehan}{
276 mc-m = Source~Han~Serif~Regular,
277 mc-b = Source~Han~Serif~Bold,
278 gt-d = Source~Han~Sans~Regular,
279 gt-b = Source~Han~Sans~Bold,
280 gt-u = Source~Han~Sans~Medium,
281 gt-eb = Source~Han~Sans~Heavy,
282 mg-m = Source~Han~Sans~Medium,
283 mc-l = Source~Han~Serif~Light,
284 __custom = false, __office = false, __noembed = false,
286 \ltjpreset_declare_preset:nx{sourcehan-jp}{
287 mc-m = Source~Han~Serif~JP~Regular,
288 mc-b = Source~Han~Serif~JP~Bold,
289 gt-d = Source~Han~Sans~JP~Regular,
290 gt-b = Source~Han~Sans~JP~Bold,
291 gt-u = Source~Han~Sans~JP~Medium,
292 gt-eb = Source~Han~Sans~JP~Heavy,
293 mg-m = Source~Han~Sans~JP~Medium,
294 mc-l = Source~Han~Serif~JP~Light,
295 __custom = false, __office = false, __noembed = false,
297 \ltjpreset_declare_preset:nx{noto-otc}{
298 mc-m = Noto~Serif~CJK~Regular,
299 mc-b = Noto~Serif~CJK~Bold,
300 gt-d = Noto~Sans~CJK~Regular,
301 gt-b = Noto~Sans~CJK~Bold,
302 gt-u = Noto~Sans~CJK~Medium,
303 gt-eb = Noto~Sans~CJK~Black,
304 mg-m = Noto~Sans~CJK~Medium,
305 mc-l = Noto~Serif~CJK~Light,
306 __custom = false, __office = false, __noembed = false,
308 \ltjpreset_declare_preset:nx{noto-otf}{
309 mc-m = Noto~Serif~CJK~JP~Regular,
310 mc-b = Noto~Serif~CJK~JP~Bold,
311 gt-d = Noto~Sans~CJK~JP~Regular,
312 gt-b = Noto~Sans~CJK~JP~Bold,
313 gt-u = Noto~Sans~CJK~JP~Medium,
314 gt-eb = Noto~Sans~CJK~JP~Black,
315 mg-m = Noto~Sans~CJK~JP~Medium,
316 mc-l = Noto~Serif~CJK~JP~Light,
317 __custom = false, __office = false, __noembed = false,
320 % HaranoAji {Mincho, Gothic}
321 \ltjpreset_declare_preset:nx{haranoaji}{
322 mc-m = HaranoAjiMincho-Regular.otf,
323 mc-b = HaranoAjiMincho-Bold.otf,
324 gt-d = HaranoAjiGothic-Regular.otf,
325 gt-b = HaranoAjiGothic-Bold.otf,
326 gt-u = HaranoAjiGothic-Medium.otf,
327 gt-eb = HaranoAjiGothic-Heavy.otf,
328 mg-m = HaranoAjiGothic-Medium.otf,
329 mc-l = HaranoAjiMincho-Light.otf,
330 __custom = false, __office = false, __noembed = false,
335 \ltjpreset_declare_preset:nx{ipa}{
336 \__ltjpreset_set_uni:nn { IPAMincho } { IPAGothic }
338 \ltjpreset_declare_preset:nx{ipaex}{
339 \__ltjpreset_set_uni:nn { IPAExMincho } { IPAExGothic }
341 \ltjpreset_declare_preset:nx{ms}{
342 \__ltjpreset_set_uni:nn { MS-Mincho } { MS-Gothic }
345 % {ipa,ipaex,ms}-dx % Office 付属フォントを利用
346 \ltjpreset_declare_preset:nx{ipaex-hg}{
347 \__ltjpreset_set_office:nn { IPAExMincho } { IPAExGothic }
349 \ltjpreset_declare_preset:nx{ipa-hg}{
350 \__ltjpreset_set_office:nn { IPAMincho } { IPAGothic }
352 \ltjpreset_declare_preset:nx{ms-hg}{
353 \__ltjpreset_set_office:nn { MS-Mincho } { MS-Gothic }
358 \ltjpreset_declare_preset:nx{noembed}{
359 \__ltjpreset_set_uni:nn { Ryumin-Light } { GothicBBB-Medium },
360 __custom = false, __office = false, __noembed = true,
363 \keys_set:nn {luatexja-preset} { haranoaji } %% old: ipaex
364 \ProcessKeysOptions { luatexja-preset }
365 \@ifpackageloaded{luatexja-fontspec}{
366 \bool_if:NT \g__ltjpreset_nfssonly_bool
367 { \msg_warning:nn { luatexja-preset }{ ltj-fontspec } }
368 \bool_set_false:N \g__ltjpreset_nfssonly_bool
371 %%%%%%%% main routine
373 \cs_new:Nn \__ltjpreset_extract_fonts: {
374 %% MogaMincho の場合は 90 をつける/はずす
375 \bool_if:NF \g__ltjpreset_custom_bool {
376 \tl_set:Nn \l_tmpa_tl {, CJKShape=JIS2004 }
377 \tl_if_eq:NNT \l__ltjpreset_kanji_shape_tl \l_tmpa_tl {
378 \tl_set:Nx \l_tmpb_tl { \prop_item:Nn \g__ltjpreset_font_prop { mc-m } }
379 \tl_if_in:NnT \l_tmpb_tl { Moga90Mincho } {
380 \prop_clear:N \l_tmpa_prop
381 \prop_map_inline:Nn \g__ltjpreset_font_prop {
382 \tl_set:Nn \l_tmpb_tl { ##2 } \tl_remove_all:Nn \l_tmpb_tl {90}
383 \prop_put:Nnx \l_tmpa_prop { ##1 } { \tl_use:N \l_tmpb_tl }
385 \prop_set_eq:NN \g__ltjpreset_font_prop \l_tmpa_prop
387 \tl_if_in:NnT \l_tmpb_tl { MogaEx90Mincho } {
388 \prop_clear:N \l_tmpa_prop
389 \prop_map_inline:Nn \g__ltjpreset_font_prop {
390 \tl_set:Nn \l_tmpb_tl { ##2 } \tl_remove_all:Nn \l_tmpb_tl {90}
391 \prop_put:Nnx \l_tmpa_prop { ##1 } { \tl_use:N \l_tmpb_tl }
393 \prop_set_eq:NN \g__ltjpreset_font_prop \l_tmpa_prop
398 \cs_set:Nx \__ltjpreset_font_mc_l: { \prop_item:Nn \g__ltjpreset_font_prop { mc-l } }
399 \cs_set:Nx \__ltjpreset_font_mc_m: { \prop_item:Nn \g__ltjpreset_font_prop { mc-m } }
400 \cs_set:Nx \__ltjpreset_font_mc_b: { \prop_item:Nn \g__ltjpreset_font_prop { mc-b } }
401 \cs_set:Nx \__ltjpreset_font_gt_m: { \prop_item:Nn \g__ltjpreset_font_prop { gt-d } }
402 \cs_set:Nx \__ltjpreset_font_gt_u: { \prop_item:Nn \g__ltjpreset_font_prop { gt-u } }
403 \cs_set:Nx \__ltjpreset_font_gt_b: { \prop_item:Nn \g__ltjpreset_font_prop { gt-b } }
404 \cs_set:Nx \__ltjpreset_font_gt_eb: { \prop_item:Nn \g__ltjpreset_font_prop { gt-eb } }
405 \cs_set:Nx \__ltjpreset_font_mg_m: { \prop_item:Nn \g__ltjpreset_font_prop { mg-m } }
406 %% HG 系フォント + JIS2004/90JIS のときはフォント名を置換
407 \bool_if:nT { !\g__ltjpreset_custom_bool && \g__ltjpreset_office_bool } {
408 \tl_set:Nn \l_tmpa_tl {, CJKShape=JIS2004 }
409 \tl_if_eq:NNT \l__ltjpreset_kanji_shape_tl \l_tmpa_tl {
410 \cs_set:Nx \__ltjpreset_font_mc_b: { hgrme04.ttc }
411 \cs_set:Nx \__ltjpreset_font_gt_b: { hgrge04.ttc }
412 \cs_set:Nx \__ltjpreset_font_gt_eb: { hgrsgu04.ttc }
413 \cs_set:Nx \__ltjpreset_font_mg_m: { hgrsmp04.ttf }
414 \cs_set_eq:NN \__ltjpreset_font_gt_m: \__ltjpreset_font_gt_u:
415 % HG ゴシックM のときはそうはいかないので 1 ウェイト時のゴシック体を使う
417 \tl_set:Nn \l_tmpa_tl {, CJKShape=JIS1990 }
418 \tl_if_eq:NNT \l__ltjpreset_kanji_shape_tl \l_tmpa_tl {
419 \cs_set:Nx \__ltjpreset_font_mc_b: { hgrme.ttc }
420 \cs_set:Nx \__ltjpreset_font_gt_b: { hgrge.ttc }
421 \cs_set:Nx \__ltjpreset_font_gt_eb: { hgrsgu.ttc }
422 \cs_set:Nx \__ltjpreset_font_mg_m: { hgrsmp.ttf }
426 \tl_set:Nx \l_tmpa_tl { \__ltjpreset_font_mc_l: }
427 \tl_if_empty:NT \l_tmpa_tl {\tl_set:Nn \l_tmpa_tl {~}}
428 \cs_set:Nx \__ltjpreset_font_mc_l: {
429 \tl_if_blank:nTF \l_tmpa_tl { \__ltjpreset_font_mc_m: } {\tl_use:N \l_tmpa_tl }
432 \bool_if:NTF \g__ltjpreset_deluxe_bool {
433 \bool_if:NT \g__ltjpreset_bold_bool {
434 \cs_set_eq:NN \__ltjpreset_font_mc_b: \__ltjpreset_font_gt_b:
437 \bool_if:NTF \g__ltjpreset_bold_bool
438 { \cs_set_eq:NN \__ltjpreset_font_gt_m: \__ltjpreset_font_gt_b: }
439 { \cs_set_eq:NN \__ltjpreset_font_gt_m: \__ltjpreset_font_gt_u: }
440 \cs_set_eq:NN \__ltjpreset_font_gt_b: \__ltjpreset_font_gt_m:
441 \cs_set_eq:NN \__ltjpreset_font_mc_b: \__ltjpreset_font_gt_m:
445 %%%%%%%% フォント名を \l__ltjpreset_font_name: に格納
446 \clist_new:N \l__ltjpreset_extensions_clist
447 \clist_set:Nn \l__ltjpreset_extensions_clist {.otf,.ttf,.OTF,.TTF,.ttc,.TTC}
448 \prg_new_conditional:Nnn \__ltjpreset_if_detect_external:n {TF} {
449 \clist_map_inline:Nn \l__ltjpreset_extensions_clist {
450 \bool_set_false:N \l_tmpa_bool
451 \tl_if_in:nnT {#1 <= end_of_string} {##1 <= end_of_string}
452 { \bool_set_true:N \l_tmpa_bool \clist_map_break: }
454 \bool_if:NTF \l_tmpa_bool \prg_return_true: \prg_return_false:
456 \cs_new:Nn \__ltjpreset_wrap_fontname:n {
457 \__ltjpreset_if_detect_external:nTF { #1 }
458 { \cs_set:Nn \l__ltjpreset_font_name: { [#1] } }
459 { \cs_set:Nn \l__ltjpreset_font_name: { "#1" } }
461 \cs_generate_variant:Nn \__ltjpreset_wrap_fontname:n { e }
464 \cs_new:Nn \__ltjpreset_substitute:nnnn {
466 \suppressfontnotfounderror=1
467 \cs_if_exist:cTF { __ltjpreset_font_#1_#2: } {
468 \bool_if:NF \g__ltjpreset_nocheck_bool {
469 \__ltjpreset_wrap_fontname:e { \cs:w __ltjpreset_font_#1_#2: \cs_end: }
470 \font \g__ltjpreset_font_test: = \l__ltjpreset_font_name:\relax
471 \ifx \g__ltjpreset_font_test: \nullfont
472 \msg_warning:nnxxxx { luatexja-preset }{ no-font }
473 { \cs:w __ltjpreset_font_#1_#2: \cs_end: }{ #1/#2 }
474 { \cs:w __ltjpreset_font_#3_#4: \cs_end: }{ #3/#4 }
475 \cs_gset_eq:cc { __ltjpreset_font_#1_#2: } { __ltjpreset_font_#3_#4: }
478 } { \cs_gset_eq:cc { __ltjpreset_font_#1_#2: } { __ltjpreset_font_#3_#4: } }
482 %%%%%%%% deluxe (\mgfamily はあとで定義)
483 \bool_if:NTF \g__ltjpreset_deluxe_bool {
484 \cs_new:Nn \__ltjpreset_check_deluxe_existence: {
485 \__ltjpreset_substitute:nnnn { gt } { eb } { gt } { b }
486 \__ltjpreset_substitute:nnnn { mg } { m } { gt } { b }
487 \__ltjpreset_substitute:nnnn { mc } { l } { mc } { m }
490 \DeclareRobustCommand\ltseries { \not@math@alphabet\ltseries\relax\fontseries\ltdefault\selectfont }
492 \DeclareRobustCommand\ebseries { \not@math@alphabet\ebseries\relax\fontseries\ebdefault\selectfont }
493 \DeclareRobustCommand\gtebfamily { \gtfamily\fontseries{\ebdefault}\selectfont }
494 \DeclareTextFontCommand{\textlt}{\ltseries}
495 \DeclareTextFontCommand{\texteb}{\ebseries}
497 \cs_set_eq:NN \__ltjpreset_check_deluxe_existence: \prg_do_nothing:
500 \int_new:N \g__ltjpreset_applycount_int
502 \bool_if:NTF \g__ltjpreset_nfssonly_bool {
503 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
505 \cs_if_exist:NF \Cjascale {
507 \fontsize{16}{16}\selectfont
508 \cs_gset:Npx \Cjascale { \fp_to_decimal:n {\zw / 16} }
512 \msg_warning:nnx { luatexja-preset }{ scale }{ \Cjascale }
514 % {1: encoding}{2: family}{3: series}{4: shape}{5: fontname}{6: feature}{7: scale}
515 \cs_new:Nn \__ltjpreset_declare_font_shape:nnnnnnn {
516 \DeclareFontShape{#1}{#2}{#3}{#4}{ <-> s*[#7]
517 \bool_if:NT \g__ltjpreset_noembed_bool {psft:} #5
518 ;-kern \tl_use:N \l__ltjpreset_kanji_shape_tl; #6 } {}
520 \cs_new:Nn \__ltjpreset_define_family:nnn {
521 \__ltjpreset_wrap_fontname:e { #3 }
522 \__ltjpreset_declare_font_shape:nnnnnnn { JY3 }
523 { ltjp #1 \int_to_arabic:n { \g__ltjpreset_applycount_int }} { #2 } { n }
524 { \l__ltjpreset_font_name: : jfm=\tl_use:N \__ltjpreset_use_jfm_yoko_tl }
525 { script=hani \bool_if:NT \g__ltjpreset_expert_bool { ;+hkna } }
527 \__ltjpreset_declare_font_shape:nnnnnnn { JT3 }
528 { ltjp #1 \int_to_arabic:n { \g__ltjpreset_applycount_int }} { #2 } { n }
529 { \l__ltjpreset_font_name: : jfm=\tl_use:N \__ltjpreset_use_jfm_tate_tl }
530 { script=hani \bool_if:NT \g__ltjpreset_expert_bool { ;+vkna } }
532 \bool_if:NT \g__ltjpreset_expert_bool {
533 \__ltjpreset_declare_font_shape:nnnnnnn { JY3 }
534 { ltjp #1 \int_to_arabic:n { \g__ltjpreset_applycount_int }} { #2 } { rb }
535 { \l__ltjpreset_font_name: : jfm=\tl_use:N \__ltjpreset_use_jfm_yoko_tl } { script=kana; +ruby }
537 \__ltjpreset_declare_font_shape:nnnnnnn { JT3 }
538 { ltjp #1 \int_to_arabic:n { \g__ltjpreset_applycount_int }} { #2 } { rb }
539 { \l__ltjpreset_font_name: : jfm=\tl_use:N \__ltjpreset_use_jfm_tate_tl } { script=kana; +ruby }
542 \cs_if_exist:NT \ltjpreset_define_family_hook_nfssonly:nnn
543 { \ltjpreset_define_family_hook_nfssonly:nnn { #1 } { #2 } { #3 } }
545 \bool_if:NT \g__ltjpreset_deluxe_bool {
546 \let\mgfamily\undefined
547 \DeclareRobustCommand\mgfamily {
548 \not@math@alphabet\mgfamily\relax
549 \kanjifamily{ltjpmg \int_to_arabic:n { \g__ltjpreset_applycount_int }}\selectfont
551 \DeclareTextFontCommand{\textmg}{\mgfamily}
553 \bool_if:NT \g__ltjpreset_expert_bool {
554 \DeclareRobustCommand\rubyfamily { \kanjishape{rb}\selectfont }
557 \cs_new:Nn \__ltjpreset_do_fontset: { \group_begin:
559 \xdef\mcdefault{ltjpmc \int_to_arabic:n { \g__ltjpreset_applycount_int }}
560 \xdef\gtdefault{ltjpgt \int_to_arabic:n { \g__ltjpreset_applycount_int }}
561 \DeclareKanjiFamily{JY3}{\mcdefault}{}
562 \DeclareKanjiFamily{JT3}{\mcdefault}{}
563 \DeclareKanjiFamily{JY3}{\gtdefault}{}
564 \DeclareKanjiFamily{JT3}{\gtdefault}{}
565 \unless\ifltj@disablejfam
566 \SetSymbolFont{mincho}{normal}{JY3}{\mcdefault}{m}{n}
567 \SetSymbolFont{mincho}{bold}{JY3}{\mcdefault}{b}{n}
568 \DeclareMathAlphabet{\mathgt}{JY3}{\gtdefault}{m}{n}
570 \bool_if:NT \g__ltjpreset_deluxe_bool {
571 \DeclareKanjiFamily{JY3}{ltjpmg \int_to_arabic:n { \g__ltjpreset_applycount_int }}{}
572 \DeclareKanjiFamily{JT3}{ltjpmg \int_to_arabic:n { \g__ltjpreset_applycount_int }}{}
575 \tl_set:Nn \l_tmpa_tl {, CJKShape=JIS1990 }
576 \tl_if_eq:NNT \l__ltjpreset_kanji_shape_tl \l_tmpa_tl {
577 \tl_set:Nn \l__ltjpreset_kanji_shape_tl { ;+jp90 }
579 \tl_set:Nn \l_tmpa_tl {, CJKShape=JIS2004 }
580 \tl_if_eq:NNT \l__ltjpreset_kanji_shape_tl \l_tmpa_tl {
581 \tl_set:Nx \l__ltjpreset_kanji_shape_tl { ;+jp04 }
583 \__ltjpreset_define_family:nnn {mc} {m} {\__ltjpreset_font_mc_m:}
584 \__ltjpreset_define_family:nnn {mc} {bx} {\__ltjpreset_font_mc_b:}
585 \__ltjpreset_define_family:nnn {mc} {b} {\__ltjpreset_font_mc_b:}
586 \__ltjpreset_define_family:nnn {gt} {m} {\__ltjpreset_font_gt_m:}
587 \__ltjpreset_define_family:nnn {gt} {bx} {\__ltjpreset_font_gt_b:}
588 \__ltjpreset_define_family:nnn {gt} {b} {\__ltjpreset_font_gt_b:}
590 \bool_if:NT \g__ltjpreset_deluxe_bool {
591 \__ltjpreset_define_family:nnn {mc} {l} {\__ltjpreset_font_mc_l:}
592 \__ltjpreset_define_family:nnn {gt} {eb} {\__ltjpreset_font_gt_eb:}
593 \__ltjpreset_define_family:nnn {mg} {m} {\__ltjpreset_font_mg_m:}
597 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
600 \RequirePackage{luatexja-fontspec}
602 \msg_warning:nnx { luatexja-preset }{ scale }{ \Cjascale }
603 \tl_new:N \l__ltjpreset_add_features_tl
605 \bool_if:NT \g__ltjpreset_expert_bool {
606 \cs_set:Npn \rubyfamily { \addjfontfeatures {
607 Style=Ruby , YokoFeatures={RawFeature=-hkna} , TateFeatures={RawFeature=-vkna}
610 \addjfontfeature{ Kerning=Off }
612 \cs_new:Nn \__ltjpreset_do_fontset: { \group_begin:
613 \tl_gset:Nx \l__ltjpreset_add_features_tl {
614 \tl_use:N \l__ltjpreset_kanji_shape_tl,
615 YokoFeatures = { JFM = \tl_use:N \__ltjpreset_use_jfm_yoko_tl },
616 TateFeatures = { JFM = \tl_use:N \__ltjpreset_use_jfm_tate_tl },
617 Script=CJK, \bool_if:NT \g__ltjpreset_noembed_bool { , NoEmbed }
620 \bool_if:NT \g__ltjpreset_expert_bool {
621 \tl_put_left:Nn \l__ltjpreset_add_features_tl {
622 , YokoFeatures = {Style = HorizontalKana}, TateFeatures = {Style = VerticalKana}
626 \bool_if:NT \g__ltjpreset_deluxe_bool {
627 FontFace={l}{n}{ Font = \__ltjpreset_font_mc_l:,
628 \cs_if_exist:NT \ltjpreset_define_family_hook_fontspec:nnn {
629 \ltjpreset_define_family_hook_fontspec:nnn
630 { mc } { l } { \__ltjpreset_font_mc_l: }
634 BoldFont = \__ltjpreset_font_mc_b: \tl_use:N \l__ltjpreset_add_features_tl,
635 \cs_if_exist:NT \ltjpreset_define_family_hook_fontspec:nnn {
636 UprightFeatures = { \ltjpreset_define_family_hook_fontspec:nnn
637 { mc } { m } { \__ltjpreset_font_mc_m: } },
638 BoldFeatures = { \ltjpreset_define_family_hook_fontspec:nnn
639 { mc } { b } { \__ltjpreset_font_mc_b: } },
641 ] { \__ltjpreset_font_mc_m: }
643 \bool_if:NT \g__ltjpreset_deluxe_bool {
644 FontFace={eb}{n}{ Font = \__ltjpreset_font_gt_eb:,
645 \cs_if_exist:NT \ltjpreset_define_family_hook_fontspec:nnn {
646 \ltjpreset_define_family_hook_fontspec:nnn
647 { gt } { eb } { \__ltjpreset_font_gt_eb: }
651 BoldFont = \__ltjpreset_font_gt_b: \tl_use:N \l__ltjpreset_add_features_tl,
652 \cs_if_exist:NT \ltjpreset_define_family_hook_fontspec:nnn {
653 UprightFeatures = { \ltjpreset_define_family_hook_fontspec:nnn
654 { gt } { m } { \__ltjpreset_font_gt_m: } },
655 BoldFeatures = { \ltjpreset_define_family_hook_fontspec:nnn
656 { gt } { b } { \__ltjpreset_font_gt_b: } },
658 ] { \__ltjpreset_font_gt_m: }
659 \bool_if:NT \g__ltjpreset_deluxe_bool {
661 \bool_if_exist:NTF \setfontfamily {
662 \setjfontfamily \mgfamily [
663 BoldFont = \__ltjpreset_font_mg_m: \tl_use:N \l__ltjpreset_add_features_tl,
664 \cs_if_exist:NT \ltjpreset_define_family_hook_fontspec:nnn {
665 \ltjpreset_define_family_hook_fontspec:nnn
666 { mg } { m } { \__ltjpreset_font_mg_m: },
668 ] { \__ltjpreset_font_mg_m: }
670 \newjfontfamily \mgfamily [
671 BoldFont = \__ltjpreset_font_mg_m: \tl_use:N \l__ltjpreset_add_features_tl,
672 \cs_if_exist:NT \ltjpreset_define_family_hook_fontspec:nnn {
673 \ltjpreset_define_family_hook_fontspec:nnn
674 { mg } { m } { \__ltjpreset_font_mg_m: },
676 ] { \__ltjpreset_font_mg_m: }
678 \DeclareTextFontCommand{\textmg}{\mgfamily}
681 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
685 \@ifstar{\__ltjpreset_new_preset:nnn{ true }}{\__ltjpreset_new_preset:nnn{ false }}}
686 \cs_set:Nn \__ltjpreset_new_preset:nnn {
687 \keys_if_exist:nnTF { luatexja-preset } { #2 } {
688 \seq_if_in:NnTF \g__ltjpreset_presets_seq { #2 } {
689 \bool_if:cTF { c_ #1 _bool } {
690 \msg_warning:nnn { luatexja-preset }{ exist-preset-overwrite } { #2 }
691 \keys_define:nn { luatexja-preset } {
692 #2 .meta:n = { #3, __custom = true, __noembed = false, __office = false, },
693 #2 .value_forbidden:n = true, #2 .groups:n = { preset },
696 \msg_error:nnn { luatexja-preset }{ exist-preset-nooverwrite } { #2 }
699 \msg_error:nnn { luatexja-preset }{ illegal-preset-name } { #2 }
702 \keys_define:nn { luatexja-preset } {
703 #2 .meta:n = { #3, __custom = true, __noembed = false, __office = false, },
704 #2 .value_forbidden:n = true, #2 .groups:n = { preset },
706 \seq_put_right:Nn \g__ltjpreset_presets_seq { #2 }
711 \cs_set:Npn \ltjapplypreset #1 {
712 \int_gincr:N \g__ltjpreset_applycount_int
713 \keys_set_groups:nnn { luatexja-preset } { preset } { #1 }
714 % \prop_map_inline:Nn \g__ltjpreset_font_prop {\typeout{ [##1] = "##2" } }
715 \__ltjpreset_extract_fonts:
716 \__ltjpreset_check_deluxe_existence:
717 \__ltjpreset_do_fontset:
723 \@onlypreamble\ltjnewpreset
724 \@onlypreamble\ltjapplypreset