From: Hironori Kitagawa Date: Tue, 25 Mar 2014 03:48:30 +0000 (+0900) Subject: luatexja-fontspec.sty: add \setmonojfont (defined if "match" is specified) X-Git-Tag: 20140504.0~8^2~2 X-Git-Url: http://git.osdn.jp/view?a=commitdiff_plain;h=09fa919ae761b3ba95df5d55681fdf888c979432;p=luatex-ja%2Fluatexja.git luatexja-fontspec.sty: add \setmonojfont (defined if "match" is specified) --- diff --git a/doc/luatexja.dtx b/doc/luatexja.dtx index aa9e92d..98ad53f 100644 --- a/doc/luatexja.dtx +++ b/doc/luatexja.dtx @@ -108,7 +108,9 @@ \usepackage{luatexja-otf} %\usepackage{lmodern} \directlua{luatexja.otf.enable_ivs()} +\usepackage[match]{luatexja-fontspec} \usepackage[kozuka-pr6n]{luatexja-preset} +\setmonojfont{KozGoPr6N-Regular.otf} %<*ja> \def\emph#1{\textbf{\textgt{#1}}} \def\headfont{\normalfont\bfseries\gtfamily} @@ -121,11 +123,6 @@ \setmathfont{xits-math.otf} \frenchspacing % -\DeclareRobustCommand\ttfamily - {\not@math@alphabet\ttfamily\mathtt - \romanfamily\ttdefault\ttjfam\selectfont} -\newjfontfamily\ttjfam{KozGoPr6N-Regular.otf} - %%%%%%%% logo \usepackage{metalogo} @@ -932,7 +929,7 @@ Okumura), namely, \Pkg{ltjclasses} and \Pkg{ltjsclasses}. 日本語文書を組版するためには,\texttt{article.cls}, \texttt{book.cls}といった 欧文用のクラスファイルではなく,和文用のクラスファイルを用いた方がよい. 現時点では,\Pkg{jclasses}(\pLaTeX の標準クラス)と\Pkg{jsclasses} -(奥村晴彦氏によるクラスファイル)に対応するものとして,\Pkg{ltjclasses}, +(奥村晴彦氏による「\pLaTeXe 新ドキュメントクラス」)に対応するものとして,\Pkg{ltjclasses}, \Pkg{ltjsclasses}がそれぞれ用意されている. % @@ -1114,13 +1111,21 @@ this chapter. For the method, please see Subsection~\ref{ssec-math}. \label{ssec-fontspec} %<*en> To coexist with the \Pkg{fontspec} package, it is needed to load -\Pkg{luatexja-fontspec} package in the preamble. This additional -package automatically loads \Pkg{luatexja} and \Pkg{fontspec} +\Pkg{luatexja-fontspec} package in the preamble, as follows: +\begin{quote} +\ttfamily \textbackslash usepackage[]\{luatexja-fontspec\} +\end{quote} +This \Pkg{luatexja-fontspec} package +automatically loads \Pkg{luatexja} and \Pkg{fontspec} package, if needed. % %<*ja> -\Pkg{fontspec}パッケージと同様の機能を和文フォントに対しても用いるためには, -\Pkg{luatexja-fontspec}パッケージをプリアンブルで読み込む必要がある.このパッケージ +\Pkg{fontspec}パッケージと同様の機能を和文フォントに対しても用いる場合, +\Pkg{luatexja-fontspec}パッケージを読み込む: +\begin{quote} +\ttfamily \textbackslash usepackage[]\{luatexja-fontspec\} +\end{quote} +このパッケージ は必要ならば自動で\Pkg{luatexja}パッケージと\Pkg{fontspec}パッケージを読み込む. % @@ -1132,20 +1137,21 @@ counterparts of original commands in the \Pkg{fontspec} package: \Pkg{luatexja-fontspec}パッケージでは,以下の7つのコマンドを\Pkg{fontspec} パッケージの元のコマンドに対応するものとして定義している: % - %<*en> \begin{center}\small \begin{tabular}{ccccc} \toprule Japanese fonts -&\verb+\jfontspec+&\verb+\setmainjfont+&\verb+\setsansjfont+&\verb+\newjfontfamily+\\ +&\verb+\jfontspec+&\verb+\setmainjfont+&\verb+\setsansjfont+&\verb+\setmonojfont+$^*$\\ alphabetic fonts -&\verb+\fontspec+&\verb+\setmainfont+&\verb+\setsansfont+&\verb+\newfontfamily+\\ +&\verb+\fontspec+&\verb+\setmainfont+&\verb+\setsansfont+&\verb+\setmonofont+\\ \midrule Japanese fonts -&\verb+\newjfontface+&\verb+\defaultjfontfeatures+&\verb+\addjfontfeatures+\\ +&\verb+\newjfontfamily+&\verb+\newjfontface+ +&\verb+\defaultjfontfeatures+&\verb+\addjfontfeatures+\\ alphabetic fonts -&\verb+\newfontface+&\verb+\defaultfontfeatures+&\verb+\addfontfeatures+\\ +&\verb+\newfontfamily+&\verb+\newfontface+ +&\verb+\defaultfontfeatures+&\verb+\addfontfeatures+\\ \bottomrule \end{tabular} \end{center} @@ -1172,31 +1178,54 @@ alphabetic fonts \end{tabular} \end{center} % -\begin{LTXexample}[width=0.4\textwidth] -\fontspec[Numbers=OldStyle]{LMSans10-Regular} -\jfontspec[CJKShape=NLC]{KozMinPr6N-Regular} -JIS~X~0213:2004→辻 +%<*en> +The package option of \Pkg{luatexja-fontspec} are the followings: +\begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}\advance\leftmargin1\zw} + \item[match] If this option is specified, usual family-changing commands such as +\verb+\rmfamily+,~\verb+\textrm+, \verb+\sffamily+,~\dots\ also change Japanese font family. -\jfontspec[CJKShape=JIS1990]{KozMinPr6N-Regular} -JIS~X~0208:1990→辻 -\end{LTXexample} +Note that \emph{\texttt{\textup{\textbackslash setmonojfont}} is defined +if and only if this \texttt{\textup{match}} option is specified}. -%<*en> -Note that there is no command named \verb+\setmonojfont+, since it is -popular for Japanese fonts that nearly all Japanese glyphs have same + \item[pass=] +Specify options which will be passed to the \Pkg{fontspec} package. +\end{list} +The reason that \verb+\setmonojfont+ is not defined by default is that +it is popular for Japanese fonts that nearly all Japanese glyphs have same widths. Also note that kerning information in a font is not used -(that is, \texttt{kern} feature is set off) by default in these seven commands. +(that is, \texttt{kern} feature is set off) by default in these seven (or~eight) commands. This is because of the compatibility with previous versions of \LuaTeX-ja (see \ref{para-kern}). % %<*ja> -和文フォントについては全ての和文文字のグリフがほぼ等幅であるのが普通であるため, -\verb+\setmonojfont+ コマンドは存在しないことに注意.また,これらの和文用の7つのコマ -ンドではフォント内のペアカーニング情報は標準では使用されない, +\Pkg{luatexja-fontspec} パッケージのオプションは以下の通りである: +\begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}\advance\leftmargin1\zw} + \item[match] このオプションが指定されると,「\pLaTeXe 新ドキュメントクラス」のように\ +\verb+\rmfamily+, \verb+\textrm{...}+, \verb+\sffamily+ 等が +欧文フォントだけでなく和文フォントも変更するようになる. + +\emph{なお,{\tt \textbackslash setmonojfont} はこの \texttt{match} オプションが +指定された時のみ定義される.}この命令は標準の「タイプライタ体に対応する和文フォント」を指定する. + + \item[pass=] +\Pkg{fontspec} パッケージに渡すオプション を指定する. +\end{list} +標準で \verb+\setmonojfont+ コマンドが定義されないのは, +和文フォントではほぼ全ての和文文字のグリフが等幅であるのが伝統的であったことによる. +また,これらの和文用のコマンドではフォント内のペアカーニング情報は標準では使用されない, 言い換えれば \texttt{kern} featureは標準では無効化となっている. これは以前のバージョンの\LuaTeX-jaとの互換性のためである(\ref{para-kern}節を参照). % +\begin{LTXexample}[width=0.4\textwidth] +\fontspec[Numbers=OldStyle]{LMSans10-Regular} +\jfontspec[CJKShape=NLC]{KozMinPr6N-Regular} +JIS~X~0213:2004→辻 + +\jfontspec[CJKShape=JIS1990]{KozMinPr6N-Regular} +JIS~X~0208:1990→辻 +\end{LTXexample} + %\subsection{Presets} %\subsection{プリセット設定} \label{ssec-preset} @@ -4620,6 +4649,7 @@ by \verb+\input+. \verb+\input+ で読み込み可能である. % \subsection{\texttt{luatexja-fontspec.sty}} +\label{ssec-fontspec2} %<*en> As described in Subsection~\ref{ssec-fontspec}, this optional package provides the counterparts for several commands defined in the diff --git a/src/addons/luatexja-fontspec.sty b/src/addons/luatexja-fontspec.sty index 9fa1ec4..4623675 100644 --- a/src/addons/luatexja-fontspec.sty +++ b/src/addons/luatexja-fontspec.sty @@ -3,11 +3,41 @@ % \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{luatexja-fontspec}[2014/01/23 fontspec support of LuaTeX-ja] - -\RequirePackage{fontspec,luatexja} +\ProvidesPackage{luatexja-fontspec}[2014/03/25 fontspec support of LuaTeX-ja] +\RequirePackage{l3keys2e,luatexja} \ExplSyntaxOn +\bool_new:N \ltj_fontspec_match +\cs_set:Nn \ltj_fontspec_pass_opts: {} +\keys_define:nn { luatexja-fontspec } + { + match .bool_set:N = \ltj_fontspec_match, + match .default:n = true, + pass .code:n = \cs_set:Nn \ltj_fontspec_pass_opts: {#1}, + } +\ProcessKeysOptions { luatexja-fontspec } +\RequirePackage[\ltj_fontspec_pass_opts:]{fontspec} + +%%%%%%%% Change Japanese font family by \rmfamily or not +\bool_if:NTF \ltj_fontspec_match +{ + \renewcommand\jttdefault{\gtdefault} + \DeclareRobustCommand\rmfamily + {\not@math@alphabet\rmfamily\mathrm + \romanfamily\rmdefault\kanjifamily\mcdefault\selectfont} + \DeclareRobustCommand\sffamily + {\not@math@alphabet\sffamily\mathsf + \romanfamily\sfdefault\kanjifamily\gtdefault\selectfont} + \DeclareRobustCommand\ttfamily + {\not@math@alphabet\ttfamily\mathtt + \romanfamily\ttdefault\kanjifamily\jttdefault\selectfont} + \DeclareDocumentCommand \setmonojfont { O{} m } { + \ltj_fontspec_set_family:Nnn \jttdefault {#1}{#2} + \normalfont + } +}{ +} + %%%%%%%% Messages \cs_new:Npn \ltj_fontspec_warning:n { \msg_warning:nn {ltj-fontspec} } diff --git a/src/ltjsarticle.cls b/src/ltjsarticle.cls index 518f152..52e48c3 100644 --- a/src/ltjsarticle.cls +++ b/src/ltjsarticle.cls @@ -332,6 +332,7 @@ %% \DeclareFontShape{JT3}{gt}{m}{sl}{<->ssub*gt/m/n}{} %% \DeclareFontShape{JT3}{mc}{bx}{it}{<->ssub*gt/m/n}{} %% \DeclareFontShape{JT3}{mc}{bx}{sl}{<->ssub*gt/m/n}{} +\renewcommand\jttdefault{\gtdefault} \DeclareRobustCommand\rmfamily {\not@math@alphabet\rmfamily\mathrm \romanfamily\rmdefault\kanjifamily\mcdefault\selectfont} @@ -340,7 +341,7 @@ \romanfamily\sfdefault\kanjifamily\gtdefault\selectfont} \DeclareRobustCommand\ttfamily {\not@math@alphabet\ttfamily\mathtt - \romanfamily\ttdefault\kanjifamily\gtdefault\selectfont} + \romanfamily\ttdefault\kanjifamily\jttdefault\selectfont} %% \AtBeginDocument{% \reDeclareMathAlphabet{\mathrm}{\mathrm}{\mathmc} diff --git a/src/ltjsbook.cls b/src/ltjsbook.cls index 9910bae..2cbdc98 100644 --- a/src/ltjsbook.cls +++ b/src/ltjsbook.cls @@ -339,6 +339,7 @@ %% \DeclareFontShape{JT3}{gt}{m}{sl}{<->ssub*gt/m/n}{} %% \DeclareFontShape{JT3}{mc}{bx}{it}{<->ssub*gt/m/n}{} %% \DeclareFontShape{JT3}{mc}{bx}{sl}{<->ssub*gt/m/n}{} +\renewcommand\jttdefault{\gtdefault} \DeclareRobustCommand\rmfamily {\not@math@alphabet\rmfamily\mathrm \romanfamily\rmdefault\kanjifamily\mcdefault\selectfont} @@ -347,7 +348,7 @@ \romanfamily\sfdefault\kanjifamily\gtdefault\selectfont} \DeclareRobustCommand\ttfamily {\not@math@alphabet\ttfamily\mathtt - \romanfamily\ttdefault\kanjifamily\gtdefault\selectfont} + \romanfamily\ttdefault\kanjifamily\jttdefault\selectfont} %% \AtBeginDocument{% \reDeclareMathAlphabet{\mathrm}{\mathrm}{\mathmc} diff --git a/src/ltjsclasses.dtx b/src/ltjsclasses.dtx index f8acc83..b436bed 100644 --- a/src/ltjsclasses.dtx +++ b/src/ltjsclasses.dtx @@ -130,7 +130,7 @@ % これがあると |grfext.sty| を読み込んだ際にエラーを引き起こすので削除しました。 % \end{itemize} % -% [2014-02-07] jsclasses 2014-02-07 ベースにしました. +% [2014-02-07 LTJ] jsclasses 2014-02-07 ベースにしました. % % \StopEventually{} % @@ -797,6 +797,10 @@ % 和文でイタリック体,斜体,サンセリフ体, % タイプライタ体の代わりにゴシック体を使うことにします。 % +% [2014-03-25 LTJ] タイプライタ体に合わせるファミリを |\jttdefault| とし, +% 通常のゴシック体と別にできるようにしました.|\jttdefault| は,標準で +% |\gtdefault| と定義しています. +% % [2003-03-16] イタリック体,斜体について,和文でゴシックを当てていましたが, % 数学の定理環境などで多量のイタリック体を使うことがあり,ゴシックに % すると黒々となってしまうという弊害がありました。 @@ -827,6 +831,7 @@ %% \DeclareFontShape{JT3}{gt}{m}{sl}{<->ssub*gt/m/n}{} %% \DeclareFontShape{JT3}{mc}{bx}{it}{<->ssub*gt/m/n}{} %% \DeclareFontShape{JT3}{mc}{bx}{sl}{<->ssub*gt/m/n}{} +\renewcommand\jttdefault{\gtdefault} \DeclareRobustCommand\rmfamily {\not@math@alphabet\rmfamily\mathrm \romanfamily\rmdefault\kanjifamily\mcdefault\selectfont} @@ -835,7 +840,7 @@ \romanfamily\sfdefault\kanjifamily\gtdefault\selectfont} \DeclareRobustCommand\ttfamily {\not@math@alphabet\ttfamily\mathtt - \romanfamily\ttdefault\kanjifamily\gtdefault\selectfont} + \romanfamily\ttdefault\kanjifamily\jttdefault\selectfont} % \end{macrocode} %% % Lua\TeX-jaでは和文組版に伴うグルーはノードベースで挿入するようになり,また @@ -1589,7 +1594,7 @@ % はトンボの内側に |1in| のスペース(|1truein| ではなく)を挿入するので, % 場合分けしています。 % -% [2011-10-03] Lua\TeX{} (pdf\TeX?) では |1truein| ではなく +% [2011-10-03 LTJ] Lua\TeX{} (pdf\TeX?) では |1truein| ではなく % |1in| になるようです。 % % \begin{macrocode} @@ -1634,7 +1639,7 @@ % [2003-06-26] |\headheight| を |\topskip| に直しました。 % 以前はこの二つは値が同じであったので,変化はないはずです。 % -% [2011-10-03] ここも |\oddsidemargin| のときと同様に |-\inv@mag in| ではなく +% [2011-10-03 LTJ] ここも |\oddsidemargin| のときと同様に |-\inv@mag in| ではなく % |-1in| にします。 % % \begin{macrocode} @@ -2434,7 +2439,7 @@ % 二つ挿入した |\everyparhook| のうち後者が |\paragraph| 類の後で2回実行され, % それ以降は前者が実行されます。 % -% [2011-10-05] Lua\TeX-jaでは |\everyparhook| は不要なので削除。 +% [2011-10-05 LTJ] Lua\TeX-jaでは |\everyparhook| は不要なので削除。 % % \begin{macrocode} \def\@xsect#1{% @@ -4711,7 +4716,7 @@ % % 段落頭のかぎかっこなどを見かけ1字半下げから全角1字下げに直します。 % -% [2012-04-24] LuaTeX-jaではJFMに段落開始時の括弧類の字下げ幅をコントロール +% [2012-04-24 LTJ] LuaTeX-jaではJFMに段落開始時の括弧類の字下げ幅をコントロール % する機能がありますが,|\item| 直後ではラベル用のボックスが段落先頭になる % ため,うまく働きませんでした.形を変えて復活させます. % diff --git a/src/ltjskiyou.cls b/src/ltjskiyou.cls index c33b141..4aa492f 100644 --- a/src/ltjskiyou.cls +++ b/src/ltjskiyou.cls @@ -334,6 +334,7 @@ %% \DeclareFontShape{JT3}{gt}{m}{sl}{<->ssub*gt/m/n}{} %% \DeclareFontShape{JT3}{mc}{bx}{it}{<->ssub*gt/m/n}{} %% \DeclareFontShape{JT3}{mc}{bx}{sl}{<->ssub*gt/m/n}{} +\renewcommand\jttdefault{\gtdefault} \DeclareRobustCommand\rmfamily {\not@math@alphabet\rmfamily\mathrm \romanfamily\rmdefault\kanjifamily\mcdefault\selectfont} @@ -342,7 +343,7 @@ \romanfamily\sfdefault\kanjifamily\gtdefault\selectfont} \DeclareRobustCommand\ttfamily {\not@math@alphabet\ttfamily\mathtt - \romanfamily\ttdefault\kanjifamily\gtdefault\selectfont} + \romanfamily\ttdefault\kanjifamily\jttdefault\selectfont} %% \AtBeginDocument{% \reDeclareMathAlphabet{\mathrm}{\mathrm}{\mathmc} diff --git a/src/ltjspf.cls b/src/ltjspf.cls index 251d916..a13ca73 100644 --- a/src/ltjspf.cls +++ b/src/ltjspf.cls @@ -332,6 +332,7 @@ %% \DeclareFontShape{JT3}{gt}{m}{sl}{<->ssub*gt/m/n}{} %% \DeclareFontShape{JT3}{mc}{bx}{it}{<->ssub*gt/m/n}{} %% \DeclareFontShape{JT3}{mc}{bx}{sl}{<->ssub*gt/m/n}{} +\renewcommand\jttdefault{\gtdefault} \DeclareRobustCommand\rmfamily {\not@math@alphabet\rmfamily\mathrm \romanfamily\rmdefault\kanjifamily\mcdefault\selectfont} @@ -340,7 +341,7 @@ \romanfamily\sfdefault\kanjifamily\gtdefault\selectfont} \DeclareRobustCommand\ttfamily {\not@math@alphabet\ttfamily\mathtt - \romanfamily\ttdefault\kanjifamily\gtdefault\selectfont} + \romanfamily\ttdefault\kanjifamily\jttdefault\selectfont} %% \AtBeginDocument{% \reDeclareMathAlphabet{\mathrm}{\mathrm}{\mathmc} diff --git a/src/patches/lltjdefs.sty b/src/patches/lltjdefs.sty index 9d04afe..9cd7643 100644 --- a/src/patches/lltjdefs.sty +++ b/src/patches/lltjdefs.sty @@ -17,6 +17,7 @@ \newcommand\mcdefault{mc} \newcommand\gtdefault{gt} +\newcommand\jttdefault{\gtdefault} \newcommand\kanjiencodingdefault{JY3} \newcommand\kanjifamilydefault{\mcdefault} \newcommand\kanjiseriesdefault{\mddefault} @@ -30,7 +31,6 @@ \DeclareFontShape{JY3}{mc}{bx}{n}{<-> ssub*gt/m/n}{} \DeclareFontShape{JY3}{gt}{bx}{n}{<-> ssub*gt/m/n}{} -%fontencoding{JT3}\selectfont \kanjiencoding{JY3}\selectfont\adjustbaseline \DeclareTextFontCommand{\textmc}{\mcfamily}