OSDN Git Service

Added \newjfontface, \defaultjfontfeatures, \addjfontfeatures to luatexja-fontspec.sty
authorKazuki Maeda <kmaeda@users.sourceforge.jp>
Mon, 5 Sep 2011 16:31:41 +0000 (01:31 +0900)
committerKazuki Maeda <kmaeda@users.sourceforge.jp>
Mon, 5 Sep 2011 16:31:41 +0000 (01:31 +0900)
src/luatexja-fontspec.sty

index 093a319..a705823 100644 (file)
@@ -9,6 +9,14 @@
 
 \ExplSyntaxOn
 
+\cs_new:Npn \ltj_fontspec_warning:n   { \msg_warning:nn   {ltj_fontspec} }
+
+\msg_new:nnn {ltj_fontspec} {addjfontfeatures-ignored}
+{
+  \string\addjfontfeature (s)~ ignored;\\
+  it~ cannot~ be~ used~ with~ a~ font~ that~ wasn't~ selected~ by~ luatexja-fontspec.
+}
+
 \define@key[zf]{options}{JFM}{
   \fontspec_update_fontid:n  {+jfm=#1}
   \fontspec_update_featstr:n {jfm=#1}
@@ -17,8 +25,9 @@
 \cs_new:Nn \ltj_fontspec_select:nn {
   \group_begin:
   \tl_set:Nn \zf@enc {JY3}
+  \tl_set:Nn \g_fontspec_default_fontopts_tl \g_ltj_fontspec_default_fontopts_tl
   \cs_set_eq:NN \DeclareFontFamily \DeclareKanjiFamily
-  \fontspec_select:nn{JFM=ujis,#1}{#2}
+  \fontspec_select:nn{JFM=ujis,Scale=0.960444,#1}{#2}
   \group_end:
 }
 
   }
 }
 
+\DeclareDocumentCommand \newjfontface { m O{} m } {
+  \newjfontfamily #1 [ BoldFont={},ItalicFont={},SmallCapsFont={},#2 ] {#3}
+}
+
+\DeclareDocumentCommand \defaultjfontfeatures {m} {
+  \tl_set:Nn \g_ltj_fontspec_default_fontopts_tl {#1,}
+}
+
+\tl_clear:N \g_ltj_fontspec_default_fontopts_tl
+
+\DeclareDocumentCommand \addjfontfeatures {m} {
+  \ifcsname zf@family@fontdef\k@family\endcsname
+    \group_begin:
+      \tl_clear:N \g_ltj_fontspec_default_fontopts_tl
+      \use:x {
+        \exp_not:N\ltj_fontspec_select:nn
+          {\csname zf@family@options\k@family\endcsname,#1}
+          {\csname zf@family@fontname\k@family\endcsname}
+      }
+    \group_end:
+    \fontfamily\zf@family\selectfont
+  \else
+    \ltj_fontspec_warning:n {addjfontfeatures-ignored}
+  \fi
+  \ignorespaces
+}
+
+\cs_set_eq:NN \addjfontfeature \addjfontfeatures
+
 \endinput