2 \ProvidesPackage{luatexja-preset}[2020/03/19 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 }
81 \tl_new:N \__ltjpreset_use_jfm_yoko_tl % 使用する JFM(横)
82 \tl_set:Nn \__ltjpreset_use_jfm_yoko_tl {\ltj@stdyokojfm}
83 \tl_new:N \__ltjpreset_use_jfm_tate_tl % 使用する JFM(縦)
84 \tl_set:Nn \__ltjpreset_use_jfm_tate_tl {\ltj@stdtatejfm}
85 \__ltjpreset_declare_option:nn{jis}{\tl_set:Nn \__ltjpreset_use_jfm_yoko_tl {jis}} % jis
86 \__ltjpreset_declare_option:nn{ujis}{\tl_set:Nn \__ltjpreset_use_jfm_yoko_tl {ujis}} % ujis
89 \tl_new:N \l__ltjpreset_kanji_shape_tl
90 \__ltjpreset_declare_option:nn{90jis}{ \tl_set:Nn \l__ltjpreset_kanji_shape_tl { , CJKShape=JIS1990 }} % 90jis
91 \__ltjpreset_declare_option:nn{jis90}{ \tl_set:Nn \l__ltjpreset_kanji_shape_tl { , CJKShape=JIS1990 }} % 90jis
92 \__ltjpreset_declare_option:nn{jis2004}{\tl_set:Nn \l__ltjpreset_kanji_shape_tl { , CJKShape=JIS2004 }} % jis2004
93 \__ltjpreset_declare_option:nn{2004jis}{\tl_set:Nn \l__ltjpreset_kanji_shape_tl { , CJKShape=JIS2004 }} % jis2004
96 \prop_new:N \g__ltjpreset_font_prop
97 \keys_define:nn { luatexja-preset } {
99 \prop_put:Nnn \g__ltjpreset_font_prop { mc-l } {#1}
100 \prop_put:Nnn \g__ltjpreset_font_prop { mc-m } {#1}
101 \prop_put:Nnn \g__ltjpreset_font_prop { mc-b } {#1},
102 mc .groups:n = { preset }, mc .value_required:n = true,
104 \prop_put:Nnn \g__ltjpreset_font_prop { mc-b } {#1},
106 \prop_put:Nnn \g__ltjpreset_font_prop { gt-u } {#1}
107 \prop_put:Nnn \g__ltjpreset_font_prop { gt-d } {#1}
108 \prop_put:Nnn \g__ltjpreset_font_prop { gt-b } {#1}
109 \prop_put:Nnn \g__ltjpreset_font_prop { gt-eb } {#1},
111 \prop_put:Nnn \g__ltjpreset_font_prop { gt-b } {#1},
112 gt-m .code:n = % gtfamily , medium series
113 \prop_put:Nnn \g__ltjpreset_font_prop { gt-u } {#1}
114 \prop_put:Nnn \g__ltjpreset_font_prop { gt-d } {#1},
116 gt .groups:n = { preset }, gt .value_required:n = true,
117 gt-m .groups:n = { preset }, gt-m .value_required:n = true,
119 \cs_set:Nn \ltjpreset_define_preset_prop:n {
120 \keys_define:nn { luatexja-preset } {
121 #1 .code:n = \prop_put:Non \g__ltjpreset_font_prop { #1 } { ##1 },
122 #1 .groups:n = { preset }, #1 .value_required:n = true,
125 \ltjpreset_define_preset_prop:n { mc-l }
126 \ltjpreset_define_preset_prop:n { mc-m }
127 \ltjpreset_define_preset_prop:n { mc-b }
128 \ltjpreset_define_preset_prop:n { gt-u }
129 \ltjpreset_define_preset_prop:n { gt-d }
130 \ltjpreset_define_preset_prop:n { gt-b }
131 \ltjpreset_define_preset_prop:n { gt-eb}
132 \ltjpreset_define_preset_prop:n { mg-m }
134 \cs_new:Nn \__ltjpreset_set_uni:nn {
135 mc = #1, gt = #2, mc-b = #2, mg-m = #2,
136 __custom = false, __office = false, __noembed = false,
138 \cs_new:Npn \__ltjpreset_set_office:nn #1 #2{
139 mc = #1, mc-b = HGMinchoE ,
140 gt-d = HGGothicM , gt-b = HGGothicE ,
141 gt-u = #2 , gt-eb = HGSoeiKakugothicUB ,
142 mg-m = HGMaruGothicMPRO,
143 __custom = false, __office = true, __noembed = false,
149 \keys_define:nn { luatexja-preset }{
150 custom .meta:n = { #1, __custom = true, },
151 custom .value_required:n = true,
152 jfm_yoko .tl_set:N = \__ltjpreset_use_jfm_yoko_tl,
153 jfm_tate .tl_set:N = \__ltjpreset_use_jfm_tate_tl,
158 \ltjpreset_declare_preset:nx{kozuka-pro}{
159 mc-m = KozMinPro-Regular, mc-b = KozMinPro-Bold,
160 gt-d = KozGoPro-Regular, gt-b = KozGoPro-Bold,
161 gt-u = KozGoPro-Medium, gt-eb = KozGoPro-Heavy,
162 mg-m = KozGoPro-Heavy, mc-l = KozMinPro-Light,
163 __custom = false, __office = false, __noembed = false,
166 \ltjpreset_declare_preset:nx{kozuka-pr6}{
167 mc-m = KozMinProVI-Regular, mc-b = KozMinProVI-Bold,
168 gt-d = KozGoProVI-Regular, gt-b = KozGoProVI-Bold,
169 gt-u = KozGoProVI-Medium, gt-eb = KozGoProVI-Heavy,
170 mg-m = KozGoProVI-Heavy, mc-l = KozMinProVI-Light,
171 __custom = false, __office = false, __noembed = false,
174 \ltjpreset_declare_preset:nx{kozuka-pr6n}{
175 mc-m = KozMinPr6N-Regular, mc-b = KozMinPr6N-Bold,
176 gt-d = KozGoPr6N-Regular, gt-b = KozGoPr6N-Bold,
177 gt-u = KozGoPr6N-Medium, gt-eb = KozGoPr6N-Heavy,
178 mg-m = KozGoPr6N-Heavy, mc-l = KozMinPr6N-Light,
179 __custom = false, __office = false, __noembed = false,
183 \ltjpreset_declare_preset:nx{hiragino-pro}{
184 mc-m = HiraMinPro-W3, mc-b = HiraMinPro-W6,
185 gt-d = HiraKakuPro-W3, gt-b = HiraKakuPro-W6,
186 gt-u = HiraKakuPro-W6, gt-eb = HiraKakuStd-W8,
187 mg-m = HiraMaruPro-W4, mc-l = HiraMinPro-W2,
188 __custom = false, __office = false, __noembed = false,
190 \ltjpreset_declare_preset:nx{hiragino-pron}{
191 mc-m = HiraMinProN-W3, mc-b = HiraMinProN-W6,
192 gt-d = HiraKakuProN-W3, gt-b = HiraKakuProN-W6,
193 gt-u = HiraKakuProN-W6, gt-eb = HiraKakuStdN-W8,
194 mg-m = HiraMaruProN-W4, mc-l = HiraMinProN-W2,
195 __custom = false, __office = false, __noembed = false,
199 \ltjpreset_declare_preset:nx{bizud}{
200 mc = BIZ-UDMinchoM.ttc,
201 gt-d = BIZ-UDGothicR.ttc, gt-b = BIZ-UDGothicB.ttc,
202 gt-u = BIZ-UDGothicR.ttc, gt-eb = BIZ-UDGothicB.ttc,
203 mg-m = BIZ-UDGothicB.ttc,
204 __custom = false, __office = false, __noembed = false,
206 \ltjpreset_declare_preset:nx{morisawa-pro}{
207 mc = A-OTF-RyuminPro-Light.otf, mc-b = A-OTF-FutoMinA101Pro-Bold.otf,
208 gt-d = A-OTF-GothicBBBPro-Medium.otf , gt-b = A-OTF-FutoGoB101Pro-Bold.otf,
209 gt-u = A-OTF-GothicBBBPro-Medium.otf , gt-eb = A-OTF-MidashiGoPro-MB31.otf,
210 mg-m = A-OTF-Jun101Pro-Light.otf,
211 __custom = false, __office = false, __noembed = false,
213 \ltjpreset_declare_preset:nx{morisawa-pr6n}{
214 mc = A-OTF-RyuminPr6N-Light.otf, mc-b = A-OTF-FutoMinA101Pr6N-Bold.otf,
215 gt-d = A-OTF-GothicBBBPr6N-Medium.otf , gt-b = A-OTF-FutoGoB101Pr6N-Bold.otf,
216 gt-u = A-OTF-GothicBBBPr6N-Medium.otf , gt-eb = A-OTF-MidashiGoPr6N-MB31.otf,
217 mg-m = A-OTF-Jun101Pr6N-Light.otf,
218 __custom = false, __office = false, __noembed = false,
222 \ltjpreset_declare_preset:nx{yu-win}{
223 mc-m = YuMincho-Regular, mc-b = YuMincho-Demibold,
224 gt-d = YuGothic-Regular, gt-b = YuGothic-Bold,
225 gt-u = YuGothic-Regular, gt-eb = YuGothic-Bold,
226 mg-m = YuGothic-Bold, mc-l = YuMincho-Light,
227 __custom = false, __office = false, __noembed = false,
230 \ltjpreset_declare_preset:nx{yu-win10}{
231 mc-m = YuMincho-Regular, mc-b = YuMincho-Demibold,
232 gt-d = YuGothic-Regular, gt-b = YuGothic-Bold,
233 gt-u = YuGothic-Medium, gt-eb = YuGothic-Bold,
234 mg-m = YuGothic-Bold, mc-l = YuMincho-Light,
235 __custom = false, __office = false, __noembed = false,
239 % according to http://support.apple.com/kb/HT5944
240 \ltjpreset_declare_preset:nx{yu-osx}{
241 mc = YuMincho~Medium, mc-b = YuMincho~Demibold,
242 gt-d = YuGothic~Medium, gt-u = YuGothic~Medium,
243 gt-b = YuGothic~Bold, gt-eb = YuGothic~Bold,
244 mg-m = YuGothic~Bold,
245 __custom = false, __office = false, __noembed = false,
249 \ltjpreset_declare_preset:nx{moga-mobo}{
250 mc = Moga90Mincho, mc-b = Moga90Mincho~Bold,
251 gt-d = Moga90Gothic, gt-b = Moga90Gothic~Bold,
252 gt-u = Moga90Gothic, gt-eb = Moga90Gothic~Bold,
254 __custom = false, __office = false, __noembed = false,
256 \ltjpreset_declare_preset:nx{moga-mobo-ex}{
257 mc = MogaEx90Mincho, mc-b = MogaEx90Mincho~Bold,
258 gt-d = MogaEx90Gothic, gt-b = MogaEx90Gothic~Bold,
259 gt-u = MogaEx90Gothic, gt-eb = MogaEx90Gothic~Bold,
260 mg-m = MoboEx90Gothic,
261 __custom = false, __office = false, __noembed = false,
265 \ltjpreset_declare_preset:nx{ume}{
267 gt-d = Ume~Gothic, gt-b = Ume~Gothic~O5,
268 gt-u = Ume~Gothic~O5, gt-eb = Ume~Gothic~O5,
269 mg-m = Ume~Gothic~O4,
270 __custom = false, __office = false, __noembed = false,
273 % Source Han {Serif,Sans}
274 \ltjpreset_declare_preset:nx{sourcehan}{
275 mc-m = Source~Han~Serif~Regular,
276 mc-b = Source~Han~Serif~Bold,
277 gt-d = Source~Han~Sans~Regular,
278 gt-b = Source~Han~Sans~Bold,
279 gt-u = Source~Han~Sans~Medium,
280 gt-eb = Source~Han~Sans~Heavy,
281 mg-m = Source~Han~Sans~Heavy,
282 mc-l = Source~Han~Serif~Light,
283 __custom = false, __office = false, __noembed = false,
285 \ltjpreset_declare_preset:nx{sourcehan-jp}{
286 mc-m = Source~Han~Serif~JP~Regular,
287 mc-b = Source~Han~Serif~JP~Bold,
288 gt-d = Source~Han~Sans~JP~Regular,
289 gt-b = Source~Han~Sans~JP~Bold,
290 gt-u = Source~Han~Sans~JP~Medium,
291 gt-eb = Source~Han~Sans~JP~Heavy,
292 mg-m = Source~Han~Sans~JP~Heavy,
293 mc-l = Source~Han~Serif~JP~Light,
294 __custom = false, __office = false, __noembed = false,
296 \ltjpreset_declare_preset:nx{noto-otc}{
297 mc-m = Noto~Serif~CJK~Regular,
298 mc-b = Noto~Serif~CJK~Bold,
299 gt-d = Noto~Sans~CJK~Regular,
300 gt-b = Noto~Sans~CJK~Bold,
301 gt-u = Noto~Sans~CJK~Medium,
302 gt-eb = Noto~Sans~CJK~Black,
303 mg-m = Noto~Sans~CJK~Black,
304 mc-l = Noto~Serif~CJK~Light,
305 __custom = false, __office = false, __noembed = false,
307 \ltjpreset_declare_preset:nx{noto-otf}{
308 mc-m = Noto~Serif~CJK~JP~Regular,
309 mc-b = Noto~Serif~CJK~JP~Bold,
310 gt-d = Noto~Sans~CJK~JP~Regular,
311 gt-b = Noto~Sans~CJK~JP~Bold,
312 gt-u = Noto~Sans~CJK~JP~Medium,
313 gt-eb = Noto~Sans~CJK~JP~Black,
314 mg-m = Noto~Sans~CJK~JP~Black,
315 mc-l = Noto~Serif~CJK~JP~Light,
316 __custom = false, __office = false, __noembed = false,
319 % HaranoAji {Mincho, Gothic}
320 \ltjpreset_declare_preset:nx{haranoaji}{
321 mc-m = HaranoAjiMincho-Regular.otf,
322 mc-b = HaranoAjiMincho-Bold.otf,
323 gt-d = HaranoAjiGothic-Regular.otf,
324 gt-b = HaranoAjiGothic-Bold.otf,
325 gt-u = HaranoAjiGothic-Medium.otf,
326 gt-eb = HaranoAjiGothic-Heavy.otf,
327 mg-m = HaranoAjiGothic-Heavy.otf,
328 mc-l = HaranoAjiMincho-Light.otf,
329 __custom = false, __office = false, __noembed = false,
334 \ltjpreset_declare_preset:nx{ipa}{
335 \__ltjpreset_set_uni:nn { IPAMincho } { IPAGothic }
337 \ltjpreset_declare_preset:nx{ipaex}{
338 \__ltjpreset_set_uni:nn { IPAExMincho } { IPAExGothic }
340 \ltjpreset_declare_preset:nx{ms}{
341 \__ltjpreset_set_uni:nn { MS-Mincho } { MS-Gothic }
344 % {ipa,ipaex,ms}-dx % Office 付属フォントを利用
345 \ltjpreset_declare_preset:nx{ipaex-hg}{
346 \__ltjpreset_set_office:nn { IPAExMincho } { IPAExGothic }
348 \ltjpreset_declare_preset:nx{ipa-hg}{
349 \__ltjpreset_set_office:nn { IPAMincho } { IPAGothic }
351 \ltjpreset_declare_preset:nx{ms-hg}{
352 \__ltjpreset_set_office:nn { MS-Mincho } { MS-Gothic }
357 \ltjpreset_declare_preset:nx{noembed}{
358 \__ltjpreset_set_uni:nn { Ryumin-Light } { GothicBBB-Medium },
359 __custom = false, __office = false, __noembed = true,
362 \keys_set:nn {luatexja-preset} { haranoaji } %% old: ipaex
363 \ProcessKeysOptions { luatexja-preset }
364 \@ifpackageloaded{luatexja-fontspec}{
365 \bool_if:NT \g__ltjpreset_nfssonly_bool
366 { \msg_warning:nn { luatexja-preset }{ ltj-fontspec } }
367 \bool_set_false:N \g__ltjpreset_nfssonly_bool
370 %%%%%%%% main routine
372 \cs_new:Nn \__ltjpreset_extract_fonts: {
373 %% MogaMincho の場合は 90 をつける/はずす
374 \bool_if:NF \g__ltjpreset_custom_bool {
375 \tl_set:Nn \l_tmpa_tl {, CJKShape=JIS2004 }
376 \tl_if_eq:NNT \l__ltjpreset_kanji_shape_tl \l_tmpa_tl {
377 \tl_set:Nx \l_tmpb_tl { \prop_item:Nn \g__ltjpreset_font_prop { mc-m } }
378 \tl_if_in:NnT \l_tmpb_tl { Moga90Mincho } {
379 \prop_clear:N \l_tmpa_prop
380 \prop_map_inline:Nn \g__ltjpreset_font_prop {
381 \tl_set:Nn \l_tmpb_tl { ##2 } \tl_remove_all:Nn \l_tmpb_tl {90}
382 \prop_put:Nnx \l_tmpa_prop { ##1 } { \tl_use:N \l_tmpb_tl }
384 \prop_set_eq:NN \g__ltjpreset_font_prop \l_tmpa_prop
386 \tl_if_in:NnT \l_tmpb_tl { MogaEx90Mincho } {
387 \prop_clear:N \l_tmpa_prop
388 \prop_map_inline:Nn \g__ltjpreset_font_prop {
389 \tl_set:Nn \l_tmpb_tl { ##2 } \tl_remove_all:Nn \l_tmpb_tl {90}
390 \prop_put:Nnx \l_tmpa_prop { ##1 } { \tl_use:N \l_tmpb_tl }
392 \prop_set_eq:NN \g__ltjpreset_font_prop \l_tmpa_prop
397 \cs_set:Nx \__ltjpreset_font_mc_l: { \prop_item:Nn \g__ltjpreset_font_prop { mc-l } }
398 \cs_set:Nx \__ltjpreset_font_mc_m: { \prop_item:Nn \g__ltjpreset_font_prop { mc-m } }
399 \cs_set:Nx \__ltjpreset_font_mc_b: { \prop_item:Nn \g__ltjpreset_font_prop { mc-b } }
400 \cs_set:Nx \__ltjpreset_font_gt_m: { \prop_item:Nn \g__ltjpreset_font_prop { gt-d } }
401 \cs_set:Nx \__ltjpreset_font_gt_u: { \prop_item:Nn \g__ltjpreset_font_prop { gt-u } }
402 \cs_set:Nx \__ltjpreset_font_gt_b: { \prop_item:Nn \g__ltjpreset_font_prop { gt-b } }
403 \cs_set:Nx \__ltjpreset_font_gt_eb: { \prop_item:Nn \g__ltjpreset_font_prop { gt-eb } }
404 \cs_set:Nx \__ltjpreset_font_mg_m: { \prop_item:Nn \g__ltjpreset_font_prop { mg-m } }
405 %% HG 系フォント + JIS2004/90JIS のときはフォント名を置換
406 \bool_if:nT { !\g__ltjpreset_custom_bool && \g__ltjpreset_office_bool } {
407 \tl_set:Nn \l_tmpa_tl {, CJKShape=JIS2004 }
408 \tl_if_eq:NNT \l__ltjpreset_kanji_shape_tl \l_tmpa_tl {
409 \cs_set:Nx \__ltjpreset_font_mc_b: { hgrme04.ttc }
410 \cs_set:Nx \__ltjpreset_font_gt_b: { hgrge04.ttc }
411 \cs_set:Nx \__ltjpreset_font_gt_eb: { hgrsgu04.ttc }
412 \cs_set:Nx \__ltjpreset_font_mg_m: { hgrsmp04.ttf }
413 \cs_set_eq:NN \__ltjpreset_font_gt_m: \__ltjpreset_font_gt_u:
414 % HG ゴシックM のときはそうはいかないので 1 ウェイト時のゴシック体を使う
416 \tl_set:Nn \l_tmpa_tl {, CJKShape=JIS1990 }
417 \tl_if_eq:NNT \l__ltjpreset_kanji_shape_tl \l_tmpa_tl {
418 \cs_set:Nx \__ltjpreset_font_mc_b: { hgrme.ttc }
419 \cs_set:Nx \__ltjpreset_font_gt_b: { hgrge.ttc }
420 \cs_set:Nx \__ltjpreset_font_gt_eb: { hgrsgu.ttc }
421 \cs_set:Nx \__ltjpreset_font_mg_m: { hgrsmp.ttf }
425 \tl_set:Nx \l_tmpa_tl { \__ltjpreset_font_mc_l: }
426 \tl_if_empty:NT \l_tmpa_tl {\tl_set:Nn \l_tmpa_tl {~}}
427 \cs_set:Nx \__ltjpreset_font_mc_l: {
428 \tl_if_blank:nTF \l_tmpa_tl { \__ltjpreset_font_mc_m: } {\tl_use:N \l_tmpa_tl }
431 \bool_if:NTF \g__ltjpreset_deluxe_bool {
432 \bool_if:NT \g__ltjpreset_bold_bool {
433 \cs_set_eq:NN \__ltjpreset_font_mc_b: \__ltjpreset_font_gt_b:
436 \bool_if:NTF \g__ltjpreset_bold_bool
437 { \cs_set_eq:NN \__ltjpreset_font_gt_m: \__ltjpreset_font_gt_b: }
438 { \cs_set_eq:NN \__ltjpreset_font_gt_m: \__ltjpreset_font_gt_u: }
439 \cs_set_eq:NN \__ltjpreset_font_gt_b: \__ltjpreset_font_gt_m:
440 \cs_set_eq:NN \__ltjpreset_font_mc_b: \__ltjpreset_font_gt_m:
444 %%%%%%%% フォント名を \l__ltjpreset_font_name: に格納
445 \clist_new:N \l__ltjpreset_extensions_clist
446 \clist_set:Nn \l__ltjpreset_extensions_clist {.otf,.ttf,.OTF,.TTF,.ttc,.TTC}
447 \prg_new_conditional:Nnn \__ltjpreset_if_detect_external:n {TF} {
448 \clist_map_inline:Nn \l__ltjpreset_extensions_clist {
449 \bool_set_false:N \l_tmpa_bool
450 \tl_if_in:nnT {#1 <= end_of_string} {##1 <= end_of_string}
451 { \bool_set_true:N \l_tmpa_bool \clist_map_break: }
453 \bool_if:NTF \l_tmpa_bool \prg_return_true: \prg_return_false:
455 \cs_new:Nn \__ltjpreset_wrap_fontname:n {
456 \__ltjpreset_if_detect_external:nTF { #1 }
457 { \cs_set:Nn \l__ltjpreset_font_name: { [#1] } }
458 { \cs_set:Nn \l__ltjpreset_font_name: { "#1" } }
460 \cs_generate_variant:Nn \__ltjpreset_wrap_fontname:n { e }
463 \cs_new:Nn \__ltjpreset_substitute:nnnn {
465 \suppressfontnotfounderror=1
466 \cs_if_exist:cT {ltjpreset_font_#1_#2:} {
467 \__ltjpreset_wrap_fontname:e { \cs:w ltjpreset_font_#1_#2: \cs_end: }
468 \font \g__ltjpreset_font_test: = \l__preset_font_name:\relax
469 \ifx \g__ltjpreset_font_test: \nullfont
470 \msg_warning:nnxxxx { luatexja-preset }{ no-font }
471 { \cs:w ltjpreset_font_#1_#2: \cs_end: }{ #1/#2 }
472 { \cs:w ltjpreset_font_#3_#4: \cs_end: }{ #3/#4 }
473 \cs_gset_eq:cc { ltjpreset_font_#1_#2: } { ltjpreset_font_#3_#4: }
475 } { \cs_gset_eq:cc { ltjpreset_font_#1_#2: } { ltjpreset_font_#3_#4: } }
479 %%%%%%%% deluxe (\mgfamily はあとで定義)
480 \bool_if:NTF \g__ltjpreset_deluxe_bool {
481 \cs_new:Nn \__ltjpreset_check_deluxe_existence: {
482 \__ltjpreset_substitute:nnnn { gt } { eb } { gt } { b }
483 \__ltjpreset_substitute:nnnn { mg } { m } { gt } { b }
484 \__ltjpreset_substitute:nnnn { mc } { l } { mc } { m }
487 \DeclareRobustCommand\ltseries { \not@math@alphabet\ltseries\relax\fontseries\ltdefault\selectfont }
489 \DeclareRobustCommand\ebseries { \not@math@alphabet\ebseries\relax\fontseries\ebdefault\selectfont }
490 \DeclareRobustCommand\gtebfamily { \gtfamily\fontseries{\ebdefault}\selectfont }
492 \cs_set_eq:NN \__ltjpreset_check_deluxe_existence: \prg_do_nothing:
495 \int_new:N \g__ltjpreset_applycount_int
497 \bool_if:NTF \g__ltjpreset_nfssonly_bool {
498 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
500 \cs_if_exist:NF \Cjascale {
502 \fontsize{16}{16}\selectfont
503 \cs_gset:Npx \Cjascale { \fp_to_decimal:n {\zw / 16} }
507 \msg_warning:nnx { luatexja-preset }{ scale }{ \Cjascale }
509 % {1: encoding}{2: family}{3: series}{4: shape}{5: fontname}{6: feature}{7: scale}
510 \cs_new:Nn \__ltjpreset_declare_font_shape:nnnnnnn {
511 \DeclareFontShape{#1}{#2}{#3}{#4}{ <-> s*[#7]
512 \bool_if:NT \g__ltjpreset_noembed_bool {psft:} #5
513 ;-kern \tl_use:N \l__ltjpreset_kanji_shape_tl; #6 } {}
515 \cs_new:Nn \__ltjpreset_define_family:nnn {
516 \__ltjpreset_wrap_fontname:e { #3 }
517 \__ltjpreset_declare_font_shape:nnnnnnn { JY3 }
518 { ltjp #1 \int_to_arabic:n { \g__ltjpreset_applycount_int }} { #2 } { n }
519 { \l__ltjpreset_font_name: : jfm=\tl_use:N \__ltjpreset_use_jfm_yoko_tl }
520 { script=hani \bool_if:NT \g__ltjpreset_expert_bool { ;+hkna } }
522 \__ltjpreset_declare_font_shape:nnnnnnn { JT3 }
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_tate_tl }
525 { script=hani \bool_if:NT \g__ltjpreset_expert_bool { ;+vkna } }
527 \bool_if:NT \g__ltjpreset_expert_bool {
528 \__ltjpreset_declare_font_shape:nnnnnnn { JY3 }
529 { ltjp #1 \int_to_arabic:n { \g__ltjpreset_applycount_int }} { #2 } { rb }
530 { \l__ltjpreset_font_name: : jfm=\tl_use:N \__ltjpreset_use_jfm_yoko_tl } { script=kana; +ruby }
532 \__ltjpreset_declare_font_shape:nnnnnnn { JT3 }
533 { ltjp #1 \int_to_arabic:n { \g__ltjpreset_applycount_int }} { #2 } { rb }
534 { \l__ltjpreset_font_name: : jfm=\tl_use:N \__ltjpreset_use_jfm_tate_tl } { script=kana; +ruby }
537 \cs_if_exist:NT \ltjpreset_define_family_hook_nfssonly:nnn
538 { \ltjpreset_define_family_hook_nfssonly:nnn { #1 } { #2 } { #3 } }
540 \bool_if:NT \g__ltjpreset_deluxe_bool {
541 \let\mgfamily\undefined
542 \DeclareRobustCommand\mgfamily {
543 \not@math@alphabet\mgfamily\relax
544 \kanjifamily{ltjpmg \int_to_arabic:n { \g__ltjpreset_applycount_int }}\selectfont
546 \DeclareTextFontCommand{\textmg}{\mgfamily}
548 \bool_if:NT \g__ltjpreset_expert_bool {
549 \DeclareRobustCommand\rubyfamily { \kanjishape{rb}\selectfont }
552 \cs_new:Nn \__ltjpreset_do_fontset: { \group_begin:
554 \xdef\mcdefault{ltjpmc \int_to_arabic:n { \g__ltjpreset_applycount_int }}
555 \xdef\gtdefault{ltjpgt \int_to_arabic:n { \g__ltjpreset_applycount_int }}
556 \DeclareKanjiFamily{JY3}{\mcdefault}{}
557 \DeclareKanjiFamily{JT3}{\mcdefault}{}
558 \DeclareKanjiFamily{JY3}{\gtdefault}{}
559 \DeclareKanjiFamily{JT3}{\gtdefault}{}
560 \unless\ifltj@disablejfam
561 \SetSymbolFont{mincho}{normal}{JY3}{\mcdefault}{m}{n}
562 \SetSymbolFont{mincho}{bold}{JY3}{\mcdefault}{b}{n}
563 \DeclareMathAlphabet{\mathgt}{JY3}{\gtdefault}{m}{n}
565 \bool_if:NT \g__ltjpreset_deluxe_bool {
566 \DeclareKanjiFamily{JY3}{ltjpmg \int_to_arabic:n { \g__ltjpreset_applycount_int }}{}
567 \DeclareKanjiFamily{JT3}{ltjpmg \int_to_arabic:n { \g__ltjpreset_applycount_int }}{}
570 \tl_set:Nn \l_tmpa_tl {, CJKShape=JIS1990 }
571 \tl_if_eq:NNT \l__ltjpreset_kanji_shape_tl \l_tmpa_tl {
572 \tl_set:Nn \l__ltjpreset_kanji_shape_tl { ;+jp90 }
574 \tl_set:Nn \l_tmpa_tl {, CJKShape=JIS2004 }
575 \tl_if_eq:NNT \l__ltjpreset_kanji_shape_tl \l_tmpa_tl {
576 \tl_set:Nx \l__ltjpreset_kanji_shape_tl { ;+jp04 }
578 \__ltjpreset_define_family:nnn {mc} {m} {\__ltjpreset_font_mc_m:}
579 \__ltjpreset_define_family:nnn {mc} {bx} {\__ltjpreset_font_mc_b:}
580 \__ltjpreset_define_family:nnn {mc} {b} {\__ltjpreset_font_mc_b:}
581 \__ltjpreset_define_family:nnn {gt} {m} {\__ltjpreset_font_gt_m:}
582 \__ltjpreset_define_family:nnn {gt} {bx} {\__ltjpreset_font_gt_b:}
583 \__ltjpreset_define_family:nnn {gt} {b} {\__ltjpreset_font_gt_b:}
585 \bool_if:NT \g__ltjpreset_deluxe_bool {
586 \__ltjpreset_define_family:nnn {mc} {l} {\__ltjpreset_font_mc_l:}
587 \__ltjpreset_define_family:nnn {gt} {eb} {\__ltjpreset_font_gt_eb:}
588 \__ltjpreset_define_family:nnn {mg} {m} {\__ltjpreset_font_mg_m:}
592 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
595 \RequirePackage{luatexja-fontspec}
597 \msg_warning:nnx { luatexja-preset }{ scale }{ \Cjascale }
598 \tl_new:N \l__ltjpreset_add_features_tl
600 \bool_if:NT \g__ltjpreset_expert_bool {
601 \cs_set:Npn \rubyfamily { \addjfontfeatures {
602 Style=Ruby , YokoFeatures={RawFeature=-hkna} , TateFeatures={RawFeature=-vkna}
605 \addjfontfeature{ Kerning=Off }
607 \cs_new:Nn \__ltjpreset_do_fontset: { \group_begin:
608 \tl_gset:Nx \l__ltjpreset_add_features_tl {
609 \tl_use:N \l__ltjpreset_kanji_shape_tl,
610 YokoFeatures = { JFM = \tl_use:N \__ltjpreset_use_jfm_yoko_tl },
611 TateFeatures = { JFM = \tl_use:N \__ltjpreset_use_jfm_tate_tl },
612 Script=CJK, \bool_if:NT \g__ltjpreset_noembed_bool { , NoEmbed }
615 \bool_if:NT \g__ltjpreset_expert_bool {
616 \tl_put_left:Nn \l__ltjpreset_add_features_tl {
617 , YokoFeatures = {Style = HorizontalKana}, TateFeatures = {Style = VerticalKana}
621 \bool_if:NT \g__ltjpreset_deluxe_bool {
622 FontFace={l}{n}{ Font = \__ltjpreset_font_mc_l:,
623 \cs_if_exist:NT \ltjpreset_define_family_hook_fontspec:nnn {
624 \ltjpreset_define_family_hook_fontspec:nnn
625 { mc } { l } { \__ltjpreset_font_mc_l: }
629 BoldFont = \__ltjpreset_font_mc_b: \tl_use:N \l__ltjpreset_add_features_tl,
630 \cs_if_exist:NT \ltjpreset_define_family_hook_fontspec:nnn {
631 UprightFeatures = { \ltjpreset_define_family_hook_fontspec:nnn
632 { mc } { m } { \__ltjpreset_font_mc_m: } },
633 BoldFeatures = { \ltjpreset_define_family_hook_fontspec:nnn
634 { mc } { b } { \__ltjpreset_font_mc_b: } },
636 ] { \__ltjpreset_font_mc_m: }
638 \bool_if:NT \g__ltjpreset_deluxe_bool {
639 FontFace={eb}{n}{ Font = \__ltjpreset_font_gt_eb:,
640 \cs_if_exist:NT \ltjpreset_define_family_hook_fontspec:nnn {
641 \ltjpreset_define_family_hook_fontspec:nnn
642 { gt } { eb } { \__ltjpreset_font_gt_eb: }
646 BoldFont = \__ltjpreset_font_gt_b: \tl_use:N \l__ltjpreset_add_features_tl,
647 \cs_if_exist:NT \ltjpreset_define_family_hook_fontspec:nnn {
648 UprightFeatures = { \ltjpreset_define_family_hook_fontspec:nnn
649 { gt } { m } { \__ltjpreset_font_gt_m: } },
650 BoldFeatures = { \ltjpreset_define_family_hook_fontspec:nnn
651 { gt } { b } { \__ltjpreset_font_gt_b: } },
653 ] { \__ltjpreset_font_gt_m: }
654 \bool_if:NT \g__ltjpreset_deluxe_bool {
656 \bool_if_exist:NTF \setfontfamily {
657 \setjfontfamily \mgfamily [
658 BoldFont = \__ltjpreset_font_mg_m: \tl_use:N \l__ltjpreset_add_features_tl,
659 \cs_if_exist:NT \ltjpreset_define_family_hook_fontspec:nnn {
660 \ltjpreset_define_family_hook_fontspec:nnn
661 { mg } { m } { \__ltjpreset_font_mg_m: },
663 ] { \__ltjpreset_font_mg_m: }
665 \newjfontfamily \mgfamily [
666 BoldFont = \__ltjpreset_font_mg_m: \tl_use:N \l__ltjpreset_add_features_tl,
667 \cs_if_exist:NT \ltjpreset_define_family_hook_fontspec:nnn {
668 \ltjpreset_define_family_hook_fontspec:nnn
669 { mg } { m } { \__ltjpreset_font_mg_m: },
671 ] { \__ltjpreset_font_mg_m: }
673 \DeclareTextFontCommand{\textmg}{\mgfamily}
676 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
680 \@ifstar{\__ltjpreset_new_preset:nnn{ true }}{\__ltjpreset_new_preset:nnn{ false }}}
681 \cs_set:Nn \__ltjpreset_new_preset:nnn {
682 \keys_if_exist:nnTF { luatexja-preset } { #2 } {
683 \seq_if_in:NnTF \g__ltjpreset_presets_seq { #2 } {
684 \bool_if:cTF { c_ #1 _bool } {
685 \msg_warning:nnn { luatexja-preset }{ exist-preset-overwrite } { #2 }
686 \keys_define:nn { luatexja-preset } {
687 #2 .meta:n = { #3, __custom = true, __noembed = false, __office = false, },
688 #2 .value_forbidden:n = true, #2 .groups:n = { preset },
691 \msg_error:nnn { luatexja-preset }{ exist-preset-nooverwrite } { #2 }
694 \msg_error:nnn { luatexja-preset }{ illegal-preset-name } { #2 }
697 \keys_define:nn { luatexja-preset } {
698 #2 .meta:n = { #3, __custom = true, __noembed = false, __office = false, },
699 #2 .value_forbidden:n = true, #2 .groups:n = { preset },
701 \seq_put_right:Nn \g__ltjpreset_presets_seq { #2 }
706 \cs_set:Npn \ltjapplypreset #1 {
707 \int_gincr:N \g__ltjpreset_applycount_int
708 \keys_set_groups:nnn { luatexja-preset } { preset } { #1 }
709 % \prop_map_inline:Nn \g__ltjpreset_font_prop {\typeout{ [##1] = "##2" } }
710 \__ltjpreset_extract_fonts:
711 \__ltjpreset_check_deluxe_existence:
712 \__ltjpreset_do_fontset:
718 \@onlypreamble\ltjnewpreset
719 \@onlypreamble\ltjapplypreset