OSDN Git Service

luatexja-preset.sty: changed presets' name.
[luatex-ja/luatexja.git] / src / addons / luatexja-preset.sty
1 % luatexja-preset.sty
2 \ProvidesPackage{luatexja-preset}
3   [2013/04/08 v0.2]
4 %% Sync with PXchfon 0.6a
5
6 \RequirePackage{expl3}
7 \RequirePackage{luatexja-fontspec}
8 \ExplSyntaxOn
9
10 %%%% message
11
12 \bool_new:N \l_ltjpreset_bold_bool % bold
13 \bool_set_false:N \l_ltjpreset_bold_bool
14 \DeclareOption{bold}  {\bool_set_true:N \l_ltjpreset_bold_bool}
15 \DeclareOption{nobold}{\bool_set_false:N \l_ltjpreset_bold_bool}
16
17 \bool_new:N \l_ltjpreset_expert_bool % expert
18 \bool_set_false:N \l_ltjpreset_expert_bool
19 \DeclareOption{expert}  {\bool_set_true:N \l_ltjpreset_expert_bool}
20 \DeclareOption{noexpert}{\bool_set_false:N \l_ltjpreset_expert_bool}
21
22 \int_new:N \l_ltjpreset_deluxe_int % expert
23 \int_set:Nn \l_ltjpreset_deluxe_int { 0 }
24 \DeclareOption{deluxe}{\int_set:Nn \l_ltjpreset_deluxe_int { 2 }}   % 7 fonts
25 \DeclareOption{nodeluxe}{\int_set:Nn \l_ltjpreset_deluxe_int { 0 }} % 2 fonts
26
27 % scale
28 \msg_new:nnn { luatexja-preset }{ scale }{
29   Japanese~fonts~will~be~scaled~by~\fp_use:N \g_ltj_fontspec_scale_fp.
30 }
31 \msg_warning:nn { luatexja-preset }{ scale }
32
33 % JFM
34 \cs_set:Npn \ltjpreset_use_jfm: {ujis}  % 使用する JFM
35 %%% \DeclareOption{min}{\cs_set:Npn  \ltjpreset_use_jfm: {min}} % min
36 %%% ↑jfm-min.lua が横組み・縦組み専用仮名に追いついていないので使用禁止
37 \DeclareOption{jis}{\cs_set:Npn  \ltjpreset_use_jfm: {jis}}     % jis
38 \DeclareOption{ujis}{\cs_set:Npn  \ltjpreset_use_jfm: {ujis}}   % ujis
39
40 % 漢字字形
41 \tl_new:N \l_ltjpreset_kanji_shape_tl
42 \DeclareOption{90jis}{  \tl_set:Nn \l_ltjpreset_kanji_shape_tl { , RawFeature = +jp90 }} % 90jis
43 \DeclareOption{jis2004}{\tl_set:Nn \l_ltjpreset_kanji_shape_tl { , RawFeature = +jp04 }} % jis2004
44
45 % font preset
46 \bool_new:N \l_ltjpreset_office_bool  % MS Office の HG 系フォントを使っているか
47 \bool_new:N \l_ltjpreset_noembed_bool % 非埋込か
48 \clist_new:N \l_ltjpreset_font_list
49
50 \cs_new:Npn \ltjpreset_set_uni:nn #1#2 {
51   \ltjpreset_set_multi:n { #1, #1, #2, #2, #2, #2, #1 }
52 }
53 \cs_new:Npn \ltjpreset_set_multi:n #1 {
54   \clist_set:Nn \l_ltjpreset_font_list { #1 }
55   \bool_set_false:N \l_ltjpreset_office_bool
56   \bool_set_false:N \l_ltjpreset_noembed_bool
57 }
58 \cs_new:Npn \ltjpreset_set_office:nn #1 #2{
59   \ltjpreset_set_multi:n {
60     #1, HGMinchoE ,           % mc/m, mc/bx
61     HGGothicM , HGGothicE ,   % gt/m, gt/bx (multiweight))
62     #2 , HGSoeiKakugothicUB , % gt/m (uni), gt/eb
63     HGMaruGothicMPRO          % mg/m
64   }
65   \bool_set_true:N \l_ltjpreset_office_bool
66 }
67
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 %%% OBSOLETE
70 % kozuka
71 \DeclareOption{kozuka4}{
72   \ltjpreset_set_multi:n {
73     KozMinPro-Regular.otf , KozMinPro-Bold.otf, % mc/m, mc/bx
74     KozGoPro-Regular.otf  , KozGoPro-Bold.otf,  % gt/m, gt/bx (multiweight))
75     KozGoPro-Medium.otf   , KozGoPro-Heavy.otf, % gt/m (uni), gt/eb
76     KozGoPro-Heavy.otf                          % mg/m
77   }
78 }
79 \DeclareOption{kozuka6}{
80   \ltjpreset_set_multi:n {
81     KozMinProVI-Regular.otf , KozMinProVI-Bold.otf, % mc/m, mc/bx
82     KozGoProVI-Regular.otf  , KozGoProVI-Bold.otf,  % gt/m, gt/bx (multiweight))
83     KozGoProVI-Medium.otf   , KozGoProVI-Heavy.otf, % gt/m (uni), gt/eb
84     KozGoProVI-Heavy.otf                            % mg/m
85   }
86 }
87 \DeclareOption{kozuka6n}{
88   \ltjpreset_set_multi:n {
89     KozMinPr6N-Regular.otf , KozMinPr6N-Bold.otf, % mc/m, mc/bx
90     KozGoPr6N-Regular.otf  , KozGoPr6N-Bold.otf,  % gt/m, gt/bx (multiweight))
91     KozGoPr6N-Medium.otf   , KozGoPr6N-Heavy.otf, % gt/m (uni), gt/eb
92     KozGoPr6N-Heavy.otf                           % mg/m
93   }
94 }
95
96 % hiragino
97 \DeclareOption{hiragino}{
98   \ltjpreset_set_multi:n {
99     HiraMinPro-W3.otf      , HiraMinPro-W6.otf,   % mc/m, mc/bx
100     HiraKakuPro-W3.otf     , HiraKakuPro-W6.otf,  % gt/m, gt/bx (multiweight))
101     HiraKakuPro-W3.otf     , HiraKakuStd-W8.otf,  % gt/m (uni), gt/eb
102     HiraMaruPro-W4.otf                            % mg/m
103   }
104 }
105 \DeclareOption{hiraginon}{
106   \ltjpreset_set_multi:n {
107     HiraMinProN-W3.otf      , HiraMinProN-W6.otf,   % mc/m, mc/bx
108     HiraKakuProN-W3.otf     , HiraKakuProN-W6.otf,  % gt/m, gt/bx (multiweight))
109     HiraKakuProN-W3.otf     , HiraKakuStdN-W8.otf,  % gt/m (uni), gt/eb
110     HiraMaruProN-W4.otf                             % mg/m
111   }
112 }
113
114 % morisawa?
115 \DeclareOption{morisawa4}{
116   \ltjpreset_set_multi:n {
117     A-OTF-RyuminPro-Light.otf , A-OTF-FutoMinA101Pro-Bold.otf ,    % mc/m, mc/bx
118     A-OTF-GothicBBBPro-Medium.otf , A-OTF-FutoGoB101Pro-Bold.otf , % gt/m, gt/bx (multiweight))
119     A-OTF-GothicBBBPro-Medium.otf , A-OTF-MidashiGoPro-MB31.otf ,  % gt/m (uni), gt/eb
120     A-OTF-Jun101Pro-Light.otf % mg/m
121   }
122 }
123 \DeclareOption{morisawa6n}{
124   \ltjpreset_set_multi:n {
125     A-OTF-RyuminPr6N-Light.otf , A-OTF-FutoMinA101Pr6N-Bold.otf ,    % mc/m, mc/bx
126     A-OTF-GothicBBBPr6N-Medium.otf , A-OTF-FutoGoB101Pr6N-Bold.otf , % gt/m, gt/bx (multiweight))
127     A-OTF-GothicBBBPr6N-Medium.otf , A-OTF-MidashiGoPr6N-MB31.otf ,  % gt/m (uni), gt/eb
128     A-OTF-Jun101Pr6N-Light.otf                                       % mg/m
129   }
130 }
131
132 \DeclareOption{ipaex-dx}{\ltjpreset_set_office:nn { IPAExMincho } { IPAExGothic }}
133 \DeclareOption{ipa-dx}  {\ltjpreset_set_office:nn { IPAMincho } { IPAGothic }}
134 \DeclareOption{ms-dx}   {\ltjpreset_set_office:nn { MS-Mincho } { MS-Gothic }}
135 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
136
137
138
139 % kozuka
140 \DeclareOption{kozuka-pro}{
141   \ltjpreset_set_multi:n {
142     KozMinPro-Regular.otf , KozMinPro-Bold.otf, % mc/m, mc/bx
143     KozGoPro-Regular.otf  , KozGoPro-Bold.otf,  % gt/m, gt/bx (multiweight))
144     KozGoPro-Medium.otf   , KozGoPro-Heavy.otf, % gt/m (uni), gt/eb
145     KozGoPro-Heavy.otf                          % mg/m
146   }
147 }
148 \DeclareOption{kozuka-pr6}{
149   \ltjpreset_set_multi:n {
150     KozMinProVI-Regular.otf , KozMinProVI-Bold.otf, % mc/m, mc/bx
151     KozGoProVI-Regular.otf  , KozGoProVI-Bold.otf,  % gt/m, gt/bx (multiweight))
152     KozGoProVI-Medium.otf   , KozGoProVI-Heavy.otf, % gt/m (uni), gt/eb
153     KozGoProVI-Heavy.otf                            % mg/m
154   }
155 }
156 \DeclareOption{kozuka-pr6n}{
157   \ltjpreset_set_multi:n {
158     KozMinPr6N-Regular.otf , KozMinPr6N-Bold.otf, % mc/m, mc/bx
159     KozGoPr6N-Regular.otf  , KozGoPr6N-Bold.otf,  % gt/m, gt/bx (multiweight))
160     KozGoPr6N-Medium.otf   , KozGoPr6N-Heavy.otf, % gt/m (uni), gt/eb
161     KozGoPr6N-Heavy.otf                           % mg/m
162   }
163 }
164
165 % hiragino
166 \DeclareOption{hiragino-pro}{
167   \ltjpreset_set_multi:n {
168     HiraMinPro-W3.otf      , HiraMinPro-W6.otf,   % mc/m, mc/bx
169     HiraKakuPro-W3.otf     , HiraKakuPro-W6.otf,  % gt/m, gt/bx (multiweight))
170     HiraKakuPro-W6.otf     , HiraKakuStd-W8.otf,  % gt/m (uni), gt/eb
171     HiraMaruPro-W4.otf                            % mg/m
172   }
173 }
174 \DeclareOption{hiragino-pron}{
175   \ltjpreset_set_multi:n {
176     HiraMinProN-W3.otf      , HiraMinProN-W6.otf,   % mc/m, mc/bx
177     HiraKakuProN-W3.otf     , HiraKakuProN-W6.otf,  % gt/m, gt/bx (multiweight))
178     HiraKakuProN-W6.otf     , HiraKakuStdN-W8.otf,  % gt/m (uni), gt/eb
179     HiraMaruProN-W4.otf                             % mg/m
180   }
181 }
182
183 % morisawa
184 \DeclareOption{morisawa-pro}{
185   \ltjpreset_set_multi:n {
186     A-OTF-RyuminPro-Light.otf , A-OTF-FutoMinA101Pro-Bold.otf ,    % mc/m, mc/bx
187     A-OTF-GothicBBBPro-Medium.otf , A-OTF-FutoGoB101Pro-Bold.otf , % gt/m, gt/bx (multiweight))
188     A-OTF-GothicBBBPro-Medium.otf , A-OTF-MidashiGoPro-MB31.otf ,  % gt/m (uni), gt/eb
189     A-OTF-Jun101Pro-Light.otf % mg/m
190   }
191 }
192 \DeclareOption{morisawa-pr6n}{
193   \ltjpreset_set_multi:n {
194     A-OTF-RyuminPr6N-Light.otf , A-OTF-FutoMinA101Pr6N-Bold.otf ,    % mc/m, mc/bx
195     A-OTF-GothicBBBPr6N-Medium.otf , A-OTF-FutoGoB101Pr6N-Bold.otf , % gt/m, gt/bx (multiweight))
196     A-OTF-GothicBBBPr6N-Medium.otf , A-OTF-MidashiGoPr6N-MB31.otf ,  % gt/m (uni), gt/eb
197     A-OTF-Jun101Pr6N-Light.otf                                       % mg/m
198   }
199 }
200
201
202 % ipa, ipaex, ms
203 \DeclareOption{ipa}{
204   \ltjpreset_set_uni:nn { IPAMincho } { IPAGothic }
205 }
206 \DeclareOption{ipaex}{
207   \ltjpreset_set_uni:nn { IPAExMincho } { IPAExGothic }
208 }
209 \DeclareOption{ms}{
210   \ltjpreset_set_uni:nn { MS-Mincho } { MS-Gothic }
211 }
212
213 % {ipa,ipaex,ms}-dx % Office 付属フォントを利用
214 \DeclareOption{ipaex-hg}{
215   \ltjpreset_set_office:nn { IPAExMincho } { IPAExGothic }
216 }
217 \DeclareOption{ipa-hg}{
218   \ltjpreset_set_office:nn { IPAMincho } { IPAGothic }
219 }
220 \DeclareOption{ms-hg}{
221   \ltjpreset_set_office:nn { MS-Mincho } { MS-Gothic }
222 }
223
224
225 % 非埋込
226 \DeclareOption{noembed}{
227   \ltjpreset_set_uni:nn { Ryumin-Light } { GothicBBB-Medium }
228   \bool_set_true:N \l_ltjpreset_noembed_bool
229 }
230
231 \ExecuteOptions{noembed}
232 \ProcessOptions*
233
234 %% KozMinPr6N の場合はjp04 feature がないので,nlck にする
235 \clist_if_in:NnT \l_ltjpreset_font_list { KozMinPr6N-Regular.otf } {
236   \tl_set:Nn \l_tmpa_tl {, RawFeature = +jp04}
237   \tl_if_eq:NNT \l_ltjpreset_kanji_shape_tl \l_tmpa_tl {
238     \tl_set:Nn \l_ltjpreset_kanji_shape_tl { , RawFeature = +nlck }
239   }
240 }
241
242 %%%%%%%% main routine
243
244 %%%%  リストからの展開
245 % mc/m
246 \clist_pop:NN \l_ltjpreset_font_list \l_tmpa_tl
247 \cs_set:Nx \ltjpreset_font_mc_m: { \tl_use:N \l_tmpa_tl }
248
249 % mc/bx
250 \clist_pop:NN \l_ltjpreset_font_list \l_tmpa_tl
251 \cs_set:Nx \ltjpreset_font_mc_bx: { \tl_use:N \l_tmpa_tl }
252
253 % gt/m
254 \clist_pop:NN \l_ltjpreset_font_list \l_tmpa_tl
255 \cs_set:Nx \ltjpreset_font_gt_m: { \tl_use:N \l_tmpa_tl }
256
257 % gt/bx
258 \clist_pop:NN \l_ltjpreset_font_list \l_tmpa_tl
259 \cs_set:Nx \ltjpreset_font_gt_bx: { \tl_use:N \l_tmpa_tl }
260
261 % gt/m-uni
262 \clist_pop:NN \l_ltjpreset_font_list \l_tmpa_tl
263 \cs_set:Nx \ltjpreset_font_gt_n_uni: { \tl_use:N \l_tmpa_tl }
264
265 % gt/eb
266 \clist_pop:NN \l_ltjpreset_font_list \l_tmpa_tl
267 \cs_set:Nx \ltjpreset_font_gt_eb: { \tl_use:N \l_tmpa_tl }
268
269 % mg/m
270 \clist_pop:NN \l_ltjpreset_font_list \l_tmpa_tl
271 \cs_set:Nx \ltjpreset_font_mg: { \tl_use:N \l_tmpa_tl }
272
273 %% HG 系フォント + JIS2004/90JIS のときはフォント名を置換
274 \bool_if:NT \l_ltjpreset_office_bool {
275   \tl_set:Nn \l_tmpa_tl {, RawFeature = +jp04}
276   \tl_if_eq:NNT \l_ltjpreset_kanji_shape_tl \l_tmpa_tl { 
277     \cs_set:Nx \ltjpreset_font_mc_bx: { hgrme04.ttc }
278     \cs_set:Nx \ltjpreset_font_gt_bx: { hgrge04.ttc }
279     \cs_set:Nx \ltjpreset_font_gt_eb: { hgrsgu04.ttc }
280     \cs_set:Nx \ltjpreset_font_mg:    { hgrsmp04.ttf }
281     \cs_set_eq:NN \ltjpreset_font_gt_m: \ltjpreset_font_gt_n_uni:
282     % HG ゴシックM のときはそうはいかないので 1 ウェイト時のゴシック体を使う
283   }
284   \tl_set:Nn \l_tmpa_tl {, RawFeature = +jp90}
285   \tl_if_eq:NNT \l_ltjpreset_kanji_shape_tl \l_tmpa_tl { 
286     \cs_set:Nx \ltjpreset_font_mc_bx: { hgrme.ttc }
287     \cs_set:Nx \ltjpreset_font_gt_bx: { hgrge.ttc }
288     \cs_set:Nx \ltjpreset_font_gt_eb: { hgrsgu.ttc }
289     \cs_set:Nx \ltjpreset_font_mg:    { hgrsmp.ttf }
290   }
291 }
292
293 %%%% expert 用設定
294 \tl_new:N \l_ltjpreset_add_features_tl
295
296 \tl_set:Nx \l_ltjpreset_add_features_tl {
297   \tl_use:N \l_ltjpreset_kanji_shape_tl, 
298   JFM   = \ltjpreset_use_jfm:
299 }
300
301 \bool_if:NT \l_ltjpreset_expert_bool {
302   \cs_set:Npn \rubyfamily { \addfontfeatures { Style = Ruby} }
303   \tl_put_left:Nn \l_ltjpreset_add_features_tl { Style = HorizontalKana, }
304 }
305
306 %%%% (丸)ゴシック体の設定: bold option もここで
307 \int_compare:nTF { \l_ltjpreset_deluxe_int ==  2 } {
308   \newjfontfamily \mgfamily [
309       \tl_use:N \l_ltjpreset_add_features_tl
310       \bool_if:NT \l_ltjpreset_noembed_bool { , NoEmbed }
311     ] { \ltjpreset_font_mg: }
312   \newjfontfamily \gtebfamily [
313       \tl_use:N \l_ltjpreset_add_features_tl
314       \bool_if:NT \l_ltjpreset_noembed_bool { , NoEmbed }
315     ] { \ltjpreset_font_gt_eb: }
316   \bool_if:NT \l_ltjpreset_bold_bool {
317     \cs_set_eq:NN \ltjpreset_font_mc_bx: \ltjpreset_font_gt_bx:
318   }
319 }{
320   \bool_if:NTF \l_ltjpreset_bold_bool {
321     \cs_set_eq:NN \ltjpreset_font_gt_m: \ltjpreset_font_gt_bx:
322   }{
323     \cs_set_eq:NN \ltjpreset_font_gt_m: \ltjpreset_font_gt_n_uni:
324   }
325   \cs_set_eq:NN \ltjpreset_font_gt_bx: \ltjpreset_font_gt_m:
326   \cs_set_eq:NN \ltjpreset_font_mc_bx: \ltjpreset_font_gt_m:
327 }
328
329
330 %%%% 実際の fontspec の呼びだし
331
332 \defaultjfontfeatures{ Kerning=Off, \tl_use:N \l_ltjpreset_add_features_tl }
333
334 \setmainjfont [ 
335   BoldFont = \ltjpreset_font_mc_bx:
336   \bool_if:NT \l_ltjpreset_noembed_bool { , NoEmbed }
337 ] { \ltjpreset_font_mc_m: }
338 \setsansjfont [ 
339   BoldFont = \ltjpreset_font_gt_bx: 
340   \bool_if:NT \l_ltjpreset_noembed_bool { , NoEmbed }
341 ] { \ltjpreset_font_gt_m: }
342
343 \ExplSyntaxOff
344 \endinput