From: Hironori Kitagawa Date: Wed, 12 Feb 2014 11:12:39 +0000 (+0900) Subject: Updated test14-ruby.tex (test and the manual of luatexja-ruby.sty) X-Git-Tag: 20140504.0~14 X-Git-Url: http://git.osdn.jp/view?a=commitdiff_plain;h=ca2f902449134e3055387148c03930652e4ee67f;p=luatex-ja%2Fluatexja.git Updated test14-ruby.tex (test and the manual of luatexja-ruby.sty) --- diff --git a/src/addons/luatexja-ruby.sty b/src/addons/luatexja-ruby.sty index 6df9a0b..c104576 100644 --- a/src/addons/luatexja-ruby.sty +++ b/src/addons/luatexja-ruby.sty @@ -58,10 +58,13 @@ %% attr_ruby_maxmargin %% attr は sp 単位だが,ユーザーは親文字全角単位で指定 \ltj@@rkeydef{maxmargin} + +\ltj@@rkeydef{kenten}%% 圏点文字 + \savekeys[ltj]{ruby}{% mode, intrusionpre, intrusionpost, stretchhead, stretchend, stretch, stretchruby, - maxmargin, rubysize, + maxmargin, rubysize, kenten, } %%%%%%%% setkeys の別名 @@ -71,10 +74,13 @@ %% ルビと親文字の大きさの比 \ltj@@rkeydef{rubysize} +% 中つき用簡易設定. +\define@key[ltj]{ruby}{kata}[none]{\setkeys[ltj]{ruby}{mode=1, stretch=121, stretchruby=121}} % 肩つき用簡易設定. -\define@key[ltj]{ruby}{kata}[none]{\setkeys[ltj]{ruby}{mode=9,stretchruby=001}} +\define@key[ltj]{ruby}{kata}[none]{\setkeys[ltj]{ruby}{mode=9, stretch=121, stretchruby=001}} % 拡張肩つき用簡易設定. -\define@key[ltj]{ruby}{ekata}[none]{\setkeys[ltj]{ruby}{stretch=001,stretchruby=001}} +\define@key[ltj]{ruby}{ekata}[none]{\setkeys[ltj]{ruby}{% + intrusionpre=0, mode=1, stretch=001,stretchruby=001}} %%%%%%%% 補助関数 @@ -160,6 +166,13 @@ \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 @@ -179,11 +192,10 @@ rubypostintrusion={`・,1}} \setkeys[ltj]{ruby}{ - maxmargin=0.5, stretchruby={1}{2}{1}, stretch = {1}{2}{1}, stretchhead = {0}{1}{1}, stretchend = {1}{1}{0}, - intrusionpre = -1, intrusionpost = -1, - mode = 1, rubysize = 0.5 + intrusionpre = -1, intrusionpost = -1, maxmargin=0.5, + mode = 1, rubysize = 0.5, kenten=\ltjalchar`• } \endinput \ No newline at end of file diff --git a/src/ltj-ruby.lua b/src/ltj-ruby.lua index d0f8115..42c4074 100644 --- a/src/ltj-ruby.lua +++ b/src/ltj-ruby.lua @@ -440,6 +440,14 @@ local function pre_low_cal_box(w, cmp) return coef end + +local function first_whatsit(n) -- n 以後で最初の whatsit + for h in Dnode.traverse_id(id_whatsit, n) do + return h + end + return nil +end + -- ノード追加 local function pre_low_app_node(head, w, cmp, coef, ht, dp) -- メインの node list 更新 @@ -471,41 +479,37 @@ local function pre_low_app_node(head, w, cmp, coef, ht, dp) end tex.setattribute(attr_ruby, -0x7FFFFFFF) setfield(w, 'user_id', RUBY_POST) - return head, node_next(nt) + 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 = head + local n = first_whatsit(head) while n do - if getid(n) == id_whatsit then - 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 atr >0 then - -- 直前のルビで intrusion がおこる可能性あり. - -- 前 run のデータが残っていればそれを使用, - -- そうでなければ行中形のデータを利用する - local op = old_break_info[atr] or post_intrusion_backup - max_allow_pre = max(0, max_allow_pre - op) - 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 = node_next(n) + 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 atr >0 then + -- 直前のルビで intrusion がおこる可能性あり. + -- 前 run のデータが残っていればそれを使用, + -- そうでなければ行中形のデータを利用する + local op = old_break_info[atr] or post_intrusion_backup + max_allow_pre = max(0, max_allow_pre - op) 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 = node_next(n) + n = first_whatsit(node_next(n)) end end return to_node(head) @@ -572,27 +576,27 @@ do end end -local function is_zero_parfillskip(h,n) - if getid(n)==id_glue then - if getsubtype(n)==15 then - local ns = getfield(n, 'spec') - local n_width = getfield(ns, 'width') - if getfield(h, 'glue_sign')==1 - and getfield(h, 'glue_order') == getfield(ns, 'stretch_order') then - n_width = n_width - + round(getfield(h, 'glue_set')*getfield(ns, 'stretch')) - elseif getfield(h, 'glue_sign')==2 - and getfield(h, 'glue_order') == getfield(ns, 'shrink_order') then - n_width = n_width - - round(getfield(h, 'glue_set')*getfield(n,s 'shrink')) - end - n = node_next(n) -- rightskip 未完 - return (n_width <= 0) - else return false - end - else return false - end -end +-- local function is_zero_parfillskip(h,n) +-- if getid(n)==id_glue then +-- if getsubtype(n)==15 then +-- local ns = getfield(n, 'spec') +-- local n_width = getfield(ns, 'width') +-- if getfield(h, 'glue_sign')==1 +-- and getfield(h, 'glue_order') == getfield(ns, 'stretch_order') then +-- n_width = n_width +-- + round(getfield(h, 'glue_set')*getfield(ns, 'stretch')) +-- elseif getfield(h, 'glue_sign')==2 +-- and getfield(h, 'glue_order') == getfield(ns, 'shrink_order') then +-- n_width = n_width +-- - round(getfield(h, 'glue_set')*getfield(n,s 'shrink')) +-- end +-- n = node_next(n) -- rightskip 未完 +-- return (n_width <= 0) +-- else return false +-- end +-- else return false +-- end +-- end local function post_high_break(head) local rs = {} -- rs: sequence of ruby_nodes, @@ -613,19 +617,19 @@ local function post_high_break(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*cmp+2 then - local par_not_end = true - local hn = node_next(ha) - if hn and getid(hn)==id_penalty and getfield(hn, 'penalty')==10000 then - local hm = node_next(hn) - if is_zero_parfillskip(h,hm) then - par_not_end = false - end - end - if par_not_end then - rs[#rs+1] = ha; ha = hn - else - setfield(h, 'head', node_remove(getlist(h), ha)); break - end + -- local par_not_end = true + -- local hn = node_next(ha) + -- if hn and getid(hn)==id_penalty and getfield(hn, 'penalty')==10000 then + -- local hm = node_next(hn) + -- if is_zero_parfillskip(h,hm) then + -- par_not_end = false + -- end + -- end + -- if par_not_end then + rs[#rs+1] = ha; ha = node_next(ha) + -- else + -- setfield(h, 'head', node_remove(getlist(h), ha)); break + -- end elseif i>=3 then rs[#rs+1] = ha; ha = node_next(ha) elseif i==2 then diff --git a/src/patches/lltjdefs.sty b/src/patches/lltjdefs.sty index 3fbc353..9d04afe 100644 --- a/src/patches/lltjdefs.sty +++ b/src/patches/lltjdefs.sty @@ -31,7 +31,7 @@ \DeclareFontShape{JY3}{gt}{bx}{n}{<-> ssub*gt/m/n}{} %fontencoding{JT3}\selectfont -\fontencoding{JY3}\selectfont\adjustbaseline +\kanjiencoding{JY3}\selectfont\adjustbaseline \DeclareTextFontCommand{\textmc}{\mcfamily} \DeclareTextFontCommand{\textgt}{\gtfamily} diff --git a/test/test14-ruby.pdf b/test/test14-ruby.pdf index f877e99..049c98b 100644 Binary files a/test/test14-ruby.pdf and b/test/test14-ruby.pdf differ diff --git a/test/test14-ruby.tex b/test/test14-ruby.tex index cf76953..a803de0 100644 --- a/test/test14-ruby.tex +++ b/test/test14-ruby.tex @@ -1,7 +1,7 @@ %#! luajitlatex %%% a test of ruby. \documentclass[b5paper,10pt]{ltjsarticle} -\usepackage{fontspec,luacode,luatexja-otf,amsmath} +\usepackage{luatexja-otf,amsmath,fontspec} \usepackage{unicode-math} \setmathfont{XITS Math} \setmainfont[Ligatures=TeX]{TeX Gyre Termes} @@ -10,7 +10,6 @@ \usepackage{luatexja-ruby,showexpl,booktabs} \lstset{preset=\huge,basicstyle=\ttfamily} \fboxsep=0mm -%\usepackage{lua-visual-debug} \def\kata{\ltjsetruby{kata}} % 肩つきルビ用簡易設定.グループルビでは使用しないこと @@ -25,69 +24,225 @@ \DeclareFontShape{JY3}{mc}{mc}{n}{<-> [0.92487] psft:Ryumin-Light:extend=0.67;jfm=ujisc33}{} -\title{ルビ実装のサンプル} +\title{\texttt{luatexja-ruby.sty}} \begin{document} +\catcode`\<=13 +\def<#1>{{\normalfont\rm\itshape$\langle$#1\/$\rangle$}} %\fontsize{13.19873}{15}\selectfont% \maketitle +\texttt{luatexja-ruby.sty} は,\LuaTeX-jaの機能を利用してルビの組版処理を行う追加パッケージである. \section{使い方} +パッケージ読み込みは,\verb+\usepackage{luatexja-ruby}+ で良い. +plain \LuaTeX でのロードはまだサポートしておらず, +\LaTeXe のみサポート. + +\subsection{用語} +「進入(intrusion)」「突出(protrusion)」という用語は,ZRさんによる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{命令} +\paragraph{\tt\textbackslash ltjruby} +ルビ出力用命令の本体.\verb+\ruby+ という別名を定義している. +\begin{quote} +\tt \textbackslash ltjruby[