OSDN Git Service

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