OSDN Git Service

Removed foolish code: use \fontspec_update_fontid:n.
[luatex-ja/luatexja.git] / src / luatexja-fontspec.sty
1 %
2 % luatexja-fontspec.sty
3 %
4
5 \NeedsTeXFormat{LaTeX2e}
6 \ProvidesPackage{luatexja-fontspec}[2011/08/17 v0.1]
7
8 \RequirePackage{luatexja,fontspec}
9
10 \ExplSyntaxOn
11
12 \define@key[zf]{options}{JFM}{
13   \fontspec_update_fontid:n  {+jfm=#1}
14   \fontspec_update_featstr:n {jfm=#1}
15 }
16
17 \cs_new:Nn \ltj_fontspec_select:nn {
18   \group_begin:
19   \tl_set:Nn \zf@enc {JY3}
20   \fontspec_select:nn{JFM=ujis,#1}{#2}
21   \group_end:
22 }
23
24 \cs_new:Nn \ltj_fontspec_set_newjfamily:Nnn {
25   \ltj_fontspec_select:nn{#2}{#3}
26   \tl_set_eq:NN #1 \zf@family
27 }
28
29 \DeclareDocumentCommand \jfontspec { O{} m } {
30   \ltj_fontspec_set_newjfamily:Nnn \k@family {#1}{#2}
31   \selectfont
32   \ignorespaces
33 }
34
35 \DeclareDocumentCommand \setmainjfont { O{} m } {
36   \ltj_fontspec_set_newjfamily:Nnn \mcdefault {#1}{#2}
37   \normalfont
38 }
39
40 \DeclareDocumentCommand \setsansjfont { O{} m } {
41   \ltj_fontspec_set_newjfamily:Nnn \gtdefault {#1}{#2}
42   \normalfont
43 }
44
45 \DeclareRobustCommand\jfontfamily[1]{\edef\k@family{#1}}
46
47 \DeclareDocumentCommand \newjfontfamily { m O{} m } {
48   \ltj_fontspec_select:nn{#2}{#3}
49   \use:x {
50     \exp_not:N \DeclareRobustCommand \exp_not:N #1 {
51       \exp_not:N \jfontfamily {\zf@family} \exp_not:N \selectfont
52     }
53   }
54 }
55
56 \endinput