OSDN Git Service

luatexja-ruby: added baseheight key
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sun, 4 Oct 2020 07:50:30 +0000 (16:50 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sun, 4 Oct 2020 07:50:30 +0000 (16:50 +0900)
doc/luatexja-ruby.tex
src/addons/luatexja-ruby.sty
src/ltj-ruby.lua
src/luatexja.sty

index 40657a3..9ce9588 100644 (file)
@@ -188,6 +188,19 @@ plain \LuaTeX でのロードはまだサポートしておらず,
 \frame{\ltjruby[rubysmash=false,intergap=-1.5]
   {本}{ほん}}
 \end{LTXexample}
+\item[baseheight=<real>] 正の値($r$とする)が指定された場合,
+  ルビの親文字の高さを全角高さの$r$倍と固定する.0以下の値は効力を発揮しない.
+  既定値は0.
+\begin{LTXexample}[width=0.3\textwidth, preset=\Large]
+\noindent
+\ltjruby[baseheight=0.88]{本}{ほん}\ 
+\ltjruby[baseheight=0.88]{dvi}{ディーヴィーアイ}\\
+\ltjruby[baseheight=0.5]{本}{ほん}\ 
+\ltjruby[baseheight=0.5]{dvi}{ディーヴィーアイ}\\
+\ltjruby[baseheight=0]{本}{ほん}\ 
+\ltjruby[baseheight=0]{dvi}{ディーヴィーアイ}
+\end{LTXexample}
+
 
 
 \item[kenten=<command>]各文字につく圏点の出力命令を指定する.既定値は「\verb+\ltjalchar`•+」
@@ -231,7 +244,7 @@ mode=9, stretch={1}{2}{1}, stretchruby={0}{0}{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
+  kenten=\ltjalchar`•, fontcmd=\relax, baseheight=0.88
 \end{verbatim}
 
 \paragraph{\texttt{\textbackslash ltjsetparamater} に追加されるキー}
@@ -244,7 +257,8 @@ mode=9, stretch={1}{2}{1}, stretchruby={0}{0}{1}
 既定値は,\Param{rubypreintrusion},~\Param{rubypostintrusion}とも
 以下の文字に対しては1,その他の文字については0である:
 \begin{quote}
- 平仮名(\texttt{U+3040}--\texttt{U+309F}),カギ括弧「」,読点「,」「、」,中黒「・」
+ ひらがな(\texttt{U+3040}--\texttt{U+309F}),カタカナ(\texttt{U+30A0}--\texttt{U+30FF}),
+ 仮名補助など(\texttt{U+1B000}--\texttt{U+1B16F}),カギ括弧「」,読点「,」「、」,中黒「・」
 \end{quote}
 また,ここでは「文字コード$-1$の文字」は,「段落開始の \verb+\parindent+」を表す%
 \footnote{通常の\LuaTeX-jaにおける指定では文中数式境界を表していることに注意.}.
@@ -561,6 +575,14 @@ $r_2$,~$g_2$を行Bから除去・メモリ解放し,代わりに$n_3$を行B
 %\directlua{ltj.ext_show_node_list(tex.box[0], '? ', print)}
 \fbox{\box0}
 
+\setbox0=\vbox{\hsize=22\zw\noindent
+ふぁいる\ruby[baseheight=0.88]{dvi}{ディーヴィーアイ}ファイル
+  \ruby[baseheight=0.88]{oo}{ほーげーふーが}漢字\\
+ファイル\ruby[baseheight=0.88]{dvi}{ディーヴィーアイ}ふぁいる
+  \ruby[baseheight=0.88]{oo}{ほーげーふーが}漢字
+}
+\fbox{\box0}
+
 \def\rubytest{\ruby{国府津}{こうづ}\relax}
 % グループルビ
 
index 518d6ec..03959b8 100644 (file)
@@ -4,7 +4,7 @@
 
 % LaTeX only!
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{luatexja-ruby}[2017/09/26 v0.23a]
+\ProvidesPackage{luatexja-ruby}[2020-10-04 v0.3]
 \RequirePackage{luatexja}
 
 %%------------------
@@ -66,6 +66,7 @@
 \ltj@@rkeydef{kenten}%% 圏点文字
 \ltj@@rkeydef{fontcmd}%% フォント
 \define@boolkey[ltj]{ruby}{rubysmash}[true]{}
+\ltj@@rkeydef{baseheight}%% 親文字の高さ
 
 
 %%%%%%%% setkeys の別名
@@ -89,7 +90,7 @@
       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},
+      intergap =  \ltj@safe@dimen{\ltj@@rubyip@intergap\zh},
       stretch 
         = 262144 * \expandafter\ltj@@ruby@cts\ltj@@rubyip@stretchbol
          + 512 * \expandafter\ltj@@ruby@cts\ltj@@rubyip@stretcheol
@@ -97,7 +98,8 @@
       mode 
         = 2097152 * \expandafter\ltj@@ruby@cts\ltj@@rubyip@stretchruby
           + \ltj@safe@num{\ltj@@rubyip@mode}
-          + 1048576 * \ifltj@ruby@rubysmash1\else0\fi
+          + 1048576 * \ifltj@ruby@rubysmash1\else0\fi,
+      baseheight = \ltj@safe@dimen{\ltj@@rubyip@baseheight\zh},
     \string}
 }
 %%%
   \ltjsetparameter{rubypreintrusion={\the\count@,1}, 
     rubypostintrusion={\the\count@,1}}
   \advance\count@1\repeat
+%% カタカナ
+\count@="30F0\loop\relax\ifnum \count@<"3100
+  \ltjsetparameter{rubypreintrusion={\the\count@,1}, 
+    rubypostintrusion={\the\count@,1}}
+  \advance\count@1\repeat
+%% Kana Supplement
+\count@="1B000\loop\relax\ifnum \count@<"1B170
+  \ltjsetparameter{rubypreintrusion={\the\count@,1}, 
+    rubypostintrusion={\the\count@,1}}
+  \advance\count@1\repeat
 %% 「」
 \ltjsetparameter{rubypreintrusion={`「,1}, 
   rubypostintrusion={`」,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
+  kenten=\ltjalchar`•, fontcmd=\relax, baseheight=0
 }
 
 \endinput
index 865e301..1f311ea 100644 (file)
@@ -50,6 +50,7 @@ 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_baseheight= luatexbase.attributes['ltj@kcat6']
 local attr_ruby = luatexbase.attributes['ltj@rubyattr']
 -- ルビ内部処理用,以下のようにノードによって使われ方が異なる
 -- * (whatsit) では JAglue 処理時に,
@@ -264,6 +265,7 @@ local function texiface_low(rst, rtlr, rtlp)
    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_baseheight, rst.baseheight)
    set_attr(wv, attr_ruby_stretch, rst.stretch)
    set_attr(wv, attr_ruby_mode, rst.mode)
    local n = wv
@@ -350,7 +352,7 @@ 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)
+                            mapre, mapost, imode, rgap, bheight)
    local post_intrusion = 0
    local intmode = imode%4
    local rpre, rmid, rpost, rsmash
@@ -386,6 +388,9 @@ local function new_ruby_box(r, p, ppre, pmid, ppost,
    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)
+   if bheight > 0 then
+       setfield(p, 'height', bheight)
+   end
    a = node.direct.vpack(r); setfield(a, 'shift', 0)
    set_attr(a, attr_ruby, post_intrusion)
    if rsmash or getfield(a, 'height')<getfield(p, 'height') then
@@ -418,6 +423,7 @@ local function pre_low_cal_box(w, cmp)
    local coef = {} -- 連立一次方程式の拡大係数行列
    local rtb = expand_3bits(has_attr(wv, attr_ruby_stretch))
    local rgap = has_attr(wv, attr_ruby_intergap)
+   local bheight = has_attr(wv, attr_ruby_baseheight)
    local intmode = floor(has_attr(wv, attr_ruby_mode)/4)
 
    -- node list 展開・行末形の計算
@@ -430,7 +436,7 @@ local function pre_low_cal_box(w, cmp)
       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)
+                        rtb[6], rtb[5], rtb[4], max_allow_pre, 0, intmode, rgap, bheight)
    end
    node_free(nta); node_free(ntb)
 
@@ -443,7 +449,7 @@ local function pre_low_cal_box(w, cmp)
       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)
+                        rtb[9], rtb[8], rtb[7], 0, max_allow_post, intmode, rgap, bheight)
    end
 
    -- ここで,nta, ntb には全 container を連結した box が入っているので
@@ -452,7 +458,7 @@ local function pre_low_cal_box(w, cmp)
    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)
+                     max_allow_pre, max_allow_post, intmode, rgap, bheight)
 
    -- w.value の node list 更新.
    local nt = wv
index cfee092..74df9c7 100644 (file)
   \expandafter\let\csname ifltj@in@latex\expandafter\endcsname
     \csname iftrue\endcsname
   \NeedsTeXFormat{LaTeX2e}
-  \ProvidesPackage{luatexja}[2020-09-19 Japanese Typesetting with Lua(La)TeX]
+  \ProvidesPackage{luatexja}[2020-10-05 Japanese Typesetting with Lua(La)TeX]
   \DeclareOption{disablejfam}{\ltj@disablejfamtrue}
   \DeclareOption*{}
   \ProcessOptions\relax
 \fi                             %</LaTeX>
 %%%% VERSION
-\def\LuaTeXjaversion{20201001.0}
+\def\LuaTeXjaversion{20201005.0}
 
 \directlua{require('ltj-unicode-ccfix.lua')}% catcode of ideographs