From b3270eb1ec497a524747f36b7b8e3e6de47ad902 Mon Sep 17 00:00:00 2001 From: Kazuki Maeda Date: Tue, 6 Sep 2011 01:31:41 +0900 Subject: [PATCH] Added \newjfontface, \defaultjfontfeatures, \addjfontfeatures to luatexja-fontspec.sty --- src/luatexja-fontspec.sty | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/luatexja-fontspec.sty b/src/luatexja-fontspec.sty index 093a319..a705823 100644 --- a/src/luatexja-fontspec.sty +++ b/src/luatexja-fontspec.sty @@ -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: } @@ -52,4 +61,33 @@ } } +\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 -- 2.11.0