summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-05-05 22:06:34 +0000
committerKarl Berry <karl@freefriends.org>2014-05-05 22:06:34 +0000
commitc282c4699b5c50d0d050bb1d7f5187a47eebc94e (patch)
tree247a127065821c008bc8fee600c1e130e2d0ecd5
parentc2e26b130cd3c16ddba1e50bd65f8ff334ba8acc (diff)
luatexja (4may14)
git-svn-id: svn://tug.org/texlive/trunk@33863 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/luatex/luatexja/README8
-rw-r--r--Master/texmf-dist/doc/luatex/luatexja/jfm-ujisc33.lua135
-rw-r--r--Master/texmf-dist/doc/luatex/luatexja/luatexja-en.pdfbin340132 -> 362167 bytes
-rw-r--r--Master/texmf-dist/doc/luatex/luatexja/luatexja-ja.pdfbin706092 -> 727474 bytes
-rw-r--r--Master/texmf-dist/doc/luatex/luatexja/luatexja-ruby.pdfbin0 -> 324385 bytes
-rw-r--r--Master/texmf-dist/doc/luatex/luatexja/luatexja-ruby.tex806
-rw-r--r--Master/texmf-dist/doc/luatex/luatexja/luatexja.dtx291
-rw-r--r--Master/texmf-dist/source/luatex/luatexja/ltjsclasses.dtx21
-rw-r--r--Master/texmf-dist/tex/luatex/luatexja/addons/luatexja-fontspec.sty178
-rw-r--r--Master/texmf-dist/tex/luatex/luatexja/addons/luatexja-ruby.sty207
-rw-r--r--Master/texmf-dist/tex/luatex/luatexja/ltj-base.lua8
-rw-r--r--Master/texmf-dist/tex/luatex/luatexja/ltj-jfmglue.lua7
-rw-r--r--Master/texmf-dist/tex/luatex/luatexja/ltj-ruby.lua774
-rw-r--r--Master/texmf-dist/tex/luatex/luatexja/ltjsarticle.cls5
-rw-r--r--Master/texmf-dist/tex/luatex/luatexja/ltjsbook.cls5
-rw-r--r--Master/texmf-dist/tex/luatex/luatexja/ltjskiyou.cls5
-rw-r--r--Master/texmf-dist/tex/luatex/luatexja/ltjspf.cls5
-rw-r--r--Master/texmf-dist/tex/luatex/luatexja/luatexja-core.sty4
-rw-r--r--Master/texmf-dist/tex/luatex/luatexja/patches/lltjdefs.sty2
-rw-r--r--Master/texmf-dist/tex/luatex/luatexja/patches/lltjfont.sty9
20 files changed, 2342 insertions, 128 deletions
diff --git a/Master/texmf-dist/doc/luatex/luatexja/README b/Master/texmf-dist/doc/luatex/luatexja/README
index 8cd4cbe045a..3668aeb2158 100644
--- a/Master/texmf-dist/doc/luatex/luatexja/README
+++ b/Master/texmf-dist/doc/luatex/luatexja/README
@@ -1,4 +1,4 @@
-The LuaTeX-ja Package 20140324.0
+The LuaTeX-ja Package 20140504.0
--------------------------------
Copyright (c) 2011--2014 The LuaTeX-ja project
License: modified BSD (see COPYING)
@@ -33,9 +33,9 @@ Installation
2. If you must/want to install manually:
a. Download the source archive from CTAN,
- or tagged as 20140324.0 in the Git repository by
+ or tagged as 20140504.0 in the Git repository by
<http://git.sourceforge.jp/view?p=luatex-ja/luatexja.git
- ;a=snapshot;h=refs/tags/20140324.0;sf=tgz>
+ ;a=snapshot;h=refs/tags/20140504.0;sf=tgz>
b1. Extract the archive and process following three files by LuaLaTeX
to generate classes for Japanese typesetting:
@@ -80,4 +80,4 @@ Notes
* src/*.{ins.dtx} and src/ltj-kinsoku_make.tex are not needed in regular use.
-Last commit date: Mon Mar 24 09:20:06 2014 +0900
+Last commit date: Sun May 4 06:31:45 2014 +0900
diff --git a/Master/texmf-dist/doc/luatex/luatexja/jfm-ujisc33.lua b/Master/texmf-dist/doc/luatex/luatexja/jfm-ujisc33.lua
new file mode 100644
index 00000000000..7879f58c3b7
--- /dev/null
+++ b/Master/texmf-dist/doc/luatex/luatexja/jfm-ujisc33.lua
@@ -0,0 +1,135 @@
+luatexja.jfont.define_jfm {
+ dir = 'yoko',
+ zw = 1.0, zh = 1.0,
+
+ [0] = {
+ align = 'left', left = 0.0, down = 0.0,
+ width = 1.0*0.67, height = 0.88, depth = 0.12, italic=0.0,
+ glue = {
+ [1] = { 0.5*0.67 , 0.0, 0.5 },
+ [3] = { 0.25*0.67, 0.0, 0.25 }
+ }
+ },
+
+ [1] = { -- 開き括弧類
+ chars = {
+ '‘', '“', '〈', '《', '「', '『', '【', '〔', '〖',
+ '〘', '〝', '(', '[', '{', '⦅'
+ },
+ align = 'right', left = 0.0, down = 0.0,
+ width = 0.5*0.67, height = 0.88, depth = 0.12, italic=0.0,
+ glue = {
+ [3] = { 0.25*0.67, 0.0, 0.25 }
+ }
+ },
+
+ [2] = { -- 閉じ括弧類
+ chars = {
+ '’', '”', '、', '〉', '》', '」', '』', '】', '〕',
+ '〗', '〙', '〟', ')', ',', ']', '}', '⦆'
+ },
+ align = 'left', left = 0.0, down = 0.0,
+ width = 0.5*0.67, height = 0.88, depth = 0.12, italic=0.0,
+ glue = {
+ [0] = { 0.5*0.67 , 0.0, 0.5 },
+ [1] = { 0.5*0.67 , 0.0, 0.5 },
+ [3] = { 0.25*0.67, 0.0, 0.25 },
+ [5] = { 0.5*0.67 , 0.0, 0.5 },
+ [6] = { 0.5*0.67 , 0.0, 0.5 },
+ [7] = { 0.5*0.67 , 0.0, 0.5 }
+ }
+ },
+
+ [3] = { -- 中点類
+ chars = {'・', ':', ';'},
+ align = 'middle', left = 0.0, down = 0.0,
+ width = 0.5*0.67, height = 0.88, depth = 0.12, italic=0.0,
+ glue = {
+ [0] = { 0.25*0.67, 0.0, 0.25 },
+ [1] = { 0.25*0.67, 0.0, 0.25 },
+ [2] = { 0.25*0.67, 0.0, 0.25 },
+ [3] = { 0.5*0.67 , 0.0, 0.5 },
+ [4] = { 0.25*0.67, 0.0, 0.25 },
+ [5] = { 0.25*0.67, 0.0, 0.25 },
+ [6] = { 0.25*0.67, 0.0, 0.25 },
+ [7] = { 0.25*0.67, 0.0, 0.25 }
+ }
+ },
+
+ [4] = { -- 句点類
+ chars = {'。', '.'},
+ align = 'left', left = 0.0, down = 0.0,
+ width = 0.5*0.67, height = 0.88, depth = 0.12, italic=0.0,
+ glue = {
+ [0] = { 0.5*0.67 , 0.0, 0.0 },
+ [1] = { 0.5*0.67 , 0.0, 0.0 },
+ [3] = { 0.75*0.67, 0.0, 0.25 },
+ [5] = { 0.5*0.67 , 0.0, 0.0 },
+ [6] = { 0.5*0.67 , 0.0, 0.0 },
+ [7] = { 0.5*0.67 , 0.0, 0.0 }
+ }
+ },
+
+ [5] = { -- ダッシュ
+ chars = { '―', '‥', '…' },
+ align = 'left', left = 0.0, down = 0.0,
+ width = 1.0*0.67, height = 0.88, depth = 0.12, italic=0.0,
+ glue = {
+ [1] = { 0.5*0.67 , 0.0, 0.5 },
+ [3] = { 0.25*0.67, 0.0, 0.25 }
+ },
+ kern = {
+ [5] = 0.0
+ }
+ },
+
+ [6] = { -- 感嘆符・疑問符
+ chars = { '?', '!' },
+ align = 'left', left = 0.0, down = 0.0,
+ width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
+ glue = {
+ [0] = { 0.5*0.67 , 0.0, 0.5 },
+ [1] = { 0.5*0.67 , 0.0, 0.5 },
+ [3] = { 0.25*0.67, 0.0, 0.25 },
+ [7] = { 0.5*0.67 , 0.0, 0.5 },
+ },
+ kern = {
+ [5] = 0.0
+ }
+ },
+
+ [7] = { -- 半角カナ
+ chars = {
+ '。', '「', '」', '、', '・', 'ヲ', 'ァ', 'ィ', 'ゥ',
+ 'ェ', 'ォ', 'ャ', 'ュ', 'ョ', 'ッ', 'ー', 'ア', 'イ',
+ 'ウ', 'エ', 'オ', 'カ', 'キ', 'ク', 'ケ', 'コ', 'サ',
+ 'シ', 'ス', 'セ', 'ソ', 'タ', 'チ', 'ツ', 'テ', 'ト',
+ 'ナ', 'ニ', 'ヌ', 'ネ', 'ノ', 'ハ', 'ヒ', 'フ', 'ヘ',
+ 'ホ', 'マ', 'ミ', 'ム', 'メ', 'モ', 'ヤ', 'ユ', 'ヨ',
+ 'ラ', 'リ', 'ル', 'レ', 'ロ', 'ワ', 'ン', '゙', '゚',
+ "AJ1-516", "AJ1-517", "AJ1-518", "AJ1-519", "AJ1-520", "AJ1-521", "AJ1-522",
+ "AJ1-523", "AJ1-524", "AJ1-525", "AJ1-526", "AJ1-527", "AJ1-528", "AJ1-529",
+ "AJ1-530", "AJ1-531", "AJ1-532", "AJ1-533", "AJ1-534", "AJ1-535", "AJ1-536",
+ "AJ1-537", "AJ1-538", "AJ1-539", "AJ1-540", "AJ1-541", "AJ1-542", "AJ1-543",
+ "AJ1-544", "AJ1-545", "AJ1-546", "AJ1-547", "AJ1-548", "AJ1-549", "AJ1-550",
+ "AJ1-551", "AJ1-552", "AJ1-553", "AJ1-554", "AJ1-555", "AJ1-556", "AJ1-557",
+ "AJ1-558", "AJ1-559", "AJ1-560", "AJ1-561", "AJ1-562", "AJ1-563", "AJ1-564",
+ "AJ1-565", "AJ1-566", "AJ1-567", "AJ1-568", "AJ1-569", "AJ1-570", "AJ1-571",
+ "AJ1-572", "AJ1-573", "AJ1-574", "AJ1-575", "AJ1-576", "AJ1-577", "AJ1-578",
+ "AJ1-579", "AJ1-580", "AJ1-581", "AJ1-582", "AJ1-583", "AJ1-584", "AJ1-585",
+ "AJ1-586", "AJ1-587", "AJ1-588", "AJ1-589", "AJ1-590", "AJ1-591", "AJ1-592",
+ "AJ1-593", "AJ1-594", "AJ1-595", "AJ1-596", "AJ1-597", "AJ1-598",
+ },
+ align = 'left', left = 0.0, down = 0.0,
+ width = 0.5*0.67, height = 0.88, depth = 0.12, italic=0.0,
+ glue = {
+ [1] = { 0.5*0.67 , 0.0, 0.5 },
+ [3] = { 0.25*0.67, 0.0, 0.25 }
+ }
+ },
+
+ [99] = { -- box末尾
+ chars = {'boxbdd', 'parbdd'},
+ },
+
+} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/luatex/luatexja/luatexja-en.pdf b/Master/texmf-dist/doc/luatex/luatexja/luatexja-en.pdf
index 3f87190f0ae..4c398d686a5 100644
--- a/Master/texmf-dist/doc/luatex/luatexja/luatexja-en.pdf
+++ b/Master/texmf-dist/doc/luatex/luatexja/luatexja-en.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/luatex/luatexja/luatexja-ja.pdf b/Master/texmf-dist/doc/luatex/luatexja/luatexja-ja.pdf
index 938ebdff1c6..187b498f942 100644
--- a/Master/texmf-dist/doc/luatex/luatexja/luatexja-ja.pdf
+++ b/Master/texmf-dist/doc/luatex/luatexja/luatexja-ja.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/luatex/luatexja/luatexja-ruby.pdf b/Master/texmf-dist/doc/luatex/luatexja/luatexja-ruby.pdf
new file mode 100644
index 00000000000..aee015b9256
--- /dev/null
+++ b/Master/texmf-dist/doc/luatex/luatexja/luatexja-ruby.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/luatex/luatexja/luatexja-ruby.tex b/Master/texmf-dist/doc/luatex/luatexja/luatexja-ruby.tex
new file mode 100644
index 00000000000..86167b031c4
--- /dev/null
+++ b/Master/texmf-dist/doc/luatex/luatexja/luatexja-ruby.tex
@@ -0,0 +1,806 @@
+%#! luajitlatex
+%%% a test of ruby.
+\documentclass[a4paper,10pt]{ltjsarticle}
+\usepackage{luatexja-otf,amsmath}
+\usepackage[match]{luatexja-fontspec}
+\usepackage[kozuka-pr6n]{luatexja-preset}\normalsize
+\def\emph#1{\textbf{\textgt{#1}}}
+\def\headfont{\normalfont\bfseries\gtfamily}
+\setmonojfont{KozGoPr6N-Regular.otf}
+
+\usepackage[textwidth=45\zw, lines=45, footskip=6mm]{geometry}
+\advance\leftmargini-1\zw\advance\leftmarginii-1\zw
+
+
+\usepackage{luatexja-ruby,showexpl,booktabs}
+\lstset{
+ preset=\normalsize, basicstyle=\small\ttfamily, basewidth=0.5em,
+ explpreset={numberstyle=\tiny, numbers=left, numbersep=1em, columns=fixed},
+}
+\makeatletter\let\SX@Info=\relax\makeatother
+\fboxsep=0mm
+
+\usepackage{hyperref,bookmark,xcolor}
+\hypersetup{%
+ unicode,
+ colorlinks,
+ allbordercolors=1 1 1,
+ allcolors=blue,
+ pdftitle={luatexja-ruby.sty}
+}
+
+\def\Node#1#2{\,\vcenter{\hbox{\fboxsep=1pt\fbox{\vbox{\small\halign{\hfil##\hfil\cr
+ #1\mathstrut\cr\noalign{\hrule height.4pt}\strut#2\cr}}}}\,}}
+\def\LuaTeX{Lua\TeX}
+
+% 三分ルビ用
+\DeclareFontShape{JY3}{mc}{mc}{n}{<-> [0.92487]
+ KozMinPr6N-Regular:extend=0.67;jfm=ujisc33}{}
+
+\title{\texttt{luatexja-ruby.sty}}
+\begin{document}
+\catcode`\<=13
+\def<#1>{{\normalfont\rm\itshape$\langle$#1\/$\rangle$}}
+%\fontsize{13.19873}{15}\selectfont%
+
+\maketitle
+
+\begin{abstract}
+\texttt{luatexja-ruby.sty} は,\LuaTeX-jaの機能を利用してルビの組版処理を行う追加パッケージである.
+\LuaTeX, \LuaTeX-jaの内部処理に割り込むことにより,熟語ルビ中の行分割や,
+行頭形・行中形・行末形の自動検出,また進入許容量の自動設定などを可能とした.
+\end{abstract}
+
+\tableofcontents
+
+\newpage
+\section{\ltjruby{利|用|方|法}{り|よう|ほう|ほう}}
+パッケージ読み込みは,\verb+\usepackage{luatexja-ruby}+ で良く,
+必要ならば自動的に\LuaTeX-ja本体を読み込む.
+plain \LuaTeX でのロードはまだサポートしておらず,
+\LaTeXe のみサポートしている.
+
+\subsection{\ltjruby{用|語}{よう|ご}}
+「進入(intrusion)」「突出(protrusion)」という用語は,
+\href{http://zrbabbler.sp.land.to/pxrubrica.html}{\texttt{pxrubrica}\ パッケージ}%
+での用法に準ずる.
+
+\begin{quotation}
+進入あり:と\ltjruby{暁}{あかつき}の
+
+進入なし:{\setkeys[ltj]{ruby}{mode=0}と\ltjruby{暁}{あかつき}の}
+
+突出あり:{\setkeys[ltj]{ruby}{stretch={1}{2}{1}}\ltjruby{聴衆}{ちようしゆう}}
+
+突出なし:{\setkeys[ltj]{ruby}{stretch={0}{2}{0}}\ltjruby{聴衆}{ちようしゆう}}
+\end{quotation}
+
+\subsection{\ruby{命|令}{めい|れい}}
+\paragraph{\tt\textbackslash ltjruby}
+ルビ出力用命令の本体.\verb+\ruby+ という別名を定義している.
+\begin{quote}
+\tt \textbackslash ltjruby[<option>]\{親|文|字\}\{おや|も|じ\}
+\end{quote}
+のように使用する.
+第2・第3引数内の「\verb+|+」はグループの区切りを表す.詳細は\ref{ssec:grp}\nobreak 小節を参照.
+
+<option>には以下の内容をkey-valueリストで指定可能である:
+\begin{description}
+\def\makelabel#1{\tt#1}
+\item[pre=<real>] 前進入許容量をルビ全角単位で指定.
+負の長さを指定した場合は,ルビの状況や直前の文字に応じた自動指定を意味する.
+既定値は負(つまり,自動指定).
+
+\item[post=<real>] 同様に,後進入許容量を指定する.既定値は負(自動指定).
+
+\item[mode] 進入処理のモードを表すbit vector.下位2\,bitは,\texttt{pre}や
+\texttt{post}が負である場合にしか効力を発揮しない.既定値は$(0001)_2 = 1$.
+\begin{description}
+ \item[bit 0] 進入を無効にするならば0,有効にするならば1.
+ \item[bit 1] 前進入許容量$B$と後進入許容量$A$が異なった場合,
+そのまま処理する場合は0,小さい方に揃えるならば1.
+ \item[bit 2--3] ルビ文字の突出量$x$から実際の前進入量$b$,後進入量$a$の計算方法を指定する.
+親文字の文字数が$k+1$,親文字の前に入る空白量・間の空白量・後ろの空白量の比が$p:q:r$のとき,
+\begin{description}
+ \item[00] $b=\min\{B, xp/[p+kq+r]\}$, \ $a=\min\{A, xr/[p+kq+r]\}$
+ \item[01] $b=\min(B, x)$, \ $a=\min[A, \max(x-b,0)]$
+ \item[10] $a=\min(A, x)$, \ $b=\min[B, \max(x-a,0)]$
+ \item[11] $M=\min(B,A)$とおく.もし$x\le 2M$ならば$b=a=x/2$.そうでなければ
+\[
+ b=\min\left(B, M + \frac{(x-2M)p}{p+kp+r}\right),\qquad
+ a=\min\left(A, M + \frac{(x-2M)r}{p+kp+r}\right)
+\]
+\end{description}
+
+組み方の具体例を実際に示す.例示のため,平仮名にはルビが1字まで,「立」にはルビを
+0.5字分までかけてよいことにしている.
+\begin{description}
+\item[00]{\setkeys[ltj]{ruby}{mode=1}%
+\ltjsetparameter{rubypreintrusion={`立,0.5}, rubypostintrusion={`立,0.5}}%
+は\ltjruby{美}{うつく}しい
+ \quad は\ltjruby{聴衆}{ちようしゆう}と\quad
+は\ltjruby{暁}{あかつき}立\quad
+は\ltjruby{聴衆}{ちようしゆう}立\par}
+\item[01]{\setkeys[ltj]{ruby}{mode=5}%
+\ltjsetparameter{rubypreintrusion={`立,0.5}, rubypostintrusion={`立,0.5}}%
+は\ltjruby{美}{うつく}しい
+ \quad は\ltjruby{聴衆}{ちようしゆう}と\quad
+は\ltjruby{暁}{あかつき}立\quad
+は\ltjruby{聴衆}{ちようしゆう}立\par}
+\item[10]{\setkeys[ltj]{ruby}{mode=9}%
+\ltjsetparameter{rubypreintrusion={`立,0.5}, rubypostintrusion={`立,0.5}}%
+は\ltjruby{美}{うつく}しい
+ \quad は\ltjruby{聴衆}{ちようしゆう}と\quad
+は\ltjruby{暁}{あかつき}立\quad
+は\ltjruby{聴衆}{ちようしゆう}立\par}
+\item[11]{\setkeys[ltj]{ruby}{mode=13}%
+\ltjsetparameter{rubypreintrusion={`立,0.5}, rubypostintrusion={`立,0.5}}%
+は\ltjruby{美}{うつく}しい\quad
+は\ltjruby{聴衆}{ちようしゆう}と\quad
+は\ltjruby{暁}{あかつき}立\quad
+は\ltjruby{聴衆}{ちようしゆう}立\par}
+\end{description}
+
+\end{description}
+\item[stretchruby=\{<left>\}\{<middle>\}\{<right>\}] 親文字の合計長が
+ルビ文字の合計長より長い時に,ルビ文字の前・間・後に入れる空白の割合であり,
+それぞれ0--7の自然数で指定する.
+既定値は\ \verb+{1}{2}{1}+ である.
+<left>はルビ文字の先頭までの空き量,<middle>はルビ文字間の空き量,<right>はルビ文字の末尾からの
+空き量(の比)を表す.以下が例である.
+\begin{LTXexample}[width=0.3\textwidth, preset=\Large]
+\ltjruby[stretchruby=123,maxmargin=2]%
+ {◯◯◯◯}{◆◆}
+\end{LTXexample}
+\item[stretch=\{<left>\}\{<middle>\}\{<right>\}]
+行中形でルビ文字の方が長い場合,親文字の前・中・後に入れる空白の割合.
+既定値は\ \verb+{1}{2}{1}+ である.それ以外の代表的な値としては,例えば次のようなものがある.
+\begin{description}
+\item[親文字均等割禁止] \verb+{1}{0}{1}+\ など<middle>を0にした値
+\item[前突出禁止] \verb+{0}{1}{1}+
+\item[後突出禁止] \verb+{1}{1}{0}+
+\end{description}
+
+\item[stretchbol=\{<left>\}\{<middle>\}\{<right>\}] 行頭形〜.
+既定値は\ \verb+{0}{1}{1}+ である.
+\item[stretcheol=\{<left>\}\{<middle>\}\{<right>\}] 行末形〜.
+既定値は\ \verb+{1}{1}{0}+ である.
+
+\item[maxmargin=<real>] 親文字の方がルビより長い時に,ルビの先頭と親文字の先頭,及び
+ルビ末尾と親文字の末尾の間に許される最大の空白量.\textbf{親文字全角単位}で指定し,既定値は0.5.
+
+\medskip
+\item[size=<real>] ルビ文字の親文字に対する大きさ.既定値は0.5.
+\item[intergap=<real>] ルビ文字と親文字との空きを親文字全角単位で指定.既定値は0.
+\item[rubysmash=<bool>] ルビの高さを0にするか.既定値は偽.次が例である.
+\begin{LTXexample}[width=0.3\textwidth, preset=\Large]
+\ \vrule width 0pt height 2\zw depth 1\zw
+\frame{\ltjruby[rubysmash=false]{本}{ほん}}\
+\frame{\ltjruby[rubysmash=true]{本}{ほん}}\
+\frame{\ltjruby[rubysmash=false,intergap=0.2]
+ {本}{ほん}}\
+\frame{\ltjruby[rubysmash=true,intergap=0.2]
+ {本}{ほん}}\
+\frame{\ltjruby[rubysmash=false,intergap=-1.5]
+ {本}{ほん}}
+\end{LTXexample}
+
+
+\item[kenten=<command>]各文字につく圏点の出力命令を指定する.既定値は「\verb+\ltjalchar`•+」
+であり,\texttt{U+2022} (Bullet)を\textbf{ALchar}として出力することを指定している.
+
+\item[fontcmd=<command>]ルビ用のフォント切り替え命令を指定する.
+このキーの内容が実行された後に\ \verb+\fontsize...\selectfont+\ が実行されるので,
+このキーの指定では最後に\ \verb+\selectfont+ を加える必要はない.
+
+この \texttt{fontcmd} キーの内容は多くの回数実行される.
+例えば,\texttt{luatexja-fontspec}パッケージを用いてOpenTypeフォントを用いる場合,
+\begin{lstlisting}
+ fontcmd=\addjfontfeatures{Style=Ruby}
+\end{lstlisting}
+のようにしてルビ用字形を用いることが可能だが,現在の実装ではタイプセットに時間がかかるようになる.
+
+
+\end{description}
+
+\medskip
+次の2つは,以上で説明した複数のオプションを一度に設定するためのものである.
+普通はこの2つのうちいずれかを設定するだけで足りるだろう.
+
+\begin{description}
+\def\makelabel#1{\tt#1}
+\item[naka] 以下のオプションを同時に設定する.主に中付きルビを組むときに用いる.
+\begin{verbatim}
+mode=1, stretch={1}{2}{1}, stretchruby={1}{2}{1}
+\end{verbatim}
+\item[kata] 同様に,肩付きルビ用に,次を設定する.
+\begin{verbatim}
+mode=9, stretch={1}{2}{1}, stretchruby={0}{0}{1}
+\end{verbatim}
+\end{description}
+
+\paragraph{\tt\textbackslash ltjsetruby\{<option>\}}
+<option>の既定値を指定する.\texttt{luatexja-ruby} 読み込み時の値は
+各項目の所で既に説明してあるが,次のようになっている.
+\begin{verbatim}
+ pre=-1, post=-1, mode=1,
+ stretchruby={1}{2}{1}, stretch = {1}{2}{1},
+ stretchbol={0}{1}{1}, stretcheol={1}{1}{0},
+ maxmargin=0.5, size=0.5, intergap=0, rubysmash=false,
+ kenten=\ltjalchar`•, fontcmd=\relax
+\end{verbatim}
+
+\paragraph{\texttt{\textbackslash ltjsetparamater} に追加されるキー}
+\begin{description}
+\item[\textsf{\mdseries rubypreintrusion}\tt =\{<chr\_code>, <pre\_int>\}]
+文字<chr\_code> に,その\textbf{直後}のルビによって掛けられるルビ文字列の最大長をルビ全角単位で指定.
+\item[\textsf{\mdseries rubypostintrusion}\tt =\{<chr\_code>, <post\_int>\}]
+文字<chr\_code> に,その\textbf{直前}のルビによって掛けられるルビ文字列の最大長をルビ全角単位で指定.
+\end{description}
+既定値は,\textsf{rubypreintrusion},~\textsf{rubypostintrusion}とも
+以下の文字に対しては1,その他の文字については0である:
+\begin{quote}
+ 平仮名(\texttt{U+3040}--\texttt{U+309F}),カギ括弧「」,読点「,」「、」,中黒「・」
+\end{quote}
+また,ここでは「文字コード$-1$の文字」は,「段落開始の \verb+\parindent+」を表す%
+\footnote{通常の\LuaTeX-jaにおける指定では文中数式境界を表していることに注意.}.
+この「文字」に対する\textsf{rubypreintrusion}の値も1である.
+
+\paragraph{\texttt{\textbackslash ltjkenten}}
+圏点を出力する命令で,\verb+\kenten+ という別名を定義している.
+\begin{quote}
+ \tt \textbackslash ltjkenten[<option>]\{親文字\}
+\end{quote}
+のように使用する.複数文字に圏点をつける場合でも,\verb+\ltjruby+ のように「\texttt{|}」を使って
+文字を区切る\textbf{必要はない}ことに注意してほしい.
+
+圏点として出力される文字は \texttt{kenten} キーによって指定し,
+圏点自身の大きさは(ルビと同様に)\texttt{size} キーで指定する.
+
+\subsection{グループの\ruby{指|定}{し|てい}}
+\label{ssec:grp}
+\begin{quote}
+\tt \textbackslash ltjruby[<option>]\{親|文|字\}\{おや|も|じ\}
+\end{quote}
+のように,\verb+\ltjruby+\ の第2・第3引数内の「\verb+|+」はグループの区切りを表す.
+グループの数は両者で一致しなければならず,
+\verb+\ltjruby{紋章}{もん|しよう}+ のようには\emph{できない}.
+
+1グループのみのルビ(単純グループルビ)はグループルビとして組まれる.そのため,
+もしモノルビを使いたければ,面倒でも
+\begin{LTXexample}[width=0.4\textwidth, preset=\Large]
+の\ltjruby{紋}{もん}\ltjruby{章}{しよう}が
+\end{LTXexample}
+のように,複数回使用すること.
+また,全てのグループにおいて「ルビ文字列の長さは親文字列以下」であれば,
+単純グループルビの並びとして扱われる.すなわち,次の2行は全くの等価となる.
+\begin{verbatim}
+\ltjruby{普|通|車}{ふ|つう|しや}
+\ltjruby{普}{ふ}\ltjruby{通}{つう}\ltjruby{車}{しや}
+\end{verbatim}
+
+\newpage
+複数グループかつ上記の条件を満たさない場合は,
+所謂「可動グループルビ」であり,ルビの前後や各グループの切れ目で行分割が可能となる.
+例えば
+\begin{verbatim}
+…の\ltjruby{表|現|力}{ひよう|げん|りよく}は…
+\end{verbatim}
+という入力からは得られる組版結果は,次のいずれかになる.
+\begin{center}
+ \begin{tabular}{ll}
+ \toprule
+ 改行なし(行中形)&\Large …の\ltjruby{表|現|力}{ひよう|げん|りよく}は…\\
+ 直前で改行&\Large \vrule \ltjruby[stretch=011]{表|現|力}{ひよう|げん|りよく}は…\\
+&\Large …の\ltjruby[stretch=110]{表}{ひよう}
+ \vrule\ltjruby[stretch=011]{現|力}{げん|りよく}は…\\
+&\Large …の\ltjruby[stretch=110]{表|現}{ひよう|げん}
+ \vrule\ltjruby[stretch=011]{力}{りよく}は…\\
+ 直後に改行&\Large …の\ltjruby[stretch=110]{表|現|力}{ひよう|げん|りよく}\vrule\\
+\bottomrule
+ \end{tabular}
+\end{center}
+\begin{itemize}
+ \item これらの行分割によってペナルティは発生しない.
+ \item 上記の例で見られるように,
+2ブロック以上をまとめて組むときは,全体を1つのグループルビのように組版する(JIS~X~4051と同様).
+『日本語組版処理の要件』では,
+附属書Fに「熟語の構成,さらにその熟語の前後にくる文字の種類を考慮して配置する方法」として
+別の方法を解説しているが,こちらの方法は現時点ではサポートしていないので,
+面倒でも手動で \texttt{pre}, \texttt{post} などを使って頑張って欲しい.
+ \item 実装方法の都合により,ルビの直前・直後・途中で2箇所以上の改行が起きる場合,例えば
+\begin{center}
+ \begin{tabular}{lll}
+ \toprule
+ \Large …の\ltjruby[stretch=110]{表}{ひよう}
+ \vrule\ltjruby[stretch=010]{現|力}{げん|りよく}\vrule&
+\Large \vrule\ltjruby[stretch=010]{表|現}{ひよう|げん}
+ \vrule\ltjruby[stretch=011]{力}{りよく}は…&
+\Large \vrule\ltjruby[stretch=010]{表|現|力}{ひよう|げん|りよく}\vrule\\
+\bottomrule
+ \end{tabular}
+\end{center}
+などの組み方は\emph{想定していない}.
+\end{itemize}
+
+\newpage
+
+\section{\ruby{注|意|点}{ちゆう|い|てん}}
+\begin{description}
+\item[ルビ文字のはみ出し]
+「日本語組版処理の要件」の図3.82のように,
+ルビ文字のはみ出しが繋がらないようにする処理について述べる.
+
+例えば,
+\begin{LTXexample}[preset=\Large,width=0.3\textwidth]
+\ltjruby{陵}{りよう}と\ltjruby{陵}{みささぎ}\\
+\ltjruby{陵}{りよう}と\ltjruby[pre=1]{陵}{みささぎ}
+\end{LTXexample}
+において,1行目右側の「\ltjruby{陵}{みささぎ}」のルビが前の「と」にかかる量は次のように決まる:
+\begin{enumerate}
+\item 1回目の実行では,行分割前に「\ltjruby{陵}{りよう}」の後側進入量は前もって知ることはでき
+ ない.なので,「\ltjruby{陵}{りよう}」は行中形で組まれるものとして
+「\ltjruby{陵}{みささぎ}」前側進入許容量は
+\[
+ \underbrace{0.5\,\mathrm{zw}}_{\text{元々の許容量}}
+-\underbrace{0.25\,\mathrm{zw}}_{\text{前のルビの後側進入量(行中形)}}=0.25\,\mathrm{zw}
+\]
+となる.行分割後,「\ltjruby{陵}{りよう}」の実際の後側進入量は
+auxファイルに記述される.
+\item 2回目以降の実行では,auxファイルに保存された「\ltjruby{陵}{りよう}」の後側進入量
+を用いて,「\ltjruby{陵}{みささぎ}」前側進入許容量を次のように計算する:
+\[
+ \underbrace{0.5\,\mathrm{zw}}_{\text{元々の許容量}}
+-\underbrace{0.25\,\mathrm{zw}}_{\text{前のルビの後側進入量 (from aux)}}=0.25\,\mathrm{zw}.
+\]
+\end{enumerate}
+auxファイルに保存する際,各 \verb+\ltjruby+ 命令の呼び出しを識別するキーが必要になるが,
+そのキーとしては単純に「何個目の \verb+\ltjruby+ 命令か」である.
+
+なお,以上の処理は,1行目と2行目を比較すれば分かるように,
+「\ltjruby{陵}{みささぎ}」の\emph{前進入許容量指定(\texttt{pre})が自動}になっている場合のみ
+実施される.
+
+\item[段落末尾のルビ]
+段落がルビで終わった場合,そのルビが行末形で組まれることはない.
+これは,段落の「本当の」末尾には \verb+\penalty10000\parfillskip+ があるためで,
+ルビ処理用に作った最後のグルー(\ref{sec:impl}\nobreak 節の説明では$g_2$)が消去されないことによる.
+
+\verb+\parfillskip+ の長さ(や,場合によっては \verb+\rightskip+)を実測し,
+それによって処理を変えるのも可能だが,そのようなことはしなかった.
+段落がルビで終わることは普通ない(最低でも句点が続くだろう)と思うからである.
+
+
+
+\item[段落先頭のルビ]
+同様に,段落先頭のルビは行頭形にはならない.
+\texttt{pre}が負(つまり,自動指定)のとき,段落最初の \verb+\parindent+ 部分への
+進入は可能である.\verb+\parindent+ 部分への進入許容量は
+「文字$-1$」に対する\textsf{rubypreintrusion}(既定値は1,ルビ全角単位)と
+\ \verb+\parindent+ の長さのうち小さい方である.
+\begin{LTXexample}[preset=\Large,width=0.4\textwidth]
+\parindent1\zw\noindent 012345\par
+\ltjruby{陵}{みささぎ}は……\par
+\ltjruby{承}{うけたまわ}り……\par
+\parindent0.25\zw\ltjruby{陵}{みささぎ}は……
+\end{LTXexample}
+
+
+\end{description}
+
+\newpage
+\section{\ruby{実|装}{じつ|そう}について}
+\label{sec:impl}
+次の例で実装の大まかな方法を説明する.
+\begin{LTXexample}[preset=\Large]
+……を\ltjruby{流|暢}{りゆう|ちよう}に……
+\end{LTXexample}
+
+\begin{enumerate}
+\item \verb|\ltjruby|コマンド自体は,一旦次のnode listを値とするwhatsit~$W$を作って,
+現在の水平リストへと挿入する(必要ならば\verb|\leavevmode|も実行):
+\[
+ \Node{whatsit $w$}{value: 2}\longrightarrow
+ \Node{hlist $s_1$}{「りゆう」}\longrightarrow
+ \Node{hlist $p_1$}{「流」}\longrightarrow
+ \Node{hlist $s_2$}{「ちよう」}\longrightarrow
+ \Node{hlist $p_2$}{「暢」}
+\]
+ここで,最初の$w$の値2は,ルビが2つのパーツ「\ltjruby{流}{りゆう}」「\ltjruby{暢}{ちよう}」からなっていることを
+表している.この値を$\mathit{cmp}$とおこう.
+$s_i$達の中の文字は既にルビの大きさである.
+\item \LuaTeX-jaの和文処理グルー挿入処理において,
+このwhatsit~$W$はまとめて
+「先頭が『流』,最後が『暢』であるようなhboxを \verb|\unhbox| で展開したもの」と扱われる.
+言い換えれば,ルビ部分を無視した単なる「流暢」という和文文字の並びとして扱われる\footnote{「流」「暢」の間のグルーは既に入っている,と扱われる.}.
+次のサンプルを参照
+\begin{LTXexample}[preset=\Large]
+\leavevmode\hbox{.}A\\
+%↑xkanjiskip
+\ltjruby{.}{}A
+%↑2分
+\end{LTXexample}
+\item 和文処理グルーの挿入が終わった後で,可動グループルビのためのノードの挿入に入る.
+\begin{enumerate}
+\item $W$の前後に$2\mathit{cmp}+1=5$個のノードが挿入され,$W$の周辺は次のようなノード列になる.
+\begin{align*}
+ (\text{other nodes})&\longrightarrow
+ \Node{glue $g_0$}{}\longrightarrow \Node{whatsit~$W$}{元からある}\longrightarrow \Node{rule $r_1$}{}
+\\&\longrightarrow
+ \Node{glue $g_1$}{}\longrightarrow \Node{rule $r_2$}{}\longrightarrow
+ \Node{glue $g_2$}{}\longrightarrow (\text{other nodes})
+\end{align*}
+
+\item このようにノードを挿入する目的は,\TeX の行分割処理自体に影響を加えずに可動グループルビ
+を実現させることにある.
+\begin{gather*}
+ (\text{other nodes})\longrightarrow
+ \Node{glue $g_0$}{}\longrightarrow \Node{whatsit~$W$}{元からある}\longrightarrow \Node{rule $r_1$}{}\\
+\noalign{\hrulefill 行の境目\hrulefill}
+\Node{rule $r_2$}{}\longrightarrow
+ \Node{glue $g_2$}{}\longrightarrow (\text{other nodes})
+\end{gather*}
+のようになったとしたら,「\ltjruby{流}{りゆう}」「\ltjruby{暢}{ちよう}」の間で行分割が起きた,ということがわかり,
+$g_i$,~$r_i$達のノードを適切に置き換えればよい(後で詳しく説明する).
+
+\begin{figure}\centering\small
+\begin{tabular}{cllll}
+\toprule
+\multicolumn{1}{c}{\bf ノード}&\multicolumn{1}{c}{\bf 組み方}&\multicolumn{1}{c}{\bf サンプル}%
+&\multicolumn{1}{c}{\bf 対応するノード並び}\\
+\midrule
+$n_1$&行末1グループ&
+\Large
+\fbox{を}{\color{blue!50!black}\gt\ltjruby[pre=1,mode=5,stretch=110]{流}{りゆう}}\vrule
+&
+$g_0\rightarrow W\rightarrow r_1$\\
+$n_2$&行末2グループ&
+\Large
+\fbox{を}{\color{blue!50!black}\gt\ltjruby[pre=1,mode=1,stretch=110]{流|暢}{りゆう|ちよう}}\vrule
+&
+$g_0\rightarrow W\rightarrow r_1\rightarrow g_2 \rightarrow r_2$\\
+$n_3$&行頭1グループ&
+\Large
+\vrule{\color{blue!50!black}\gt\ltjruby[post=1,mode=1,stretch=011]{暢}{ちよう}}\fbox{に}
+&
+$r_2\rightarrow g_2$\\
+$n_4$&行頭2グループ&
+\Large
+\vrule{\color{blue!50!black}\gt\ltjruby[post=1,mode=1,stretch=011]{流|暢}{りゆう|ちよう}}\fbox{に}
+&
+$W\rightarrow r_1\rightarrow g_2 \rightarrow r_2\rightarrow g_2$\\
+$n_5$&行中&
+\Large
+\fbox{を}{\color{blue!50!black}\gt\ltjruby[post=0.5,pre=0.5,mode=1]{流|暢}{りゆう|ちよう}}\fbox{に}
+&
+$g_0\rightarrow W\rightarrow r_1\rightarrow g_2 \rightarrow r_2\rightarrow g_2$\\
+
+\bottomrule
+\end{tabular}
+\caption{ルビの組み方と対応するノード並び}
+\label{fig:node}
+\end{figure}
+
+\item なお,$r_i$達の高さ・深さは組み上がった後のそれである.
+$g_i$,~$r_i$達の幅は,図\nobreak\ref{fig:node}に示したような対応に沿って算出する.
+例えばこの場合,行中形$n_5$に対して
+\[
+ g_0+r_1+g_2+r_2+g_2 = 3\,\mathrm{zw}-(0.25\,\mathrm{zw}\times 2)=2.5\,\mathrm{zw}
+\]
+という方程式が立つ(zwは親文字全角の幅,進入量込).
+$n_1$から$n_5$まで計5本の方程式が立つが,これらはGau\ss の消去法で解くことができて
+$g_i$,~$r_i$達の幅が求まる.
+\item また,ルビ処理を統括しているwhatsit~$W$の値も
+\[
+ \Node{whatsit $w$}{value: 2}\longrightarrow
+ \Node{vlist $n_1$}{末1}\longrightarrow
+ \Node{vlist $n_2$}{末2}\longrightarrow
+ \Node{vlist $n_3$}{頭1}\longrightarrow
+ \Node{vlist $n_4$}{頭2}\longrightarrow
+ \Node{vlist $n_5$}{中}
+\]
+に置き換えておく.
+
+\end{enumerate}
+
+\item \LuaTeX の行分割処理を普通に行う.
+\item 行分割の結果に従って,$g_i$,~$r_i$達を適切に置換する.
+
+例えば行分割の結果
+\begin{gather*}
+ (\text{other nodes})\longrightarrow
+ \Node{glue $g_0$}{}\longrightarrow \Node{whatsit~$W$}{元からある}\longrightarrow \Node{rule $r_1$}{}
+ \tag{行A}\\
+\noalign{\hrulefill 行の境目\hrulefill}
+\Node{rule $r_2$}{}\longrightarrow
+ \Node{glue $g_2$}{}\longrightarrow (\text{other nodes})\tag{行B}
+\end{gather*}
+のようになったとしよう.
+\begin{enumerate}
+\item 処理は段落の上の行から順番に行われる.行Aの処理がまわってきたとしよう.
+
+\item 行Aの先頭から順番に眺めていく.すると「whatsit~$W$由来」のノード,$g_0$,~$W$,~$r_1$が見つかり,
+行Aはここで終わっている.
+
+まず,行Aのhboxの中身からwhatsit~$W$を消去(リストから取り除くだけで,$W$のメモリを解放するわけではない)する.
+$g_0$,~($W$,)~$r_1$というノードの並びは,「行末1グループ」$n_1$に対応しているので,
+$g_0$,~$r_1$を行Aから除去・メモリ解放し,代わりに$n_1$を行Aの中身に追加する.
+
+\item 次に行Bの処理にうつる.行Aでルビの処理は完了していない(2グループのルビなのにまだ1グループしか使っていない)ので,
+「whatsit~$W$由来」のノードがいくつか行B内に残っているはずである.
+
+案の定,$r_2$,~$g_2$というノード列が見つかった.これは「行頭1グループ」$n_3$に対応しているので,
+$r_2$,~$g_2$を行Bから除去・メモリ解放し,代わりに$n_3$を行Bの中身に挿入する.
+
+\item これで2グループとも使い切ったことになるので,
+隔離しておいた$W$を,(使われなかった$n_2$,~$n_4$,~$n_5$などと共に)メモリ解放する.結果として
+次のようになった:
+\begin{gather*}
+ (\text{other nodes})\longrightarrow
+ \Node{vlist $n_1$}{末1}\tag{行A}\\
+\noalign{\hrulefill 行の境目\hrulefill}
+\Node{vlist $n_3$}{頭1}\longrightarrow (\text{other nodes})\tag{行B}
+\end{gather*}
+\end{enumerate}
+\end{enumerate}
+
+\newpage
+\section{いくつかの例}
+\def\rubytest{\ruby{黄金橋}{ゴールデンゲートブリッジ}\relax}
+
+\setbox0=\vbox{\hsize=22\zw%
+ああああ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこ}
+%\directlua{ltj.ext_show_node_list(tex.box[0], '? ', print)}
+\fbox{\box0}
+
+\def\rubytest{\ruby{国府津}{こうづ}\relax}
+% グループルビ
+
+\setbox0=\vbox{\hsize=18\zw%
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこ}
+%\directlua{ltj.ext_show_node_list(tex.box[0], '? ', print)}
+\fbox{\box0}
+
+\def\rubytest{\ruby{●●|◆}{◆◆◆◆◆◆|●●●}\relax}
+\setbox0=\vbox{\hsize=19\zw%
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこイ
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこウ
+あ\rubytest いうえおかきくけこエ
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこ}
+%\directlua{ltj.ext_show_node_list(tex.box[0], '? ', print)}
+\fbox{\box0}
+
+\def\rubytest{\ruby{●●|□}{◆◆◆|●●●}\relax}
+\setbox0=\vbox{\hsize=19\zw%
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこイ
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこウ
+あ\rubytest いうえおかきくけこエ
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこ
+あ\rubytest いうえおかきくけこ}
+%\directlua{ltj.ext_show_node_list(tex.box[0], '? ', print)}
+\fbox{\box0}
+
+\def\rubytest{\ruby{異|様}{い|よう}\relax}
+\setbox0=\vbox{\hsize=19\zw%
+あ\rubytest いうえくけ
+あ\rubytest いうえくけこ
+あ\rubytest いうえくけこ
+あ\rubytest いうえくけこイ
+あ\rubytest いうえおかきくけこ}
+%\directlua{ltj.ext_show_node_list(tex.box[0], '? ', print)}
+\fbox{\box0}
+
+\def\rubytest{\ruby{□|■|□}{■■|□□□|■■}\relax}
+
+\setbox0=\vbox{\hsize=23\zw%
+あ\rubytest いうえおかきくけこうえおかきくけこ
+あ\rubytest いうえおかきくけこうえおかきくけこ
+あ\rubytest いう□おかきくけこうえおかきくけこ
+あ\rubytest いう□おかきくけこうえおかきくけこ
+あ\rubytest いう□おかきくけこうえおかきくけこ
+あ\rubytest いうえおかきくけこ}
+\fbox{\box0}
+
+\begin{description}
+\def\sample{又\ruby{承}{うけたまわ}る\quad \ruby{疎}{そ}\quad は\ruby{俄}{にわか}勉強
+ \quad 後\ruby{俄}{にわか}勉強\quad は\ruby{暁}{あかつき}に
+ は\ruby{俄}{にわか}に
+ \quad \ruby{休|憩|中}{きゆう|けい|ちゆう}かつ\ruby{視|聴|中}{し|ちよう|ちゆう}}
+\item[標準] \sample
+\item[肩つき] {\ltjsetruby{kata}\sample}
+\end{description}
+
+\newpage
+\begin{LTXexample}[pos=t]
+{\ltjsetruby{stretch=101}% 親文字均等割り禁止
+ \ruby{休|憩|中}{きゆう|けい|ちゆう}かつ\ruby{視|聴|中}{し|ちよう|ちゆう}%
+}\quad
+\textgt{\ruby{勉|強}{べん|きよう}と%
+ \ruby[fontcmd=\mcfamily]{勉|強}{べん|きよう}}\quad% ルビは明朝体
+\ruby{コギト・エルゴ・スム}{Cogito ergo sum}\quad % 欧文空白は伸長しない
+\ruby[size=1]{Cogito ergo sum}{コギト・エルゴ・スム}% 欧文空白は伸長しない
+\end{LTXexample}
+
+\newpage
+\section{『日本語組版処理の要件』20120403の例}
+
+\newcommand*{\噂}{\CID{7642}}
+\newcommand*{\倦}{\CID{7674}}
+%================================== 横組
+\paragraph{3.3.1節}\
+\begin{LTXexample}[pos=t]
+\obeylines
+3.49 \ruby{君|子}{くん|し}は\ruby{和}{わ}して\ruby{同}{どう}ぜず
+3.50 \ruby{人}{ひと}に\ruby{誨}{おし}えて\ruby{\倦}{う}まず
+% モノルビ.面倒でも複数回の実行が必要
+3.51 \ruby{鬼}{き}\ruby{門}{もん}の\ruby{方}{ほう}\ruby{角}{がく}を%
+ \ruby{凝}{ぎょう}\ruby{視}{し}する
+% 熟語ルビ
+3.52 \ruby{鬼|門}{き|もん}の\ruby{方|角}{ほう|がく}を\ruby{凝|視}{ぎよう|し}する
+3.53 \ruby{茅場町}{かやばちよう}\quad\ruby{茅|場}{かや|ば}\ruby{町}{ちよう}
+% 熟字訓
+3.54 \ruby{紫陽花}{あじさい}\quad\ruby{坩堝}{るつぼ}\quad\ruby{田舎}{いなか}
+% グループルビ
+3.55 \ruby{模型}{モデル}\quad\ruby{顧客}{クライアント}\quad%
+ \ruby{境界面}{インターフエース}\quad\ruby{避難所}{アジール}
+3.56 \ruby{編集者}{editor}\quad \ruby{editor}{エデイター}
+\end{LTXexample}
+
+\paragraph{3.3.3節}\
+\begin{LTXexample}[pos=t]
+\obeylines
+3.58 に\ruby{幟}{のぼり}を\quad に\ruby[kata]{幟}{のぼり}を\quad%
+ \ruby{韋}{い}\ruby{編}{へん}\ruby{三}{さん}\ruby{絶}{ぜつ}
+% 三分ルビ.JY3/mc/mc は本文書のプリアンブルで独自に定義
+3.59 に\ruby[fontcmd=\kanjifamily{mc}\kanjiseries{mc}]{幟}{のぼり}を
+% ルビ文字を小さくする
+3.60 {\Large%
+ \ruby{韋}{い}\ruby{編}{へん}\ruby{三}{さん}\ruby{絶}{ぜつ}\quad% 比較用
+ \ltjsetruby{size=0.375}% 0.5 -> 0.375
+ \ruby{韋}{い}\ruby{編}{へん}\ruby{三}{さん}\ruby{絶}{ぜつ}}
+\end{LTXexample}
+
+\paragraph{3.3.4節}
+3.61図(両側ルビ)は未サポートにより省略
+
+\newpage
+\paragraph{3.3.5節 モノルビ}\
+\begin{LTXexample}[pos=t]
+\obeylines
+3.62 の\ruby{葯}{やく}に
+3.63 版面の\ruby{地}{ち}に\quad 版面の\ruby[kata]{地}{ち}に
+% 横組肩つきはしないが,現状では縦組未サポートだし,仕方ないね
+3.65 の\ruby{砦}{とりで}に
+{\ltjsetruby{kata}%
+3.66上 の\ruby{旬}{しゆん}に\quad 後\ruby{旬}{しゆん}に
+3.66下 の\ruby{旬}{しゆん}又\quad 後\ruby{旬}{しゆん}又}
+\end{LTXexample}
+
+
+\paragraph{3.3.6節 グループルビ}\
+\begin{LTXexample}[pos=t]
+\obeylines
+3.67 は\ruby{冊子体}{コーデツクス}と
+3.68 \ruby{模型}{モデル}\quad \ruby{利用許諾}{ライセンス}
+% 両端を揃える流儀
+3.69 {\ltjsetruby{stretchruby=010}%
+ \ruby{模型}{モデル}\quad \ruby{利用許諾}{ライセンス}}
+% ルビが極端に短い場合
+3.70 \ruby{なげきの聖母像}{ピエタ}\quad% ルビ全角まで許容
+ \ruby[maxmargin=0.75]{なげきの聖母像}{ピエタ}% ルビ全角1.5倍まで
+% ルビが長い場合
+3.71 \ruby{顧客}{クライアント}\quad \ruby{境界面}{インターフエース}
+3.72 {\ltjsetruby{stretch=010, stretchbol=010, stretcheol=010}% はみ出さない流儀
+ \ruby{顧客}{クライアント}\quad \ruby{境界面}{インターフエース}}
+\end{LTXexample}
+
+\newpage
+\paragraph{3.3.7節 熟語ルビ}\
+\begin{LTXexample}[pos=t]
+\obeylines
+3.73 \ruby{杞|憂}{き|ゆう}\quad \ruby{畏|怖}{い|ふ}\quad%
+ \ruby[kata]{杞|憂}{き|ゆう}\quad \ruby[kata]{畏|怖}{い|ふ}
+3.74 の\ruby{流|儀}{りゆう|ぎ}を\quad の\ruby{無|常}{む|じよう}を\quad%
+ の\ruby{成|就}{じよう|じゆ}を\quad の\ruby{紋|章}{もん|しよう}を\quad%
+ の\ruby{象|徴}{しよう|ちよう}を
+% 熟語の構成を考慮した方法は現行ではできない.
+% 行分割はできるのだが,「他の漢字にルビ全角までかかって良い」は難しい.
+3.75 {\ltjsetruby{kata}%
+ の\ruby{流|儀}{りゆう|ぎ}を\quad の\ruby{無|常}{む|じよう}を\quad%
+ の\ruby{成|就}{じよう|じゆ}を\quad の\ruby{紋|章}{もん|しよう}を\quad%
+ の\ruby{象|徴}{しよう|ちよう}を}
+% モノルビ配置.望ましくない
+3.76× の\ruby{流}{りゆう}\ruby{儀}{ぎ}を\quad の\ruby{無}{む}\ruby{常}{じよう}を\quad%
+
+要調整 3.77\ {\ltjsetruby{stretchbol=121, stretcheol=121}% 行頭・行末揃えず
+ \hbox{\vrule\vbox{\hsize=10\zw ああああああああの%
+ \ruby{流|儀}{りゆう|ぎ}がある.}\vrule}\textbf{←なぜ改行できない}\quad%
+ \hbox{\vrule\vbox{\hsize=5\zw ……等の\ruby{無|常}{む|じよう}を}\vrule}}
+\end{LTXexample}
+
+\paragraph{3.3.8節 ルビはみ出し}\
+\begin{LTXexample}[pos=t]
+\obeylines
+3.78 \ruby{人}{ひと}は\ruby{死}{し}して\ruby{名}{な}を\ruby{残}{のこ}す
+% 現在の自動設定の仕様では「脚」の前が四分だけ「要件」の例より空く
+3.79 漢字の部首には\ruby{偏}{へん}・\ruby{冠}{かんむり}・\ruby{脚}{きやく}・%
+ \ruby{旁}{つくり}がある
+3.79 漢字の部首には\ruby{偏}{へん},\ruby{冠}{かんむり},\ruby{脚}{きやく},%
+ \ruby{旁}{つくり}がある
+\end{LTXexample}
+\begin{LTXexample}[pos=t]
+\obeylines
+% もちろん手動で進入量を指定すれば話は別
+3.79 漢字の部首には\ruby{偏}{へん}・\ruby{冠}{かんむり}・\ruby[pre=1]{脚}{きやく}・%
+ \ruby{旁}{つくり}がある
+3.79 漢字の部首には\ruby{偏}{へん},\ruby{冠}{かんむり},\ruby[pre=1]{脚}{きやく},%
+ \ruby{旁}{つくり}がある
+3.79 この\ruby{\噂}{うわさ}の好きな人は\ruby{懐}{ふところ}ぐあいもよく、\ruby{檜}{ひのき}を
+3.80 漢字の部首には「\ruby{偏}{へん}」「\ruby{冠}{かんむり}」「\ruby{脚}{きやく}」%
+「\ruby{旁}{つくり}」がある
+3.80 この\ruby{\噂}{うわさ}好きな人は\ruby{懐}{ふところ}具合もよく、\ruby{檜}{ひのき}材を
+3.81× に\ruby{暁}{あかつき}の\kern-1\zw の\ruby{趣}{おもむき}を
+3.82 に\ruby{暁}{あかつき}の\ruby{趣}{おもむき}を
+
+% 漢字にルビを2分まで掛けても良い流儀
+{%
+ \ltjsetparameter{rubypostintrusion={`好,0.5}}
+ \ltjsetparameter{rubypostintrusion={`具,0.5}}
+ \ltjsetparameter{rubypostintrusion={`材,0.5}}
+3.83 この\ruby{\噂}{うわさ}の好きな人は\ruby{懐}{ふところ}ぐあいもよく、\ruby{檜}{ひのき}を
+3.83 この\ruby{\噂}{うわさ}好きな人は\ruby{懐}{ふところ}具合もよく、\ruby{檜}{ひのき}材を
+}
+% 平仮名にもルビを掛けない流儀
+{\catcode`\<12%
+ \makeatletter\count@="3040\loop\relax\ifnum \count@<"30A0%
+ \ltjsetparameter{rubypreintrusion={\the\count@,0}, %
+ rubypostintrusion={\the\count@,0}}%
+ \advance\count@1 \repeat
+3.84 この\ruby{\噂}{うわさ}の好きな人は\ruby{懐}{ふところ}ぐあいもよく、\ruby{檜}{ひのき}を
+3.84 この\ruby{\噂}{うわさ}好きな人は\ruby{懐}{ふところ}具合もよく、\ruby{檜}{ひのき}材を
+}
+\end{LTXexample}
+\begin{LTXexample}[pos=t]
+\obeylines
+3.85\ {\ltjsetruby{stretchbol=121, stretcheol=121}% 行頭・行末揃えず
+\hbox{\vrule\vbox{\hsize=15\zw
+ \hskip9.5\zw……の\ruby{徑}{こみち}を……%
+\hskip9\zw……の\ruby{徑}{こみち}を……}\vrule}}
+3.86\ \hbox{\vrule\vbox{\hsize=15\zw
+ \hskip10\zw……の\ruby{徑}{こみち}を……%
+\hskip9\zw……の\ruby{徑}{こみち}を……}\vrule}
+3.87\ \hbox{\vrule\vbox{\hsize=15\zw
+ \hskip8\zw……共\ruby{飾り}{アクセサリー}等……%
+\hskip9\zw……共\ruby{飾り}{アクセサリー}等……}\vrule}
+\end{LTXexample}
+
+
+\paragraph{圏点の例(常用漢字表前書きより)}
+この表は,法令,公⽤⽂書,新聞,雑誌,放送など,⼀般の社会⽣活におい%
+て\kenten[kenten=﹅]{現代の国語を書き表す}場合の\kenten{漢字使⽤の⽬安を⽰す}ものである。
+
+\subparagraph{「﹅」の大きさを親文字の0.33倍にした例}
+この表は,法令,公⽤⽂書,新聞,雑誌,放送など,⼀般の社会⽣活におい%
+て\kenten[size=0.33, kenten=﹅]{現代の国語を書き表す}場合の\kenten{漢字使⽤の⽬安を⽰す}ものである。
+\end{document}
diff --git a/Master/texmf-dist/doc/luatex/luatexja/luatexja.dtx b/Master/texmf-dist/doc/luatex/luatexja/luatexja.dtx
index aa9e92dcc73..ed343fefb84 100644
--- a/Master/texmf-dist/doc/luatex/luatexja/luatexja.dtx
+++ b/Master/texmf-dist/doc/luatex/luatexja/luatexja.dtx
@@ -47,7 +47,7 @@
%</ja>
\usepackage{amsmath,array,tikz,pict2e,multienum,float}
-\usepackage{booktabs,multicol}
+\usepackage{booktabs,multicol,luatexja-ruby}
%%%%%%%% listings
@@ -108,7 +108,9 @@
\usepackage{luatexja-otf}
%<ja>\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
%</en>
-\DeclareRobustCommand\ttfamily
- {\not@math@alphabet\ttfamily\mathtt
- \romanfamily\ttdefault\ttjfam\selectfont}
-\newjfontfamily\ttjfam{KozGoPr6N-Regular.otf}
-
%%%%%%%% logo
\usepackage{metalogo}
@@ -183,6 +180,7 @@
\catcode`\<=13
\def<#1>{{\normalfont\rm\itshape$\langle$#1\/$\rangle$}}
+\let\LARG=<
\maketitle
\tableofcontents
@@ -932,7 +930,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}がそれぞれ用意されている.
%</ja>
@@ -940,7 +938,7 @@ Okumura), namely, \Pkg{ltjclasses} and \Pkg{ltjsclasses}.
%<ja>\section{フォントの変更}
\subsection{plain \TeX~and~\LaTeXe}
-\label{ssub-chgfnt}
+\label{ssec-chgfnt}
\paragraph{plain \TeX}
%<*en>
@@ -1014,7 +1012,7 @@ auto select&\verb+\fontencoding+&\verb+\fontfamily+&---&---&\verb+\usefont+\\
alphabetic fonts to \texttt{T1}.
\verb+\fontfamily+ also changes the current Japanese font family,
the current alphabetic font family, \emph{or both}.
- For the detail, see Subsection~\ref{ssub-nfsspat}.
+ For the detail, see Subsection~\ref{ssec-nfsspat}.
%</en>
%<*ja>
ここで,\verb+\fontencoding{+<encoding>\verb+}+ は,引数により和文側か欧文
@@ -1023,7 +1021,7 @@ auto select&\verb+\fontencoding+&\verb+\fontfamily+&---&---&\verb+\usefont+\\
\texttt{JY3}に変更し,\verb+\fontencoding{T1}+ は欧文フォント側を
\texttt{T1}へと変更する.\verb+\fontfamily+ も引数により和文側,欧文
側,\emph{あるいは両方}のフォントファミリを変更する.詳細は
- \ref{ssub-nfsspat}節を参照すること.
+ \ref{ssec-nfsspat}節を参照すること.
%</ja>
%<*en>
@@ -1046,7 +1044,7 @@ auto select&\verb+\fontencoding+&\verb+\fontfamily+&---&---&\verb+\usefont+\\
%<*ja>
仮名書体を使う場合など,複数の和文フォントを組み合わせて使いたい場合は
\ref{ssec-altfont}節の \verb+\ltjdeclarealtfont+ と,その\LaTeX 版の\
-\verb+\DeclareAlternateKanjiFont+(\ref{ssub-nfsspat}節)を参照せよ.
+\verb+\DeclareAlternateKanjiFont+(\ref{ssec-nfsspat}節)を参照せよ.
%</ja>
\end{itemize}
@@ -1114,13 +1112,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[<options>]\{luatexja-fontspec\}
+\end{quote}
+This \Pkg{luatexja-fontspec} package
+automatically loads \Pkg{luatexja} and \Pkg{fontspec}
package, if needed.
%</en>
%<*ja>
-\Pkg{fontspec}パッケージと同様の機能を和文フォントに対しても用いるためには,
-\Pkg{luatexja-fontspec}パッケージをプリアンブルで読み込む必要がある.このパッケージ
+\Pkg{fontspec}パッケージと同様の機能を和文フォントに対しても用いる場合,
+\Pkg{luatexja-fontspec}パッケージを読み込む:
+\begin{quote}
+\ttfamily \textbackslash usepackage[<options>]\{luatexja-fontspec\}
+\end{quote}
+このパッケージ
は必要ならば自動で\Pkg{luatexja}パッケージと\Pkg{fontspec}パッケージを読み込む.
%</ja>
@@ -1132,20 +1138,21 @@ counterparts of original commands in the \Pkg{fontspec} package:
\Pkg{luatexja-fontspec}パッケージでは,以下の7つのコマンドを\Pkg{fontspec}
パッケージの元のコマンドに対応するものとして定義している:
%</ja>
-
%<*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 +1179,54 @@ alphabetic fonts
\end{tabular}
\end{center}
%</ja>
-\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=<opts>]
+Specify options <opts> 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}).
%</en>
%<*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=<opts>]
+\Pkg{fontspec} パッケージに渡すオプション <opts> を指定する.
+\end{list}
+標準で \verb+\setmonojfont+ コマンドが定義されないのは,
+和文フォントではほぼ全ての和文文字のグリフが等幅であるのが伝統的であったことによる.
+また,これらの和文用のコマンドではフォント内のペアカーニング情報は標準では使用されない,
言い換えれば \texttt{kern} featureは標準では無効化となっている.
これは以前のバージョンの\LuaTeX-jaとの互換性のためである(\ref{para-kern}節を参照).
%</ja>
+\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}
+
%<en>\subsection{Presets}
%<ja>\subsection{プリセット設定}
\label{ssec-preset}
@@ -1615,7 +1645,7 @@ If you want to use these functions, load \Pkg{luatexja-otf} package.
これら3オプションについては,
\Pkg{luatexja-preset} パッケージにプリセットを使う時に一緒に指定するか,
-あるいは対応する内容を\ref{ssub-chgfnt}節,\ref{ssub-nfsspat}節 (NFSS2) や
+あるいは対応する内容を\ref{ssec-chgfnt}節,\ref{ssec-nfsspat}節 (NFSS2) や
\ref{ssec-fontspec}節 (\Pkg{fontspec}) の方法で手動で指定する必要がある.
%</ja>
@@ -2637,7 +2667,7 @@ because of the compatibility with previous versions of \LuaTeX-ja.
図\ref{fig:kern-jfm}を参照.
\begin{itemize}
\item \emph{\texttt{\textbackslash jfont} や,
-NFSS2用の命令(\ref{ssub-chgfnt}節,\ref{ssub-nfsspat}節)における指定では
+NFSS2用の命令(\ref{ssec-chgfnt}節,\ref{ssec-nfsspat}節)における指定では
カーニング情報は標準で使用する}ことになっているようである.
言い換えれば,カーニング情報を使用しない設定にするには,面倒でも
\begin{verbatim}
@@ -4265,30 +4295,19 @@ are typeset by \verb+\piyo+.
%<en>\subsection{Patch for NFSS2}
%<ja>\subsection{NFSS2へのパッチ}
-\label{ssub-nfsspat}
+\label{ssec-nfsspat}
\begin{figure}[!tb]
-\begin{lstlisting}[numberstyle=\tiny, numbers=left, numbersep=1em]
+\begin{LTXexample}[pos=b]
\DeclareKanjiFamily{JY3}{edm}{}
-\DeclareFontShape{JY3}{edm}{m}{n} {<-> s*KozMinPr6N-Regular:jfm=ujis;-kern}{}
-\DeclareFontShape{JY3}{edm}{m}{green}{<-> s*KozMinPr6N-Regular:jfm=ujis;-kern;color=007F00}{}
-\DeclareFontShape{JY3}{edm}{m}{blue} {<-> s*KozMinPr6N-Regular:jfm=ujis;-kern;color=0000FF}{}
+\DeclareFontShape{JY3}{edm}{m}{n} {<-> s*KozMinPr6N-Regular:jfm=ujis;}{}
+\DeclareFontShape{JY3}{edm}{m}{green}{<-> s*KozMinPr6N-Regular:jfm=ujis;color=007F00}{}
+\DeclareFontShape{JY3}{edm}{m}{blue} {<-> s*KozMinPr6N-Regular:jfm=ujis;color=0000FF}{}
\DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{green}{"4E00-"67FF,{-2}-{-2}}
\DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{blue}{ "6800-"9FFF}
{\kanjifamily{edm}\selectfont
日本国民は、正当に選挙された国会における代表者を通じて行動し、……}
-\end{lstlisting}
-\begin{quote}
-\DeclareKanjiFamily{JY3}{edm}{}
-\DeclareFontShape{JY3}{edm}{m}{n} {<-> s*KozMinPr6N-Regular:jfm=ujis;-kern}{}
-\DeclareFontShape{JY3}{edm}{m}{green}{<-> s*KozMinPr6N-Regular:jfm=ujis;-kern;color=007F00}{}
-\DeclareFontShape{JY3}{edm}{m}{blue} {<-> s*KozMinPr6N-Regular:jfm=ujis;-kern;color=0000FF}{}
-\DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{green}{"4E00-"67FF,{-2}-{-2}}
-\DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{blue}{ "6800-"9FFF}
-
-{\kanjifamily{edm}\selectfont
-日本国民は、正当に選挙された国会における代表者を通じて行動し、……}
-\end{quote}
+\end{LTXexample}
%<ja>\caption{\texttt{\textbackslash DeclareAlternateKanjiFont} の使用例}
%<en>\caption{An example of \texttt{\textbackslash DeclareAlternateKanjiFont}}
\label{fig:altkanji}
@@ -4298,13 +4317,13 @@ are typeset by \verb+\piyo+.
Japanese patch for NFSS2 in \LuaTeX-ja
is based on \texttt{plfonts.dtx} which plays the same role in \pLaTeXe.
We will describe
-commands which are not described in Subsection~\ref{ssub-chgfnt}.
+commands which are not described in Subsection~\ref{ssec-chgfnt}.
%</en>
%<*ja>
\LuaTeX-jaのNFSS2への日本語パッチは
\pLaTeXe で同様の役割を果たす \texttt{plfonts.dtx} をベースに,
和文エンコーディングの管理等をLuaで書きなおしたものである.
-ここでは\ref{ssub-chgfnt}節で述べていなかった命令について
+ここでは\ref{ssec-chgfnt}節で述べていなかった命令について
記述しておく.
%</ja>
@@ -4542,7 +4561,7 @@ In this case, the default family for font substitution is used for
\item[DeclareAlternateKanjiFont\{<base-encoding>\}\{<base-family>\}\{<base-series>\}\{<base-shape>\}\\
\null\hfill\{<alt-encoding>\}\{<alt-family>\}\{<alt-series>\}\{<alt-shape>\}\{<range>\}]
%<*ja>
-\ref{ssec-altfont}節の
+\ref{ssec-altfont}節の\
\verb+\ltjdeclarealtfont+ と同様に,前半の4引数の和文フォント(基底フォント)のうち<range>中の文字を
第5--第8引数の和文フォントを使って組むように指示する.使用例を図\ref{fig:altkanji}に載せた.
@@ -4620,6 +4639,7 @@ by \verb+\input+.
\verb+\input+ で読み込み可能である.
%</ja>
\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
@@ -4666,6 +4686,60 @@ will not be embedded in the output PDF file. See Subsection~\ref{ssec-psft}.
これを指定することで,PDFに埋め込まれない「名前だけ」のフォントを指定することが
できる.\ref{ssec-psft}節を参照.
%</ja>
+
+
+\begin{figure}[!tb]
+\begin{LTXexample}[pos=b]
+\jfontspec[
+ AltFont={
+ {Range="4E00-"67FF, Color=007F00},
+ {Range="6800-"9EFF, Color=0000FF},
+ {Range="3040-"306F, Font=KozGoPr6N-Regular},
+ }
+]{KozMinPr6N-Regular}
+日本国民は、正当に選挙された国会における代表者を通じて行動し、われらとわれらの子孫のために、
+諸国民との協和による成果と、わが国全土にわたつて自由のもたらす恵沢を確保し、……
+\end{LTXexample}
+%<ja>\caption{\texttt{AltFont} の使用例}
+%<en>\caption{An example of \texttt{AltFont}}
+\label{fig:altkanji-fontspec}
+\end{figure}
+
+\item[AltFont]\
+
+%<*en>
+As \verb+\ltjdeclarealtfont+~(Subsection~\ref{ssec-altfont}) and
+\verb+\DeclareAlternateKanjiFont+~(Subsection~\ref{ssec-nfsspat}),
+with this key, one can typeset some Japanese characters
+by a different font and/or using different features.
+The \texttt{AltFont} feature takes a comma-separated list of comma-separated lists,
+as the following:
+%</en>
+%<*ja>
+\ref{ssec-altfont}節の \verb+\ltjdeclarealtfont+ や,
+\ref{ssec-nfsspat}節の \verb+\DeclareAlternateKanjiFont+ と同様に,
+このキーを用いると一部の文字を異なったフォントやfont featureを使って組むことができる.
+\texttt{AltFont} に指定する値は,次のように二重のコンマ区切りリストである:
+%</ja>
+\begin{lstlisting}[escapechar=\#]
+AltFont = {
+ ...
+ { Range=#\LARG range>#, #\LARG features>#},
+ { Range=#\LARG range>#, Font=#\LARG font~name>#, #\LARG features># },
+ { Range=#\LARG range>#, Font=#\LARG font~name># },
+ ...
+}
+\end{lstlisting}
+%<*en>
+Each sublist should have the \texttt{Range} key
+(sublist which does not contain \texttt{Range} key is simply ignored).
+A demonstrartion is shown in Figure~\ref{fig:altkanji-fontspec}.
+%</en>
+%<*ja>
+各部分リストには \texttt{Range} キーが必須である(含まれない部分リストは
+単純に無視される).
+指定例は図\ref{fig:altkanji-fontspec}に示した.
+%</ja>
\end{list}
%<*ja>
@@ -4674,7 +4748,6 @@ will not be embedded in the output PDF file. See Subsection~\ref{ssec-psft}.
%</ja>
-
\subsection{\texttt{luatexja-otf.sty}}
\label{ssec-ltjotf}
%<*en>
@@ -4919,15 +4992,113 @@ for making the difference obvious.
\item[\textsf{adjust}\,=<bool>] \verb+\ltjsetparameter+ で指定可能な追加パラメータであり,
<bool>が\textit{true}なら \verb+\ltjenableadjust+ を,
そうでなければ \verb+\ltjdisableadjust+ を実行する.
-
-
\end{list}
+%</ja>
+\subsection{\texttt{luatexja-ruby.sty}}
+%<*en>
+This addon package provides functionality of ``ruby'' (\emph{furigana}) annotations
+using callbacks of \LuaTeX-ja.
+There is no detailed manual of \Pkg{luatexja-ruby.sty} in English.
+(Japanese manual is another PDF file, \url{luatexja-ruby.pdf}.)
+%</en>
+%<*ja>
+この追加パッケージは,\LuaTeX-jaの機能を利用したルビ(振り仮名)の組版機能を提供する.
+前後の文字種に応じた前後への自動進入や,
+行頭形・行中形・行末形の自動的な使い分けが特徴である.
+ルビ組版に設定可能な項目や注意事項が多いため,本追加パッケージの詳細な説明は
+使用例と共に \url{luatexja-ruby.pdf}\ という別ファイルに載せている.
+この節では簡単な使用方法のみ述べる.
+%</ja>
+\begin{description}
+%<*en>
+ \item[Group-ruby]
+By default, ruby characters (the second argument of \verb+\ruby+)
+are attached to base characters (the first argument), as one object.
+This type of ruby is called \emph{group-ruby}.
+%</en>
+%<*ja>
+ \item[グループルビ] 標準ではグループルビの形で組まれる.第1引数に親文字,
+第2引数にルビを記述する.
+%</ja>
+\begin{LTXexample}[width=0.3\textwidth]
+東西線\ruby{妙典}{みようでん}駅は……\\
+東西線の\ruby{妙典}{みようでん}駅は……\\
+東西線の\ruby{妙典}{みようでん}という駅……\\
+東西線\ruby{葛西}{かさい}駅は……
+\end{LTXexample}
+%<*en>
+As the above example, ruby hangover is allowed on the Hiragana before/after
+its base characters.
+%</en>
+%<ja> この例のように,標準では前後の平仮名にルビ全角までかかるようになっている.
+%<*en>
+\item[Mono-ruby]
+To attach ruby characters to each base characters (\emph{mono-ruby}),
+one should use \verb+\ruby+ multiple times:
+%</en>
+%<*ja>
+ \item[モノルビ] 親文字を1文字にするとモノルビとなる.
+2文字以上の熟語をモノルビの形で組みたい場合は,面倒でも
+その数だけ \verb+\ruby+ を書く必要がある.
+%</ja>
+\begin{LTXexample}[width=0.3\textwidth]
+東西線の\ruby{妙}{みよう}\ruby{典}{でん}駅は……
+\end{LTXexample}
+%<*en>
+ \item[Jukugo-ruby]
+Vertical bar~\verb+|+ denotes a boundary of \emph{groups}.
+%</en>
+%<*ja>
+ \item[熟語ルビ] 引数内の縦棒 \verb+|+ はグループの区切りを表し,
+複数グループのルビは熟語ルビとして組まれる.
+\cite{x4051}にあるように,
+どのグループでも「親文字」が対応するルビ以上の長さの場合は
+各グループごとに,そうでないときは全体をまとめて1つのグループルビとして組まれる.
+\cite{jlreq}で規定されている組み方とは異なるので注意.
%</ja>
+\begin{LTXexample}
+\ruby{妙|典}{みよう|でん}\
+\ruby{葛|西}{か|さい}\
+\ruby{神楽|坂}{かぐら|ざか}
+\end{LTXexample}
+%<*en>
+If there are multiple groups in one \verb+\ruby+ call,
+A linebreak between two groups is allowed.
+%</en>
+%<ja> 複数ルビではグループとグループの間で改行が可能である.
+\begin{LTXexample}[width=0.3\textwidth]
+\vbox{\hsize=6\zw\noindent
+ \hbox to 2.5\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
+ \hbox to 2.5\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
+ \hbox to 3\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
+}
+\end{LTXexample}
+\end{description}
+
+%<*en>
+If the width of ruby characters are longer than that of base characters,
+\verb+\ruby+ automatically selects the appropriate form
+among the line-head form, the line-middle form, and the line-end form.
+%</en>
+%<*ja>
+また,ルビ文字のほうが親文字よりも長い場合は,自動的に
+行頭形・行中形・行末形のいずれか適切なものを選択する.
+%</ja>
+\begin{LTXexample}[width=0.3\textwidth]
+\vbox{\hsize=8\zw\noindent
+\null\kern3\zw ……を\ruby{承}{うけたまわ}る
+ \kern1\zw ……を\ruby{承}{うけたまわ}る\\
+\null\kern5\zw ……を\ruby{承}{うけたまわ}る
+}
+\end{LTXexample}
+
+
+
@@ -6567,7 +6738,7 @@ Consider the following input:
例えば次のような入力を考えよう:
%</ja>
\begin{verbatim*}
-\begin{lstlisting}[escapechar=`\#]
+\begin{lstlisting}[escapechar=\#]
#\ほげ xぴよ#
\end{lstlisting}
\end{verbatim*}
diff --git a/Master/texmf-dist/source/luatex/luatexja/ltjsclasses.dtx b/Master/texmf-dist/source/luatex/luatexja/ltjsclasses.dtx
index f8acc836ddf..80b488c8a87 100644
--- a/Master/texmf-dist/source/luatex/luatexja/ltjsclasses.dtx
+++ b/Master/texmf-dist/source/luatex/luatexja/ltjsclasses.dtx
@@ -22,7 +22,7 @@
% -----------------------------------------
%
% \fi
-% \CheckSum{5199}
+% \CheckSum{5202}
%% \CharacterTable
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
@@ -50,7 +50,7 @@
%<*driver>
\ProvidesFile{ltjsclasses.dtx}
%</driver>
- [2014/02/07 ]
+ [2014/03/28 ]
%<*driver>
\documentclass{ltjsarticle}
\usepackage{doc}
@@ -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/Master/texmf-dist/tex/luatex/luatexja/addons/luatexja-fontspec.sty b/Master/texmf-dist/tex/luatex/luatexja/addons/luatexja-fontspec.sty
index 9fa1ec4867e..43666d3b3f3 100644
--- a/Master/texmf-dist/tex/luatex/luatexja/addons/luatexja-fontspec.sty
+++ b/Master/texmf-dist/tex/luatex/luatexja/addons/luatexja-fontspec.sty
@@ -3,31 +3,64 @@
%
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{luatexja-fontspec}[2014/01/23 fontspec support of LuaTeX-ja]
-
-\RequirePackage{fontspec,luatexja}
+\ProvidesPackage{luatexja-fontspec}[2014/04/16 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}[2011/09/13]
+
+%%%%%%%% 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} }
-\msg_new:nnn {ltj-fontspec} {addjfontfeatures-ignored}
+\msg_new:nnn {luatexja-fontspec} {addjfontfeatures-ignored}
{
\string\addjfontfeature (s)~ ignored;\\
it~ cannot~ be~ used~ with~ a~ font~ that~ wasn't~ selected~ by~ luatexja-fontspec.
}
-\cs_generate_variant:Nn \prg_new_conditional:Nnn {Nnx}
+\msg_new:nnn {luatexja-fontspec} {altfont-ignored-by-norange}
+{
+ ignored~ sublist~ `#1'~ in~ AltFont~ (no~ range~ is~ specified).
+}
-%%%%%%%% For compatibility with old fontspec.
-\prg_new_conditional:Nnx \ltj_fontspec_if_liiikeys: {TF,F} {
- \@ifpackagelater {fontspec} {2011/09/13}
- { \exp_not:N \prg_return_true: } % fontspec >= 2.2 (l3keys)
- { \exp_not:N \prg_return_false: } % fontspec < 2.2 (xkeyval)
+\msg_new:nnn {luatexja-fontspec} {altfont-ignored-by-rangeonly}
+{
+ ignored~ sublist~ `#1'~ in~ AltFont~ (only~ range~ is~ specified).
}
+\cs_generate_variant:Nn \prg_new_conditional:Nnn {Nnx}
+
%%%%%%%% \g_ltj_fontspec_scale_fp
%% Default scale value for jfont.
+\fp_new:N \g_ltj_fontspec_scale_fp
\group_begin:
\fontsize{10}{10}\selectfont
\fp_gset:Nn \g_ltj_fontspec_scale_fp {\zw / 10}
@@ -36,23 +69,49 @@
%%%%%%%% Internal control sequences
%% Each CS is ltj_fontspec version that corresponds to original CS of fontspec.
\cs_new:Nn \ltj_fontspec_define_option:nn {
- \ltj_fontspec_if_liiikeys:TF {
- \keys_define:nn {fontspec} { #1 .code:n = {#2}}
- } {
- \define@key[zf]{options}{#1}{#2}
- }
+ \keys_define:nn {fontspec} { #1 .code:n = {#2}}
}
\cs_new:Nn \ltj_fontspec_define_preparse_external:nn {
- \ltj_fontspec_if_liiikeys:TF {
- \keys_define:nn {fontspec-preparse-external} { #1 .code:n = {#2}}
- } {
- \define@key[zf]{preparse-external}{#1}{#2}
- }
+ \keys_define:nn {fontspec-preparse-external} { #1 .code:n = {#2}}
+}
+
+\cs_new:Nn \ltj_fontspec_define_altfont_option:nn {
+ \keys_define:nn {fontspec-ltjaltfont} { #1 .code:n = {#2}}
}
+%% Alternate Fonts
+%% Spec: AltFont = {
+%% ...
+%% { Range = <range>, <font features> },
+%% { Range = <range>, Font = <font name>, <font features> },
+%% { Range = <range>, Font = <font name> },
+%% ...
+%% }
+\tl_new:N \l_ltj_fontspec_altname_tl
+\tl_new:N \l_ltj_fontspec_altrange_tl
+\clist_new:N \l_ltj_fontspec_altfont_clist
+\clist_new:N \l_ltj_fontspec_altfont_leftover_clist
+\int_new:N \g_ltj_fontspec_altnumber_int
+
+\ltj_fontspec_define_altfont_option:nn {Range} {
+ \tl_set:Nn \l_ltj_fontspec_altrange_tl {#1}
+}
+\ltj_fontspec_define_altfont_option:nn {Font} {
+ \fontspec_complete_fontname:Nn \l_ltj_fontspec_altname_tl {#1}
+}
+
+\cs_new:Nn \__ltj_fontspec_altfont_key_code:n
+ {
+ \clist_set:Nn \l_ltj_fontspec_altfont_clist {#1}
+ \fontspec_update_fontid:n {alt:#1}
+ }
+
\cs_new:Nn \ltj_fontspec_select:nn {
\group_begin:
+ \ltj_fontspec_define_option:nn {AltFont} {
+ \__ltj_fontspec_altfont_key_code:n { ##1 }
+ }
\ltj_fontspec_define_option:nn {CID} {
\fontspec_update_fontid:n {+cid=##1}
\fontspec_update_featstr:n {cid=##1}
@@ -74,43 +133,91 @@
\fontspec_update_fontid:n {-kern}
\fontspec_update_featstr:n {-kern}
}
- \ltj_fontspec_if_liiikeys:TF {
- \tl_set:Nn \g_fontspec_encoding_tl {JY3}
- } {
- \tl_set:Nn \zf@enc {JY3}
- }
+ \tl_set:Nn \g_fontspec_encoding_tl {JY3}
\tl_set:Nx \g_fontspec_default_fontopts_tl
- {JFM=ujis,Scale=\fp_use:N \g_ltj_fontspec_scale_fp,Kerning=Off,\g_ltj_fontspec_default_fontopts_tl}
+ {JFM=ujis, Scale=\fp_use:N \g_ltj_fontspec_scale_fp,
+ Kerning=Off, \g_ltj_fontspec_default_fontopts_tl}
\prop_set_eq:NN \g__fontspec_fontopts_prop \g__ltj_fontspec_fontopts_prop
+ \cs_set_eq:NN \fontspec_make_font_shapes:nnnn \ltj_fontspec_make_font_shapes:nnnn
\cs_set_eq:NN \DeclareFontFamily \DeclareKanjiFamily
\fontspec_select:nn{#1}{#2}
\group_end:
- \ltj_fontspec_if_liiikeys:F {
- \tl_set_eq:NN \l_fontspec_family_tl \zf@family
- }
}
-\cs_new:Nn \ltj_fontspec_set_family:Nnn {
+\cs_new:Nn \__ltj_fontspec_set_family:Nnn {
\ltj_fontspec_select:nn{#2}{#3}
\tl_set_eq:NN #1 \l_fontspec_family_tl
}
+\cs_set_eq:NN \__ltj_orig_fontspec_make_font_shapes:nnnn \fontspec_make_font_shapes:nnnn
+\cs_set_eq:NN \__ltj_fontspec_orig_DeclareFontShape \DeclareFontShape
+\cs_new:Nn \ltj_fontspec_make_font_shapes:nnnn {
+ \__ltj_orig_fontspec_make_font_shapes:nnnn {#1} {#2} {#3} {#4}
+ \group_begin:
+ %% Parse font features. However, we have to avoid redefine already defined shape.
+ \__fontspec_load_fontname:n {#1}
+ \cs_set_eq:NN \DeclareFontShape \use_none:nnnnnn
+ \fontspec_declare_shape:nnn {#2}{#3}
+ { \quark_if_no_value:NF \l__fontspec_fontopts_clist {\l__fontspec_fontopts_clist,} #4 }
+ \cs_set_eq:NN \DeclareFontShape \__ltj_fontspec_orig_DeclareFontShape
+ %%
+ \clist_if_empty:NF \l_ltj_fontspec_altfont_clist {
+ \int_gzero:N \g_ltj_fontspec_altnumber_int
+ \clist_map_inline:Nn \l_ltj_fontspec_altfont_clist {
+ \tl_clear:N \l_ltj_fontspec_altrange_tl
+ \tl_set:Nn \l_ltj_fontspec_altname_tl { #1 }
+ \tl_set:Nn \l_tmpa_tl { #1 }
+
+ \keys_set_known:nxN {fontspec-ltjaltfont} { \exp_after:wN \use:n ##1 }
+ \l_ltj_fontspec_altfont_leftover_clist
+
+ \tl_if_empty:NT \l_ltj_fontspec_altrange_tl {
+ \msg_warning:nnn {luatexja-fontspec} {altfont-ignored-by-norange} { ##1 }
+ } {
+ \bool_if:nTF {
+ \tl_if_eq_p:NN \l_ltj_fontspec_altname_tl \l_tmpa_tl
+ &&
+ \tl_if_empty_p:N \l_ltj_fontspec_altfont_leftover_clist
+ } {
+ \msg_warning:nnn {luatexja-fontspec} {altfont-ignored-by-rangeonly} { ##1 }
+ } {
+ \group_begin:
+ \__fontspec_load_fontname:n { \l_ltj_fontspec_altname_tl }
+ \fontspec_declare_shape:nnn {#2}
+ {#3 _ alt \int_use:N \g_ltj_fontspec_altnumber_int }
+ {
+ \quark_if_no_value:NF \l__fontspec_fontopts_clist {\l__fontspec_fontopts_clist,}
+ #4 , \l_ltj_fontspec_altfont_leftover_clist
+ }
+ \group_end:
+ \DeclareAlternateKanjiFont
+ {JY3}{ \l_fontspec_family_tl }{#2}{#3}%
+ {JY3}{ \l_fontspec_family_tl }{#2}
+ { #3 _alt \int_use:N \g_ltj_fontspec_altnumber_int }
+ { \l_ltj_fontspec_altrange_tl }
+ \int_gincr:N \g_ltj_fontspec_altnumber_int
+ }
+ }
+ }
+ }
+ \group_end:
+ }
%%%%%%%% User commands
\DeclareDocumentCommand \jfontspec { O{} m } {
- \ltj_fontspec_set_family:Nnn \k@family {#1}{#2}
+ \__ltj_fontspec_set_family:Nnn \k@family {#1}{#2}
\selectfont
\ignorespaces
}
\DeclareDocumentCommand \setmainjfont { O{} m } {
- \ltj_fontspec_set_family:Nnn \mcdefault {#1}{#2}
+ \__ltj_fontspec_set_family:Nnn \mcdefault {#1}{#2}
\DeclareSymbolFont{mincho}{JY3}{\l_fontspec_family_tl}{m}{n}
\SetSymbolFont{mincho}{bold}{JY3}{\l_fontspec_family_tl}{bx}{n}
\normalfont
}
\DeclareDocumentCommand \setsansjfont { O{} m } {
- \ltj_fontspec_set_family:Nnn \gtdefault {#1}{#2}
+ \__ltj_fontspec_set_family:Nnn \gtdefault {#1}{#2}
\DeclareMathAlphabet{\mathgt}{JY3}{\l_fontspec_family_tl}{m}{n}
\normalfont
}
@@ -160,7 +267,7 @@
\group_end:
\fontfamily\l_fontspec_family_tl\selectfont
\else
- \ltj_fontspec_warning:n {addjfontfeatures-ignored}
+ \msg_warning:nn {luatexja-fontspec} {addjfontfeatures-ignored}
\fi
\ignorespaces
}
@@ -231,5 +338,4 @@
\fi
\fi}
-
\endinput
diff --git a/Master/texmf-dist/tex/luatex/luatexja/addons/luatexja-ruby.sty b/Master/texmf-dist/tex/luatex/luatexja/addons/luatexja-ruby.sty
new file mode 100644
index 00000000000..57e58947418
--- /dev/null
+++ b/Master/texmf-dist/tex/luatex/luatexja/addons/luatexja-ruby.sty
@@ -0,0 +1,207 @@
+%
+% luatexja-ruby.sty
+%
+
+% LaTeX only!
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{luatexja-ruby}[2014/03/28 v0.21]
+\RequirePackage{luatexja}
+
+%%------------------
+\newluatexattribute\ltj@rubyattr
+\ltj@rubyattr=0
+\RequireLuaTeXjaSubmodule{ruby}
+
+% ltjset/getparameter への追加設定
+% これらは段落単位の設定.
+
+%% 引数:ルビ全角を単位とした実数
+%% この文字への pre-, post-intrusion の許容量
+\define@key[ltj]{japaram}{rubypreintrusion}{%
+ \expandafter\ltj@@set@stack@real#1:{RIPRE}{0}{0x7FFFFFFF}}
+\define@key[ltj]{japaram}{rubypostintrusion}{%
+ \expandafter\ltj@@set@stack@real#1:{RIPOST}{0}{0x7FFFFFFF}}
+\def\ltj@@set@stack@real#1,#2:#3#4#5{%
+ \directlua{luatexja.stack.set_stack_perchar(luatexja.stack_table_index.#3,
+ \ltj@safe@num@or\ltj@defnum{#1},\ltj@safe@real{#2},#4,#5)}}
+
+% ルビ用のキー設定
+\def\ltj@@rkeydef#1{
+ \define@key[ltj]{ruby}{#1}{\expandafter\def\csname ltj@@rubyip@#1\endcsname{##1}}
+}
+%% attr_ruby_mode
+%% bit 0: intrusion を有効にするか(1: 有効)
+%% bit 1: 前後の intrusion 許容量を小さい方に揃える (1: yes)
+%% bit 2, 3: intrusion をどう使って親文字を配置するか
+%% 00: intrusion なしでとりあえず計算し,左右の突出分を進入に割り当てる
+%% 01: pre-intrusion でまかなえるだけまかない,無理なら post- も使う
+%% 10: post を優先
+%% 11: 2 min (pre,post) までは pre, post に均等配分しようとする
+%% >=01 で,intrusion で賄えきれなかった場合はいつものように伸長する.
+%% bit 4: 熟語ルビの際の処理方法(0: 常にグループ,1: 可能な限りブロックごとに)
+%% ↑bit 4 は今は無効
+\ltj@@rkeydef{mode}
+%% intrusion 量強制固定(bit 0, bit 1 より優先,負数で「自動」)
+%% attr は sp 単位だが,ユーザーはルビ全角単位で指定する
+%% attr_ruby_maxprep, attr_ruby_maxpostp
+\ltj@@rkeydef{pre}
+\ltj@@rkeydef{post}
+%% 親文字伸長の際の比,{0}{1}{1} などと0--7 の数 3 つで指定
+%% attr_ruby_stretch (bol left,middle,right)(eol)(middle) 27-bits
+\ltj@@rkeydef{stretchbol} % 行頭形
+\ltj@@rkeydef{stretcheol} % 行末形
+\ltj@@rkeydef{stretch} % 行中形
+%% ルビが伸長するときの比 {1}{2}{1} などと0--7 の数 3 つで指定
+%% attr_ruby_mode 上位部分
+\ltj@@rkeydef{stretchruby}
+%% ルビ<親のとき,ルビと親文字の端の最大値
+%% attr_ruby_maxmargin
+%% attr は sp 単位だが,ユーザーは親文字全角単位で指定
+\ltj@@rkeydef{maxmargin}
+%% ルビと親文字の垂直方向の空き
+%% attr_ruby_intergap
+%% attr は sp 単位だが,ユーザーは親文字全角単位で指定
+\ltj@@rkeydef{intergap}
+
+\ltj@@rkeydef{kenten}%% 圏点文字
+\ltj@@rkeydef{fontcmd}%% フォント
+\define@boolkey[ltj]{ruby}{rubysmash}[true]{}
+
+
+%%%%%%%% setkeys の別名
+\protected\def\ltjsetruby{\setkeys[ltj]{ruby}}
+
+% ここからは ruby マクロ内でなんとかされる事項
+%% ルビと親文字の大きさの比
+\ltj@@rkeydef{size}
+
+% 中つき用簡易設定.
+\define@key[ltj]{ruby}{naka}[none]{\setkeys[ltj]{ruby}{mode=1, stretch=121, stretchruby=121}}
+% 肩つき用簡易設定.
+\define@key[ltj]{ruby}{kata}[none]{\setkeys[ltj]{ruby}{mode=9, stretch=121, stretchruby=001}}
+
+%%%%%%%% 補助関数
+
+% Lua ソースに渡す table 生成
+\def\ltj@@ruby@create@table#1{% #1: ルビ全角
+ \string{
+ rubyzw = \ltj@safe@dimen{#1},
+ maxmargin = \ltj@safe@dimen{\ltj@@rubyip@maxmargin\zw},
+ pre = \ltj@safe@dimen{\ltj@@rubyip@pre#1},
+ post = \ltj@safe@dimen{\ltj@@rubyip@post#1},
+ intergap = \ltj@safe@dimen{\ltj@@rubyip@intergap\zw},
+ stretch
+ = 262144 * \expandafter\ltj@@ruby@cts\ltj@@rubyip@stretchbol
+ + 512 * \expandafter\ltj@@ruby@cts\ltj@@rubyip@stretcheol
+ + \expandafter\ltj@@ruby@cts\ltj@@rubyip@stretch,
+ mode
+ = 2097152 * \expandafter\ltj@@ruby@cts\ltj@@rubyip@stretchruby
+ + \ltj@safe@num{\ltj@@rubyip@mode}
+ + 1048576 * \ifltj@ruby@rubysmash1\else0\fi
+ \string}
+}
+%%%
+%%% 1098765432109876543210976543210
+%%% |st_ruby|! |--| ← mode
+\def\ltj@@ruby@cts#1#2#3{%
+ ((\ltj@safe@num{#1}) * 64 + (\ltj@safe@num{#2}) * 8 + \ltj@safe@num{#3})%
+}
+
+
+%%%%%%%% ZR さんの PXrubrica パッケージ中のコードから引用・改変
+% \pxrr@decompbar: a|bc -> \ltj@@ruby@mark{a}\ltj@@ruby@mark{bc}
+\let\pxrr@res\empty
+\def\pxrr@ifx#1{%
+ \ifx#1\expandafter\@firstoftwo
+ \else\expandafter\@secondoftwo
+ \fi
+}
+\def\pxrr@nil{\noexpand\pxrr@nil}
+\def\pxrr@end{\noexpand\pxrr@end}
+\def\pxrr@appto#1#2{%
+ \expandafter\def\expandafter#1\expandafter{#1#2}%
+}
+\def\pxrr@decompbar#1{%
+ \let\pxrr@res\@empty
+ \pxrr@decompbar@loopa\pxrr@nil#1|\pxrr@end|%
+}
+\def\pxrr@decompbar@loopa#1|{%
+ \expandafter\pxrr@decompbar@loopb\expandafter{\@gobble#1}%
+}
+\def\pxrr@decompbar@loopb#1{%
+ \pxrr@decompbar@loopc#1\relax\pxrr@nil{#1}%
+}
+\def\pxrr@decompbar@loopc#1#2\pxrr@nil#3{%
+ \pxrr@ifx{#1\pxrr@end}{}{%
+ \ifx\pxrr@res\@empty
+ \def\pxrr@res{\ltj@@ruby@mark}%
+ \else
+ \pxrr@appto\pxrr@res{\ltj@@ruby@mark}%
+ \fi
+ \pxrr@appto\pxrr@res{{#3}}%
+ \pxrr@decompbar@loopa\pxrr@nil
+ }%
+}
+%%%%%%%% ここまで
+
+%%%%%%%% TeX command
+\protected\def\ltjruby{\@ifnextchar[\ltj@@ruby{\ltj@@ruby[]}}%]
+\AtBeginDocument{\ifdefined\ruby\else\let\ruby=\ltjruby\fi}
+\def\ltj@@ruby[#1]#2#3{{% #1: option #2: 親文字群,#3: ルビ文字列群,共に| 区切り
+ \setkeys[ltj]{ruby}{#1}%
+ \directlua{ruby_tmplist_r = \string{\string}; ruby_tmplist_p = \string{\string}}%
+ \leavevmode\dimen0=\f@size pt\dimen1=\ltj@@rubyip@size\dimen0%
+ % 引数展開,テーブルにセット
+ \pxrr@decompbar{#2}{\let\ltj@@ruby@mark\ltj@@ruby@sp\pxrr@res}%
+ \pxrr@decompbar{#3}{\let\ltj@@ruby@mark\ltj@@ruby@sr\pxrr@res}%
+ {\fontsize{\ltj@@rubyip@size\dimen0}\z@\selectfont\ltj@@rubyip@fontcmd\global\dimen1=\zw}%
+ \directlua{%
+ luatexja.ruby.texiface(\ltj@@ruby@create@table{\dimen1},
+ ruby_tmplist_r, ruby_tmplist_p)}%
+}}
+
+\def\ltj@@ruby@sr#1{%
+ \setbox0=\hbox{\fontsize{\dimen1}\z@\ltj@@rubyip@fontcmd\selectfont#1}%
+ \directlua{table.insert(ruby_tmplist_r, luatexja.ruby.cpbox())}%
+}
+\def\ltj@@ruby@sp#1{%
+ \setbox0=\hbox{\selectfont#1}%
+ \directlua{table.insert(ruby_tmplist_p, luatexja.ruby.cpbox())}%
+}
+
+\protected\def\ltjkenten{\@ifnextchar[\ltj@@kenten{\ltj@@kenten[]}}%]
+\let\kenten=\ltjkenten
+\def\ltj@@kenten[#1]#2{{%
+ \setkeys[ltj]{ruby}{#1, stretchruby=101}%
+ \@tfor\ltj@@kenten@temp:=#2\do{\ltj@@ruby[]{\ltj@@kenten@temp}{\ltj@@rubyip@kenten}}%
+}}
+
+% 初期値.要調整
+%% ひらがな
+\count@="3040\loop\relax\ifnum \count@<"30A0
+ \ltjsetparameter{rubypreintrusion={\the\count@,1},
+ rubypostintrusion={\the\count@,1}}
+ \advance\count@1\repeat
+%% 「」
+\ltjsetparameter{rubypreintrusion={`「,1},
+ rubypostintrusion={`」,1}}
+%% ,、
+\ltjsetparameter{rubypreintrusion={`,,1},
+ rubypostintrusion={`,,1}}
+\ltjsetparameter{rubypreintrusion={`、,1},
+ rubypostintrusion={`、,1}}
+%% ・
+\ltjsetparameter{rubypreintrusion={`・,1},
+ rubypostintrusion={`・,1}}
+%% 段落インデント部分
+\ltjsetparameter{rubypreintrusion={-1,1}}
+
+\setkeys[ltj]{ruby}{
+ pre=-1, post=-1, mode=1,
+ stretchruby={1}{2}{1}, stretch = {1}{2}{1},
+ stretchbol={0}{1}{1}, stretcheol={1}{1}{0},
+ maxmargin=0.5, size=0.5, intergap=0, rubysmash=false,
+ kenten=\ltjalchar`•, fontcmd=\relax
+}
+
+\endinput
diff --git a/Master/texmf-dist/tex/luatex/luatexja/ltj-base.lua b/Master/texmf-dist/tex/luatex/luatexja/ltj-base.lua
index 495f185fed2..0275521ec4a 100644
--- a/Master/texmf-dist/tex/luatex/luatexja/ltj-base.lua
+++ b/Master/texmf-dist/tex/luatex/luatexja/ltj-base.lua
@@ -210,11 +210,11 @@ do
p, m = nil, t[3]
end
res.width = tex.sp(t[1])
- if t[3] then
- res.stretch, res.stretch_order = parse_dimen(t[3])
+ if p then
+ res.stretch, res.stretch_order = parse_dimen(p)
end
- if t[5] then
- res.shrink, res.shrink_order = parse_dimen(t[5])
+ if m then
+ res.shrink, res.shrink_order = parse_dimen(m)
end
end
return res
diff --git a/Master/texmf-dist/tex/luatex/luatexja/ltj-jfmglue.lua b/Master/texmf-dist/tex/luatex/luatexja/ltj-jfmglue.lua
index 99fcd66069f..eb0174729e3 100644
--- a/Master/texmf-dist/tex/luatex/luatexja/ltj-jfmglue.lua
+++ b/Master/texmf-dist/tex/luatex/luatexja/ltj-jfmglue.lua
@@ -941,10 +941,13 @@ do
local lp, par_indented, lpi, lps = head, 'boxbdd', getid(head), getsubtype(head)
while lp and ((lpi==id_whatsit and lps~=sid_user)
or ((lpi==id_hlist) and (lps==3))) do
- if (lpi==id_hlist) and (lps==3) then par_indented = 'parbdd' end
+ if (lpi==id_hlist) and (lps==3) then
+ Np.char, par_indented = 'parbdd', 'parbdd'
+ Np.width = getfield(lp, 'width')
+ end
lp=node_next(lp); lpi, lps = getid(lp), getsubtype(lp) end
return lp, node_tail(head), par_indented
- else
+ else
return head, nil, 'boxbdd'
end
end
diff --git a/Master/texmf-dist/tex/luatex/luatexja/ltj-ruby.lua b/Master/texmf-dist/tex/luatex/luatexja/ltj-ruby.lua
new file mode 100644
index 00000000000..a84256cd45f
--- /dev/null
+++ b/Master/texmf-dist/tex/luatex/luatexja/ltj-ruby.lua
@@ -0,0 +1,774 @@
+--
+-- ltj-ruby.lua
+--
+luatexbase.provides_module({
+ name = 'luatexja.ruby',
+ date = '2014/04/02',
+ description = 'Ruby',
+})
+module('luatexja.ruby', package.seeall)
+local err, warn, info, log = luatexbase.errwarinf(_NAME)
+
+luatexja.load_module('stack'); local ltjs = luatexja.stack
+
+local Dnode = node.direct or node
+
+local nullfunc = function(n) return n end
+local to_node = (Dnode ~= node) and Dnode.tonode or nullfunc
+local to_direct = (Dnode ~= node) and Dnode.todirect or nullfunc
+
+local setfield = (Dnode ~= node) and Dnode.setfield or function(n, i, c) n[i] = c end
+local getfield = (Dnode ~= node) and Dnode.getfield or function(n, i) return n[i] end
+local getid = (Dnode ~= node) and Dnode.getid or function(n) return n.id end
+local getfont = (Dnode ~= node) and Dnode.getfont or function(n) return n.font end
+local getlist = (Dnode ~= node) and Dnode.getlist or function(n) return n.head end
+local getchar = (Dnode ~= node) and Dnode.getchar or function(n) return n.char end
+local getsubtype = (Dnode ~= node) and Dnode.getsubtype or function(n) return n.subtype end
+
+local node_new = Dnode.new
+local node_remove = luatexja.Dnode_remove -- Dnode.remove
+local node_next = (Dnode ~= node) and Dnode.getnext or node.next
+local node_copy, node_free, node_tail = Dnode.copy, Dnode.free, Dnode.tail
+local has_attr, set_attr = Dnode.has_attribute, Dnode.set_attribute
+local insert_before, insert_after = Dnode.insert_before, Dnode.insert_after
+
+local id_hlist = node.id('hlist')
+local id_vlist = node.id('vlist')
+local id_rule = node.id('rule')
+local id_whatsit = node.id('whatsit')
+local id_glue = node.id('glue')
+local id_kern = node.id('kern')
+local id_penalty = node.id('penalty')
+local id_glue_spec = node.id('glue_spec')
+local sid_user = node.subtype('user_defined')
+local ltjs_get_stack_table = luatexja.stack.get_stack_table
+local id_pbox_w = 258 -- cluster which consists of a whatsit
+
+local attr_icflag = luatexbase.attributes['ltj@icflag']
+-- ルビ処理用の attribute は他のやつの流用なので注意!
+-- 進入許容量 (sp)
+local attr_ruby_maxprep = luatexbase.attributes['ltj@charclass']
+local attr_ruby_maxpostp = luatexbase.attributes['ltj@kcat0']
+local attr_ruby_maxmargin = luatexbase.attributes['ltj@kcat1']
+local attr_ruby_stretch = luatexbase.attributes['ltj@kcat2']
+local attr_ruby_mode = luatexbase.attributes['ltj@kcat3']
+local attr_ruby_id = luatexbase.attributes['ltj@kcat4'] -- uniq id
+local attr_ruby_intergap = luatexbase.attributes['ltj@kcat5']
+local attr_ruby = luatexbase.attributes['ltj@rubyattr']
+-- ルビ内部処理用,以下のようにノードによって使われ方が異なる
+-- * (whatsit) では JAglue 処理時に,
+-- 「2つ前のクラスタもルビ」 ==> そのルビクラスタの id
+-- otherwise ==> unset
+-- * (whatsit).value node ではルビ全角の値(sp単位)
+-- * 行分割で whatsit の前後に並ぶノードでは,「何番目のルビ関連ノード」か
+-- * (whatsit).value に続く整形済み vbox たちでは post_intrusion の値
+local cat_lp = luatexbase.catcodetables['latex-package']
+
+local round, floor = tex.round, math.floor
+local min, max = math.min, math.max
+
+luatexja.userid_table.RUBY_PRE = luatexbase.newuserwhatsitid('ruby_pre', 'luatexja')
+luatexja.userid_table.RUBY_POST = luatexbase.newuserwhatsitid('ruby_post', 'luatexja')
+local RUBY_PRE = luatexja.userid_table.RUBY_PRE
+local RUBY_POST = luatexja.userid_table.RUBY_POST
+
+----------------------------------------------------------------
+-- TeX interface 0
+----------------------------------------------------------------
+if Dnode ~= node then
+ function cpbox() return node_copy(Dnode.getbox(0)) end
+else
+ function cpbox() return node.copy(tex.box[0]) end
+end
+
+
+----------------------------------------------------------------
+-- 補助関数群 1
+----------------------------------------------------------------
+
+local function gauss(coef)
+ -- #coef 式,#coef 変数の連立1次方程式系を掃きだし法で解く.
+ local deg = #coef
+ for i = 1, deg do
+ if coef[i][i]==0 then
+ for j = i+1, deg do
+ if coef[j][i]~=0 then
+ coef[i], coef[j] = coef[j], coef[i]; break
+ end
+ end
+ end
+ for j = 1,deg do
+ local d = coef[i][i];
+ if j~=i then
+ local e = coef[j][i]
+ for k = 1, deg+1 do coef[j][k] = coef[j][k] - e*coef[i][k]/d end
+ else
+ for k = 1, deg+1 do coef[i][k] = coef[i][k]/d end
+ end
+ end
+ end
+end
+
+local function solve_1(coef)
+ local a, b, c = coef[1][4], coef[2][4], coef[3][4]
+ coef[1][4], coef[2][4], coef[3][4] = c-b, a+b-c, c-a
+ return coef
+end
+
+local function solve_2(coef)
+ local a, b, c, d, e = coef[1][6], coef[2][6], coef[3][6], coef[4][6], coef[5][6]
+ coef[1][6], coef[2][6], coef[3][6], coef[4][6], coef[5][6]
+ = e-c, a+c-e, e-a-d, b+d-e, e-b
+ return coef
+end
+
+
+-- 実行回数 + ルビ中身 から uniq_id を作る関数
+old_break_info = {} -- public, 前 run 時の分割情報
+local make_uniq_id
+do
+ local exec_count = 0
+ make_uniq_id = function (w)
+ exec_count = exec_count + 1
+ return exec_count
+ end
+end
+
+-- concatenation of boxes: reusing nodes
+-- ルビ組版が行われている段落/hboxでの設定が使われる.
+-- ルビ文字を格納しているボックスでの設定ではない!
+local function concat(f, b)
+ if f then
+ if b then
+ local h = getlist(f)
+ setfield(node_tail(h), 'next', getlist(b))
+ setfield(f, 'head', nil); node_free(f)
+ setfield(b, 'head', nil); node_free(b)
+ return Dnode.hpack(luatexja.jfmglue.main(h,false))
+ else
+ return f
+ end
+ elseif b then
+ return b
+ else
+ local h = node_new(id_hlist)
+ setfield(h, 'subtype', 0)
+ setfield(h, 'width', 0)
+ setfield(h, 'height', 0)
+ setfield(h, 'depth', 0)
+ setfield(h, 'glue_set', 0)
+ setfield(h, 'glue_order', 0)
+ setfield(h, 'head', nil)
+ return h
+ end
+end
+
+local function expand_3bits(num)
+ local t = {}; local a = num
+ for i = 1, 10 do
+ t[i] = a%8; a = floor(a/8)
+ end
+ return t
+end
+----------------------------------------------------------------
+-- 補助関数群 2
+----------------------------------------------------------------
+
+-- box の中身のノードは再利用される
+local enlarge
+do
+ local FROM_JFM = luatexja.icflag_table.FROM_JFM
+ local PROCESSED = luatexja.icflag_table.PROCESSED
+ local KANJI_SKIP = luatexja.icflag_table.KANJI_SKIP
+ local KANJI_SKIP_JFM = luatexja.icflag_table.KANJI_SKIP_JFM
+ local XKANJI_SKIP = luatexja.icflag_table.XKANJI_SKIP
+ local XKANJI_SKIP_JFM= luatexja.icflag_table.XKANJI_SKIP_JFM
+ enlarge = function (box, new_width, pre, middle, post, prenw, postnw)
+ -- pre, middle, post: 伸縮比率
+ -- prenw, postnw: 前後の自然長 (sp)
+ local h = getlist(box);
+ local hh, hd = getfield(box, 'height'), getfield(box, 'depth')
+ local hx = h
+ while hx do
+ local hic = has_attr(hx, attr_icflag)
+ if (hic == KANJI_SKIP) or (hic == KANJI_SKIP_JFM)
+ or (hic == XKANJI_SKIP) or (hic == XKANJI_SKIP_JFM)
+ or ((hic<=FROM_JFM+2) and (hic>=FROM_JFM-2)) then
+ -- この 5 種類の空白をのばす
+ if getid(hx) == id_kern then
+ local k = node_new(id_glue)
+ local ks = node_new(id_glue_spec)
+ setfield(ks, 'width', getfield(hx, 'kern'))
+ setfield(ks, 'stretch_order', 2)
+ setfield(ks, 'stretch', round(middle*65536))
+ setfield(ks, 'shrink_order', 0); setfield(ks, 'shrink', 0)
+ setfield(k, 'subtype', 0); setfield(k, 'spec', ks)
+ h = insert_after(h, hx, k);
+ h = node_remove(h, hx); node_free(hx); hx = k
+ else -- glue
+ local old_spec = getfield(hx, 'spec')
+ local ks = node_copy(old_spec)
+ setfield(ks, 'stretch_order', 2)
+ setfield(ks, 'stretch', round(middle*65536))
+ setfield(ks, 'shrink_order', 0); setfield(ks, 'shrink', 0)
+ setfield(hx, 'spec', ks)
+ -- decrease old_spec's reference count
+ local b = node_new(id_glue)
+ setfield(b, 'spec', old_spec); node_free(b)
+ end
+ end
+ hx = node_next(hx)
+ end
+ -- 先頭の空白を挿入
+ local k = node_new(id_glue);
+ local ks = node_new(id_glue_spec)
+ setfield(ks, 'width', prenw)
+ setfield(ks, 'stretch_order', 2); setfield(ks, 'stretch', round(pre*65536))
+ setfield(ks, 'shrink_order', 0); setfield(ks, 'shrink', 0)
+ setfield(k, 'subtype', 0); setfield(k, 'spec', ks)
+ h = insert_before(h, h, k);
+ -- 末尾の空白を挿入
+ local k = node_new(id_glue);
+ local ks = node_new(id_glue_spec);
+ setfield(ks, 'width', postnw)
+ setfield(ks, 'stretch_order', 2); setfield(ks, 'stretch', round(post*65536))
+ setfield(ks, 'shrink_order', 0); setfield(ks, 'shrink', 0)
+ setfield(k, 'subtype', 0);setfield(k, 'spec', ks)
+ insert_after(h, node_tail(h), k);
+ -- hpack
+ setfield(box, 'head', nil); node_free(box)
+ box = Dnode.hpack(h, new_width, 'exactly')
+ setfield(box, 'height', hh)
+ setfield(box, 'depth', hd)
+ return box
+ end
+end
+
+
+----------------------------------------------------------------
+-- TeX interface
+----------------------------------------------------------------
+
+-- rtlr: ルビ部分のボックスたち r1, r2, ...
+-- rtlp: 親文字 のボックスたち p1, p2, ...
+local function texiface_low(rst, rtlr, rtlp)
+ local w = node_new(id_whatsit, sid_user)
+ setfield(w, 'type', 110); setfield(w, 'user_id', RUBY_PRE)
+ local wv = node_new(id_whatsit, sid_user)
+ setfield(w, 'value', to_node(wv))
+ setfield(wv, 'type', 100)
+ setfield(wv, 'value', floor(#rtlr))
+ set_attr(wv, attr_ruby, rst.rubyzw)
+ set_attr(wv, attr_ruby_maxmargin, rst.maxmargin)
+ set_attr(wv, attr_ruby_maxprep, rst.pre)
+ set_attr(wv, attr_ruby_maxpostp, rst.post)
+ set_attr(wv, attr_ruby_intergap, rst.intergap)
+ set_attr(wv, attr_ruby_stretch, rst.stretch)
+ set_attr(wv, attr_ruby_mode, rst.mode)
+ local n = wv
+ for i = 1, #rtlr do
+ _, n = insert_after(wv, n, rtlr[i])
+ _, n = insert_after(wv, n, rtlp[i])
+ end
+ -- w.value: (whatsit) .. r1 .. p1 .. r2 .. p2
+ Dnode.write(w); return w,wv
+end
+
+-- rst: table
+function texiface(rst, rtlr, rtlp)
+ if #rtlr ~= #rtlp then
+ for i=1, #rtlr do node_free(rtlr[i]) end
+ for i=1, #rtlp do node_free(rtlp[i]) end
+ luatexja.base.package_error('luatexja-ruby',
+ 'Group count mismatch between the ruby and\n' ..
+ 'the body (' .. #rtlr .. ' != ' .. #rtlp .. ').',
+ '')
+ else
+ local f = true
+ for i = 1,#rtlr do
+ if getfield(rtlr[i], 'width') > getfield(rtlp[i], 'width') then
+ f = false; break
+ end
+ end
+ if f then -- モノルビ * n
+ local r,p = {true}, {true}
+ for i = 1,#rtlr do
+ r[1] = rtlr[i]; p[1] = rtlp[i]; texiface_low(rst, r, p)
+ end
+ else
+ local w, wv = texiface_low(rst, rtlr, rtlp)
+ local id = make_uniq_id(w)
+ set_attr(wv, attr_ruby_id, id)
+ end
+ end
+end
+
+----------------------------------------------------------------
+-- pre_line_break
+----------------------------------------------------------------
+
+-- r, p の中身のノードは再利用される
+local function enlarge_parent(r, p, ppre, pmid, ppost, mapre, mapost, intmode)
+ -- r: ルビ部分の格納された box,p: 同,親文字
+ local rwidth = getfield(r, 'width')
+ local sumprot = rwidth - getfield(p, 'width') -- >0
+ local pre_intrusion, post_intrusion
+ if intmode == 0 then -- とりあえず組んでから決める
+ p = enlarge(p, rwidth, ppre, pmid, ppost, 0, 0)
+ pre_intrusion = min(mapre, round(ppre*getfield(p, 'glue_set')*65536))
+ post_intrusion = min(mapost, round(ppost*getfield(p, 'glue_set')*65536))
+ elseif intmode == 1 then
+ pre_intrusion = min(mapre, sumprot);
+ post_intrusion = min(mapost, max(sumprot-pre_intrusion, 0))
+ p = enlarge(p, rwidth, ppre, pmid, ppost, pre_intrusion, post_intrusion)
+ elseif intmode == 2 then
+ post_intrusion = min(mapost, sumprot);
+ pre_intrusion = min(mapre, max(sumprot-post_intrusion, 0))
+ p = enlarge(p, rwidth, ppre, pmid, ppost, pre_intrusion, post_intrusion)
+ else -- intmode == 3
+ local n = min(mapre, mapost)*2
+ if n < sumprot then
+ pre_intrusion = n/2; post_intrusion = n/2
+ else
+ pre_intrusion = floor(sumprot/2); post_intrusion = sumprot - pre_intrusion
+ end
+ p = enlarge(p, rwidth, ppre, pmid, ppost, pre_intrusion, post_intrusion)
+ pre_intrusion = min(mapre, pre_intrusion + round(ppre*getfield(p, 'glue_set')*65536))
+ post_intrusion = min(mapost, post_intrusion + round(ppost*getfield(p, 'glue_set')*65536))
+ end
+ setfield(r, 'shift', -pre_intrusion)
+ local rwidth = rwidth - pre_intrusion - post_intrusion
+ setfield(r, 'width', rwidth)
+ setfield(p, 'width', rwidth)
+ local ps = getfield(getlist(p), 'spec')
+ setfield(ps, 'width', getfield(ps, 'width') - pre_intrusion)
+ return r, p, post_intrusion
+end
+
+-- ルビボックスの生成(単一グループ)
+-- returned value: <new box>, <ruby width>, <post_intrusion>
+local max_margin
+local function new_ruby_box(r, p, ppre, pmid, ppost,
+ mapre, mapost, imode, rgap)
+ local post_intrusion = 0
+ local intmode = imode%4
+ local rpre, rmid, rpost, rsmash
+ imode = floor(imode/262144); rsmash = (imode%2 ==1)
+ imode = floor(imode/2); rpost = imode%8;
+ imode = (imode-rpost)/8; rmid = imode%8;
+ imode = (imode-rmid)/8; rpre = imode%8
+ if getfield(r, 'width') > getfield(p, 'width') then -- change the width of p
+ r, p, post_intrusion = enlarge_parent(r, p, ppre, pmid, ppost, mapre, mapost, intmode)
+ elseif getfield(r, 'width') < getfield(p, 'width') then -- change the width of r
+ r = enlarge(r, getfield(p, 'width'), rpre, rmid, rpost, 0, 0)
+ post_intrusion = 0
+ local need_repack = false
+ -- margin が大きくなりすぎた時の処理
+ if round(rpre*getfield(r, 'glue_set')*65536) > max_margin then
+ local ps = getfield(getlist(r), 'spec'); need_repack = true
+ setfield(ps, 'width', max_margin)
+ setfield(ps, 'stretch', 1) -- 全く伸縮しないのも困る
+ end
+ if round(rpost*getfield(r, 'glue_set')*65536) > max_margin then
+ local ps = getfield(node_tail(getlist(r)), 'spec'); need_repack = true
+ setfield(ps, 'width', max_margin)
+ setfield(ps, 'stretch', 1) -- 全く伸縮しないのも困る
+ end
+ if need_repack then
+ local rt = r
+ r = Dnode.hpack(getlist(r), getfield(r, 'width'), 'exactly')
+ setfield(rt, 'head', nil); node_free(rt);
+ end
+ end
+ local a, k = node_new(id_rule), node_new(id_kern)
+ setfield(a, 'width', 0); setfield(a, 'height', 0)
+ setfield(a, 'depth', 0); setfield(k, 'kern', rgap)
+ insert_after(r, r, a); insert_after(r, a, k);
+ insert_after(r, k, p); setfield(p, 'next', nil)
+ a = Dnode.vpack(r); setfield(a, 'shift', 0)
+ set_attr(a, attr_ruby, post_intrusion)
+ if rsmash or getfield(a, 'height')<getfield(p, 'height') then
+ local k = node_new(id_kern)
+ setfield(k, 'kern', -getfield(a, 'height')+getfield(p, 'height'))
+ setfield(a, 'head', k); insert_before(r, r, k)
+ setfield(a, 'height', getfield(p, 'height'))
+ end
+
+ return a, getfield(r, 'width'), post_intrusion
+end
+
+
+-- High-level routine in pre_linebreak_filter
+local post_intrusion_backup
+local max_allow_pre, max_allow_post
+
+
+-- 中付き熟語ルビ,cmp containers
+-- 「文字の構成を考えた」やつはどうしよう
+local function pre_low_cal_box(w, cmp)
+ local rb = {}
+ local pb = {}
+ local kf = {}
+ -- kf[i] : container 1--i からなる行末形
+ -- kf[cmp+i] : container i--cmp からなる行頭形
+ -- kf[2cmp+1] : 行中形
+ local wv = getfield(w, 'value')
+ local mdt -- nt*: node temp
+ local coef = {} -- 連立一次方程式の拡大係数行列
+ local rtb = expand_3bits(has_attr(wv, attr_ruby_stretch))
+ local rgap = has_attr(wv, attr_ruby_intergap)
+ local intmode = floor(has_attr(wv, attr_ruby_mode)/4)
+
+ -- node list 展開・行末形の計算
+ local nt, nta, ntb = wv, nil, nil -- nt*: node temp
+ for i = 1, cmp do
+ nt = node_next(nt); rb[i] = nt; nta = concat(nta, node_copy(nt))
+ nt = node_next(nt); pb[i] = nt; ntb = concat(ntb, node_copy(nt))
+ coef[i] = {}
+ for j = 1, 2*i do coef[i][j] = 1 end
+ for j = 2*i+1, 2*cmp+1 do coef[i][j] = 0 end
+ kf[i], coef[i][2*cmp+2]
+ = new_ruby_box(node_copy(nta), node_copy(ntb),
+ rtb[6], rtb[5], rtb[4], max_allow_pre, 0, intmode, rgap)
+ end
+ node_free(nta); node_free(ntb)
+
+ -- 行頭形の計算
+ local nta, ntb = nil, nil
+ for i = cmp,1,-1 do
+ coef[cmp+i] = {}
+ for j = 1, 2*i-1 do coef[cmp+i][j] = 0 end
+ for j = 2*i, 2*cmp+1 do coef[cmp+i][j] = 1 end
+ nta = concat(node_copy(rb[i]), nta); ntb = concat(node_copy(pb[i]), ntb)
+ kf[cmp+i], coef[cmp+i][2*cmp+2]
+ = new_ruby_box(node_copy(nta), node_copy(ntb),
+ rtb[9], rtb[8], rtb[7], 0, max_allow_post, intmode, rgap)
+ end
+
+ -- ここで,nta, ntb には全 container を連結した box が入っているので
+ -- それを使って行中形を計算する.
+ coef[2*cmp+1] = {}
+ for j = 1, 2*cmp+1 do coef[2*cmp+1][j] = 1 end
+ kf[2*cmp+1], coef[2*cmp+1][2*cmp+2], post_intrusion_backup
+ = new_ruby_box(nta, ntb, rtb[3], rtb[2], rtb[1],
+ max_allow_pre, max_allow_post, intmode, rgap)
+
+ -- w.value の node list 更新.
+ local nt = wv
+ Dnode.flush_list(node_next(wv))
+ for i = 1, 2*cmp+1 do setfield(nt, 'next', kf[i]); nt = kf[i] end
+
+ if cmp==1 then solve_1(coef)
+ elseif cmp==2 then solve_2(coef)
+ else
+ gauss(coef) -- 掃きだし法で連立方程式形 coef を解く
+ end
+ return coef
+end
+
+local first_whatsit
+do
+ local traverse_id = Dnode.traverse_id
+ function first_whatsit(n) -- n 以後で最初の whatsit
+ for h in traverse_id(id_whatsit, n) do
+ return h
+ end
+ return nil
+ end
+end
+
+-- ノード追加
+local function pre_low_app_node(head, w, cmp, coef, ht, dp)
+ -- メインの node list 更新
+ local nt, ntb = node_new(id_glue), node_new(id_glue_spec)
+ setfield(ntb, 'width', coef[1][2*cmp+2])
+ setfield(ntb, 'stretch_order', 0); setfield(ntb, 'stretch', 0)
+ setfield(ntb, 'shrink_order', 0); setfield(ntb, 'shrink', 0)
+ setfield(nt, 'subtype', 0); setfield(nt, 'spec', ntb)
+ set_attr(nt, attr_ruby, 1); set_attr(w, attr_ruby, 2)
+ head = insert_before(head, w, nt)
+ nt = w
+ for i = 1, cmp do
+ -- rule
+ local nta = node_new(id_rule);
+ setfield(nta, 'width', coef[i*2][2*cmp+2])
+ setfield(nta, 'height', ht); setfield(nta, 'depth', dp)
+ setfield(nta, 'subtype', 0)
+ insert_after(head, nt, nta)
+ set_attr(nta, attr_ruby, 2*i+1)
+ -- glue
+ nt = node_new(id_glue)
+ local ntb = node_new(id_glue_spec);
+ setfield(ntb, 'width', coef[i*2+1][2*cmp+2])
+ setfield(ntb, 'stretch_order', 0); setfield(ntb, 'stretch', 0)
+ setfield(ntb, 'shrink_order', 0); setfield(ntb, 'shrink', 0)
+ setfield(nt, 'subtype', 0); setfield(nt, 'spec', ntb)
+ set_attr(nt, attr_ruby, 2*i+2)
+ insert_after(head, nta, nt)
+ end
+ tex.setattribute('global', attr_ruby, -0x7FFFFFFF)
+ setfield(w, 'user_id', RUBY_POST)
+ return head, first_whatsit(node_next(nt))
+end
+
+local function pre_high(ahead)
+ if not ahead then return ahead end
+ local head = to_direct(ahead)
+ post_intrusion_backup = 0
+ local n = first_whatsit(head)
+ while n do
+ if getsubtype(n) == sid_user and getfield(n, 'user_id') == RUBY_PRE then
+ local nv = getfield(n, 'value')
+ max_allow_pre = has_attr(nv, attr_ruby_maxprep) or 0
+ local atr = has_attr(n, attr_ruby) or 0
+ if max_allow_pre < 0 then
+ if atr>0 then
+ -- 直前のルビで intrusion がおこる可能性あり.
+ -- 前 run のデータが残っていればそれを使用,
+ -- そうでなければ行中形のデータを利用する
+ local op = old_break_info[atr] or post_intrusion_backup
+ max_allow_pre = max(0, -max_allow_pre - op)
+ else
+ max_allow_pre = -max_allow_pre
+ end
+ end
+ post_intrusion_backup = 0
+ max_allow_post = has_attr(nv, attr_ruby_maxpostp) or 0
+ max_margin = has_attr(nv, attr_ruby_maxmargin) or 0
+ local coef = pre_low_cal_box(n, getfield(nv, 'value'))
+ local s = node_tail(nv) --ルビ文字
+ head, n = pre_low_app_node(
+ head, n, getfield(nv, 'value'), coef,
+ getfield(s, 'height'), getfield(s, 'depth')
+ )
+ else
+ n = first_whatsit(node_next(n))
+ end
+ end
+ return to_node(head)
+end
+luatexbase.add_to_callback('pre_linebreak_filter', pre_high, 'ltj.ruby.pre', 100)
+luatexbase.add_to_callback('hpack_filter', pre_high, 'ltj.ruby.pre', 100)
+
+----------------------------------------------------------------
+-- post_line_break
+----------------------------------------------------------------
+local post_lown
+do
+ local function write_aux(wv, num)
+ local id = has_attr(wv, attr_ruby_id)
+ if id>0 then
+ tex.sprint(cat_lp,
+ '\\write\\@mainaux{\\string\\directlua{luatexja.ruby.old_break_info['
+ .. tostring(id) .. ']=' .. num
+ .. '}}')
+ end
+ end
+
+ post_lown = function (rs, rw, cmp, ch)
+ -- ch: the head of `current' hlist
+ if #rs ==0 or not rw then return ch end
+ local hn = has_attr(rs[1], attr_ruby)
+ local fn = has_attr(rs[#rs], attr_ruby)
+ local wv = getfield(rw, 'value')
+ if hn==1 then
+ if fn==2*cmp+2 then
+ local hn = node_tail(wv)
+ node_remove(wv, hn)
+ insert_after(ch, rs[#rs], hn)
+ set_attr(hn, attr_icflag, PROCESSED)
+ write_aux(wv, has_attr(hn, attr_ruby))-- 行中形
+ else
+ local deg, hn = (fn-1)/2, wv
+ for i = 1, deg do hn = node_next(hn) end;
+ node_remove(wv, hn)
+ setfield(hn, 'next', nil)
+ insert_after(ch, rs[#rs], hn)
+ set_attr(hn, attr_icflag, PROCESSED)
+ write_aux(wv, has_attr(hn, attr_ruby))
+ end
+ else
+ local deg, hn = max((hn-1)/2,2), wv
+ for i = 1, cmp+deg-1 do hn = node_next(hn) end
+ -- -1 is needed except the case hn = 3,
+ -- because a ending-line form is removed already from the list
+ node_remove(wv, hn); setfield(hn, 'next', nil)
+ insert_after(ch, rs[#rs], hn)
+ set_attr(hn, attr_icflag, PROCESSED)
+ if fn == 2*cmp-1 then
+ write_aux(wv, has_attr(hn, attr_ruby))
+ end
+ end
+ for i = 1,#rs do
+ local ri = rs[i]
+ ch = node_remove(ch, ri); node_free(ri);
+ end
+ -- cleanup
+ if fn >= 2*cmp+1 then node_free(rw) end
+ return ch;
+ end
+end
+
+local function post_high_break(head)
+ local rs = {} -- rs: sequence of ruby_nodes,
+ local rw = nil -- rw: main whatsit
+ local cmp = -2 -- dummy
+ for h in Dnode.traverse_id(id_hlist, to_direct(head)) do
+ for i = 1, #rs do rs[i] = nil end
+ local ha = getlist(h)
+ while ha do
+ local hai = getid(ha)
+ local i = ((hai == id_glue and getsubtype(ha)==0)
+ or (hai == id_rule and getsubtype(ha)==0)
+ or (hai == id_whatsit and getsubtype(ha)==sid_user
+ and getfield(ha, 'user_id', RUBY_POST)))
+ and has_attr(ha, attr_ruby) or 0
+ if i==0 then
+ ha = node_next(ha)
+ elseif i==1 then
+ setfield(h, 'head', post_lown(rs, rw, cmp, getlist(h)))
+ for i = 2, #rs do rs[i] = nil end -- rs[1] is set by the next statement
+ rs[1], rw = ha, nil; ha = node_next(ha)
+ elseif i==2 then
+ rw = ha
+ cmp = getfield(getfield(rw, 'value'), 'value')
+ local hb, hc = node_remove(getlist(h), rw)
+ setfield(h, 'head', hb); ha = hc
+ else -- i>=3
+ rs[#rs+1] = ha; ha = node_next(ha)
+ end
+ end
+ setfield(h, 'head', post_lown(rs, rw, cmp, getlist(h)))
+ end
+ return head
+end
+
+local function post_high_hbox(ahead)
+ local ha = to_direct(ahead); local head = ha
+ local rs = {}; -- rs: sequence of ruby_nodes,
+ local rw = nil; -- rw: main whatsit
+ local cmp
+ while ha do
+ local hai = getid(ha)
+ local i = ((hai == id_glue and getsubtype(ha)==0)
+ or (hai == id_rule and getsubtype(ha)==0)
+ or (hai == id_whatsit and getsubtype(ha)==sid_user
+ and getfield(ha, 'user_id', RUBY_POST)))
+ and has_attr(ha, attr_ruby) or 0
+ if i==0 then
+ ha = node_next(ha)
+ elseif i==1 then
+ head = post_lown(rs, rw, cmp, head)
+ for i = 2, #rs do rs[i] = nil end -- rs[1] is set by the next statement
+ rs[1], rw = ha, nil; ha = node_next(ha)
+ elseif i==2 then
+ rw = ha
+ cmp = getfield(getfield(rw, 'value'), 'value')
+ head, ha = node_remove(head, rw)
+ else -- i >= 3
+ rs[#rs+1] = ha; ha = node_next(ha)
+ end
+ end
+ return to_node(post_lown(rs, rw, cmp, head))
+end
+
+luatexbase.add_to_callback('post_linebreak_filter', post_high_break, 'ltj.ruby.post_break', 100)
+luatexbase.add_to_callback('hpack_filter', post_high_hbox, 'ltj.ruby.post_hbox', 101)
+
+
+----------------------------------------------------------------
+-- for jfmglue callbacks
+----------------------------------------------------------------
+do
+ local RIPRE = luatexja.stack_table_index.RIPRE
+ local function whatsit_callback(Np, lp, Nq, bsl)
+ if Np.nuc then return Np
+ elseif getfield(lp, 'user_id') == RUBY_PRE then
+ Np.first, Np.nuc, Np.last = lp, lp, lp
+ local lpv = getfield(lp, 'value')
+ local x = node_next(node_next(lpv))
+ Np.last_char = luatexja.jfmglue.check_box_high(Np, getlist(x), nil)
+ if Nq.id ~=id_pbox_w then
+ if type(Nq.char)=='number' then
+ -- Nq is a JAchar
+ if has_attr(lpv, attr_ruby_maxprep) < 0 then -- auto
+ local p = round((ltjs.table_current_stack[RIPRE + Nq.char] or 0)
+ *has_attr(lpv, attr_ruby))
+ if has_attr(lpv, attr_ruby_mode)%2 == 0 then -- intrusion 無効
+ p = 0
+ end
+ set_attr(lpv, attr_ruby_maxprep, -p)
+ end
+ if Nq.prev_ruby then
+ set_attr(lp, attr_ruby, Nq.prev_ruby)
+ end
+ elseif has_attr(lpv, attr_ruby_maxprep) < 0 then -- auto
+ if Nq.char == 'parbdd' then
+ local p = round((ltjs.table_current_stack[RIPRE-1] or 0)
+ *has_attr(lpv, attr_ruby))
+ p = min(p, Nq.width)
+ if has_attr(lpv, attr_ruby_mode)%2 == 0 then -- intrusion 無効
+ p = 0
+ end
+ set_attr(lpv, attr_ruby_maxprep, p)
+ else
+ set_attr(lpv, attr_ruby_maxprep, 0)
+ end
+ end
+ elseif has_attr(lpv, attr_ruby_maxprep) < 0 then -- auto
+ set_attr(lpv, attr_ruby_maxprep, 0)
+ end
+ return Np
+ end
+ end
+ luatexbase.add_to_callback("luatexja.jfmglue.whatsit_getinfo", whatsit_callback,
+ "luatexja.ruby.np_info", 1)
+end
+
+do
+ local RIPOST = luatexja.stack_table_index.RIPOST
+ local function whatsit_after_callback(s, Nq, Np, bsl)
+ if not s and getfield(Nq.nuc, 'user_id') == RUBY_PRE then
+ local nqnv = getfield(Nq.nuc, 'value')
+ local x = node_next(node_next(nqnv))
+ for i = 2, getfield(nqnv, 'value') do x = node_next(node_next(x)) end
+ Nq.last_char = luatexja.jfmglue.check_box_high(Nq, getlist(x), nil)
+ luatexja.jfmglue.after_hlist(Nq)
+ if Np and Np.id ~=id_pbox_w and type(Np.char)=='number' then
+ -- Np is a JAchar
+ local rm = has_attr(nqnv, attr_ruby_mode)
+ if has_attr(nqnv, attr_ruby_maxpostp) < 0 then -- auto
+ local p = round((ltjs.table_current_stack[RIPOST + Np.char] or 0)
+ *has_attr(nqnv, attr_ruby))
+ if rm%2 == 0 then -- intrusion 無効
+ p = 0
+ end
+ if rm%4 >= 2 then
+ local q = has_attr(nqnv, attr_ruby_maxprep)
+ if q < p then p = q
+ elseif q > p then
+ set_attr(nqnv, attr_ruby_maxprep, p)
+ end
+ end
+ set_attr(nqnv, attr_ruby_maxpostp, p)
+ end
+ Np.prev_ruby = has_attr(getfield(Nq.nuc, 'value'), attr_ruby_id)
+ -- 前のクラスタがルビであったことのフラグ
+ else -- 直前が文字以外
+ local nqnv = getfield(Nq.nuc, 'value')
+ if has_attr(nqnv, attr_ruby_maxpostp) < 0 then -- auto
+ set_attr(nqnv, attr_ruby_maxpostp, 0)
+ if has_attr(nqnv, attr_ruby_mode)%4 >= 2 then
+ set_attr(nqnv, attr_ruby_maxprep, 0)
+ end
+ end
+ end
+ return true
+ else
+ return s
+ end
+ end
+ luatexbase.add_to_callback("luatexja.jfmglue.whatsit_after", whatsit_after_callback,
+ "luatexja.ruby.np_info_after", 1)
+end
+
diff --git a/Master/texmf-dist/tex/luatex/luatexja/ltjsarticle.cls b/Master/texmf-dist/tex/luatex/luatexja/ltjsarticle.cls
index 518f152b870..62ddad71674 100644
--- a/Master/texmf-dist/tex/luatex/luatexja/ltjsarticle.cls
+++ b/Master/texmf-dist/tex/luatex/luatexja/ltjsarticle.cls
@@ -38,7 +38,7 @@
%% Right brace \} Tilde \~}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ltjsarticle}
- [2014/02/07 ]
+ [2014/03/28 ]
\RequirePackage{luatexja}
\newif\if@restonecol
\newif\if@titlepage
@@ -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/Master/texmf-dist/tex/luatex/luatexja/ltjsbook.cls b/Master/texmf-dist/tex/luatex/luatexja/ltjsbook.cls
index 9910bae1108..813909f0d6f 100644
--- a/Master/texmf-dist/tex/luatex/luatexja/ltjsbook.cls
+++ b/Master/texmf-dist/tex/luatex/luatexja/ltjsbook.cls
@@ -38,7 +38,7 @@
%% Right brace \} Tilde \~}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ltjsbook}
- [2014/02/07 ]
+ [2014/03/28 ]
\RequirePackage{luatexja}
\newif\if@restonecol
\newif\if@titlepage
@@ -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/Master/texmf-dist/tex/luatex/luatexja/ltjskiyou.cls b/Master/texmf-dist/tex/luatex/luatexja/ltjskiyou.cls
index c33b1415276..145d94ba1b4 100644
--- a/Master/texmf-dist/tex/luatex/luatexja/ltjskiyou.cls
+++ b/Master/texmf-dist/tex/luatex/luatexja/ltjskiyou.cls
@@ -38,7 +38,7 @@
%% Right brace \} Tilde \~}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ltjskiyou}
- [2014/02/07 ]
+ [2014/03/28 ]
\RequirePackage{luatexja}
\newif\if@restonecol
\newif\if@titlepage
@@ -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/Master/texmf-dist/tex/luatex/luatexja/ltjspf.cls b/Master/texmf-dist/tex/luatex/luatexja/ltjspf.cls
index 251d916f69c..b56a2343531 100644
--- a/Master/texmf-dist/tex/luatex/luatexja/ltjspf.cls
+++ b/Master/texmf-dist/tex/luatex/luatexja/ltjspf.cls
@@ -38,7 +38,7 @@
%% Right brace \} Tilde \~}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ltjspf}
- [2014/02/07 ]
+ [2014/03/28 ]
\RequirePackage{luatexja}
\newif\if@restonecol
\newif\if@titlepage
@@ -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/Master/texmf-dist/tex/luatex/luatexja/luatexja-core.sty b/Master/texmf-dist/tex/luatex/luatexja/luatexja-core.sty
index 553e2001a9f..d0a4a47fe43 100644
--- a/Master/texmf-dist/tex/luatex/luatexja/luatexja-core.sty
+++ b/Master/texmf-dist/tex/luatex/luatexja/luatexja-core.sty
@@ -458,8 +458,8 @@
% いつも global
\def\ltj@@getjfontnumber#1{% result in \ltj@tempcntc
\ltj@reset@globaldefs
- \bgroup\ltj@curjfnt=-1\relax
- #1\directlua{luatexja.__temp = \the\ltj@curjfnt}\egroup
+ \begingroup\ltj@curjfnt=-1\relax
+ #1\directlua{luatexja.__temp = \the\ltj@curjfnt}\endgroup
\ltj@tempcntc=\directlua{tex.sprint(luatexja.__temp)}\relax
\ifnum\ltj@tempcntc=-1
\@PackageError{luatexja-core}%
diff --git a/Master/texmf-dist/tex/luatex/luatexja/patches/lltjdefs.sty b/Master/texmf-dist/tex/luatex/luatexja/patches/lltjdefs.sty
index 9d04afe9641..9cd76430e11 100644
--- a/Master/texmf-dist/tex/luatex/luatexja/patches/lltjdefs.sty
+++ b/Master/texmf-dist/tex/luatex/luatexja/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}
diff --git a/Master/texmf-dist/tex/luatex/luatexja/patches/lltjfont.sty b/Master/texmf-dist/tex/luatex/luatexja/patches/lltjfont.sty
index 5157a1e9a59..2933844817a 100644
--- a/Master/texmf-dist/tex/luatex/luatexja/patches/lltjfont.sty
+++ b/Master/texmf-dist/tex/luatex/luatexja/patches/lltjfont.sty
@@ -611,8 +611,11 @@
%%%% \DeclareAlternateKanjiFont<Benc><Bfam><Bser><Bshape><Aenc><Afam><Aser><Ashape><range>
% いつも global
\def\DeclareAlternateKanjiFont#1#2#3#4#5#6#7#8#9{%
- {\def\ltj@temp@bfont{#1/#2/#3/#4}\def\ltj@temp@afont{#5/#6/#7/#8}%
- \expandafter\ltj@@altfont@latex#9,,}\ignorespaces}
+ \edef\@temp{#9}%
+ \ifx\@temp\@empty\else
+ {\def\ltj@temp@bfont{#1/#2/#3/#4}\def\ltj@temp@afont{#5/#6/#7/#8}%
+ \expandafter\ltj@@altfont@latex#9,,}\ignorespaces
+ \fi}
\def\ltj@@altfont@latex#1,{\def\ltj@temp{#1}%
\ifx\ltj@temp\empty\let\@next=\relax\else
\ltj@@altfont@latexA{#1}\let\@next=\ltj@@altfont@latex\fi\@next}
@@ -638,7 +641,7 @@
\directlua{luatexja.jfont.clear_alt_font_latex('\luatexluaescapestring{#1/#2/#3/#4}')}}
\def\ltj@pickup@altfont@aux#1{%
- {\edef\font@name{\csname #1/\f@size\endcsname}\pickup@jfont}%
+ \begingroup\edef\font@name{\csname #1/\f@size\endcsname}\pickup@jfont\endgroup%
}
\def\ltj@pickup@altfont@copy#1#2{%
\ltj@@getjfontnumber#1%