\frame{\ltjruby[rubysmash=false,intergap=-1.5]
{本}{ほん}}
\end{LTXexample}
-\item[baseheight=<real>] 正の値($r$とする)が指定された場合,
- ルビの親文字の高さを全角高さの$r$倍と固定する.0以下の値は効力を発揮しない.
- 既定値は0.
+\item[ybaseheight=<real>] 非負の値が指定された場合,
+ \emph{縦組以外での}ルビの親文字の高さを全角高さの<real>倍と強制的に固定する.負の値が指定された場合は固定しない.
+ 標準値は0.88.
+\item[tbaseheight=<real>] \texttt{ybaselineshift}と同様だが,こちらは\emph{縦組での}ルビの親文字の高さを指定する.
+ 標準値は0.5.
+\item[baseheight=<real>] \texttt{ybaselineshift},\texttt{tbaselinesift}を同時に指定したことと同義.
\begin{LTXexample}[width=0.3\textwidth, preset=\Large]
\noindent
\ltjruby[baseheight=0.88]{本}{ほん}\
\ltjruby[baseheight=0.5]{本}{ほん}\
\ltjruby[baseheight=0.5]{dvi}{ディーヴィーアイ}\\
\ltjruby[baseheight=0]{本}{ほん}\
-\ltjruby[baseheight=0]{dvi}{ディーヴィーアイ}
+\ltjruby[baseheight=0]{dvi}{ディーヴィーアイ}\\
+\ltjruby[baseheight=-1]{本}{ほん}\
+\ltjruby[baseheight=-1]{dvi}{ディーヴィーアイ}
\end{LTXexample}
%\directlua{ltj.ext_show_node_list(tex.box[0], '? ', print)}
\fbox{\box0}
-\setbox0=\vbox{\hsize=22\zw\noindent
+\setbox0=\vbox{\hsize=30\zw\noindent
+\texttt{baseheight=0.88}での例\\
ふぁいる\ruby[baseheight=0.88]{dvi}{ディーヴィーアイ}ファイル
\ruby[baseheight=0.88]{oo}{ほーげーふーが}漢字\\
ファイル\ruby[baseheight=0.88]{dvi}{ディーヴィーアイ}ふぁいる
\ltj@@rkeydef{kenten}%% 圏点文字
\ltj@@rkeydef{fontcmd}%% フォント
\define@boolkey[ltj]{ruby}{rubysmash}[true]{}
-\ltj@@rkeydef{baseheight}%% 親文字の高さ
+\ltj@@rkeydef{ybaseheight} % 縦組以外 (yoko, utod, dtou)
+\ltj@@rkeydef{tbaseheight} % 縦組
+\define@key[ltj]{ruby}{baseheight}{%
+ \expandafter\def\csname ltj@@rubyip@ybaseheight\endcsname{#1}%
+ \expandafter\def\csname ltj@@rubyip@tbaseheight\endcsname{#1}%
+}
+
+%% これらの値が正のとき,親文字の高さをこの値(\zh 単位)とみなす
%%%%%%%% setkeys の別名
\protected\def\ltjsetruby{\setkeys[ltj]{ruby}}
= (2097152 * \expandafter\ltj@@ruby@cts\ltj@@rubyip@stretchruby
+ \ltj@safe@num{\ltj@@rubyip@mode}
+ 1048576 * \ifltj@ruby@rubysmash1\else0\fi),
- baseheight = \ltj@safe@dimen{\ltj@@rubyip@baseheight\zh},
+ baseheight = \ltj@safe@dimen{\ifnum\ltjgetparameter{direction}=3
+ \ltj@@rubyip@tbaseheight\else\ltj@@rubyip@ybaseheight\fi\zh},
\string}
}
%%%
rubypostintrusion={\the\count@,1}}
\advance\count@1\repeat
%% カタカナ
-\count@="30F0\loop\relax\ifnum \count@<"3100
+\count@="30A0\loop\relax\ifnum \count@<"3100
\ltjsetparameter{rubypreintrusion={\the\count@,1},
rubypostintrusion={\the\count@,1}}
\advance\count@1\repeat
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, baseheight=0
+ kenten=\ltjalchar`•, fontcmd=\relax, ybaseheight=0.88, tbaseheight=0.5
}
\endinput
end)
luatexbase.create_callback("luatexja.jfmglue.whatsit_after", "data",
function (stat, Nq, Np) return false end)
+luatexbase.create_callback("luatexja.jfmglue.whatsit_last_minute", "data",
+ function (stat, Nq, Np) return false end)
-- calc next Np
local calc_np
function calc_np(last, lp)
local k
-- We assume lp = node_next(Np.last)
+ if Nq and Nq.id==id_pbox_w then
+ luatexbase.call_callback("luatexja.jfmglue.whatsit_last_minute", false, Nq, Np)
+ end
Np, Nq, non_ihb_flag = Nq, Np, true
-- We clear `predefined' entries of Np before pairs() loop,
-- because using only pairs() loop is slower.
- Np.post, Np.pre, Np.xspc = nil, nil, nil
+ Np.post, Np.pre, Np.xspc, Np.gk = nil, nil, nil, nil
Np.first, Np.id, Np.last, Np.met, Np.class= nil, nil, nil, nil
Np.auto_kspc, Np.auto_xspc, Np.char, Np.nuc = nil, nil, nil, nil
-- auto_kspc, auto_xspc: normally true/false,
if g then
head = insert_before(head, Np.first, g)
Np.first = g
+ local ngk = Np.gk
+ if not ngk then Np.gk = g
+ elseif type(ngk)=="table" then ngk[#ngk+1]=g
+ else Np.gk = { ngk, g } end
end
end
{}, {}, {first=nil},
{ auto_kspc=nil, auto_xspc=nil, char=nil, class=nil,
first=nil, id=nil, last=nil, met=nil, nuc=nil,
- post=nil, pre=nil, xspc=nil, },
+ post=nil, pre=nil, xspc=nil, gk=nil },
{ auto_kspc=nil, auto_xspc=nil, char=nil, class=nil,
first=nil, id=nil, last=nil, met=nil, nuc=nil,
- post=nil, pre=nil, xspc=nil, },
+ post=nil, pre=nil, xspc=nil, gk=nil },
}
init_var = function (mode,dir)
-- 1073741823: max_dimen
setfield(a, 'depth', 0); setfield(k, 'kern', tmp_tbl.rgap)
insert_after(r, r, a); insert_after(r, a, k);
insert_after(r, k, p); setfield(p, 'next', nil)
- if tmp_tbl.bheight > 0 then setfield(p, 'height', tmp_tbl.bheight) end
+ if tmp_tbl.bheight >= 0 then setfield(p, 'height', tmp_tbl.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
return head, first_whatsit(node_next(nt))
end
-local get_around_skip
-do
-local KANJI_SKIP = luatexja.icflag_table.KANJI_SKIP
-local XKANJI_SKIP_JFM = luatexja.icflag_table.XKANJI_SKIP_JFM
-local getprev = node.direct.getprev
-local getnext = node.direct.getnext
-get_around_skip = function(head, n)
- local p = getprev(n)
- luatexja.ext_show_node(node.direct.tonode(p), 'B> ', print)
- if getid(p)==id_glue then
- local pi = get_attr_icflag(p)
- if pi>=KANJI_SKIP and pi<=XKANJI_SKIP_JFM then
- print(n, 'before ' .. luatexja.print_scaled(getfield(p, 'width')))
- end
- end
- p = getnext(n)
- luatexja.ext_show_node(node.direct.tonode(p), 'A> ', print)
- if getid(p)==id_glue then
- local pi = get_attr_icflag(p)
- if pi>=KANJI_SKIP and pi<=XKANJI_SKIP_JFM then
- print(n, 'after ' .. luatexja.print_scaled(getfield(p, 'width')))
- end
- end
-end
-end
-
local function pre_high(ahead)
if not ahead then return ahead end
local head = to_direct(ahead)
local n = first_whatsit(head)
while n do
if getsubtype(n) == sid_user and getfield(n, 'user_id') == RUBY_PRE then
--- local around_skip = get_around_skip(head, n)
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
insert_before(Nq.nuc, Np.first, last_glue)
Np.first = last_glue
next_cluster_array[Nq.nuc] = last_glue -- ルビ処理用のグルー
+-- if Nq.gk then
+-- if type(Nq.gk)=="table" then
+-- for _,v in ipairs(Nq.gk) do luatexja.ext_show_node(node.direct.tonode(v), 'BBt> ', print) end
+-- else luatexja.ext_show_node(node.direct.tonode(Nq.gk), 'BBB> ', print) end
+-- end
end
local nqnv = getfield(Nq.nuc, 'value')
local x = node_next(node_next(nqnv))
luatexbase.add_to_callback("luatexja.jfmglue.whatsit_after", whatsit_after_callback,
"luatexja.ruby.np_info_after", 1)
end
+if false then -- いまは off
+ local function w (s, Nq, Np)
+ if Np.gk then
+ if type(Np.gk)=="table" then
+ for _,v in ipairs(Np.gk) do luatexja.ext_show_node(node.direct.tonode(v), 'AAt> ', print) end
+ else luatexja.ext_show_node(node.direct.tonode(Np.gk), 'AAA> ', print) end
+ end
+ end
+ luatexbase.add_to_callback("luatexja.jfmglue.whatsit_last_minute", w,
+ "luatexja.ruby.np_info_last_minute", 1)
+end