• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

ソースコードの管理場所


Commit MetaInfo

Revision2851387cb262598acd81146fb4b624bdb062dcda (tree)
Time2014-08-21 20:03:11
AuthorHironori Kitagawa <h_kitagawa2001@yaho...>
CommiterHironori Kitagawa

Log Message

Fix #34207 (cherry-pick 5ee9868b)

Change Summary

Incremental Difference

--- a/src/addons/luatexja-ruby.sty
+++ b/src/addons/luatexja-ruby.sty
@@ -146,7 +146,10 @@
146146
147147 %%%%%%%% TeX command
148148 \protected\def\ltjruby{\@ifnextchar[\ltj@@ruby{\ltj@@ruby[]}}%]
149-\AtBeginDocument{\ifdefined\ruby\else\let\ruby=\ltjruby\fi}
149+\AtBeginDocument{%
150+ \ifdefined\ruby\else\let\ruby=\ltjruby\fi
151+ \directlua{luatexja.ruby.read_old_break_info()}%
152+}
150153 \def\ltj@@ruby[#1]#2#3{{% #1: option #2: 親文字群,#3: ルビ文字列群,共に| 区切り
151154 \setkeys[ltj]{ruby}{#1}%
152155 \directlua{ruby_tmplist_r = \string{\string}; ruby_tmplist_p = \string{\string}}%
--- a/src/ltj-ruby.lua
+++ b/src/ltj-ruby.lua
@@ -125,6 +125,15 @@ end
125125
126126 -- 実行回数 + ルビ中身 から uniq_id を作る関数
127127 old_break_info = {} -- public, 前 run 時の分割情報
128+local cache_handle
129+function read_old_break_info()
130+ if tex.jobname then
131+ local fname = tex.jobname .. '.ltjruby'
132+ local real_file = kpse.find_file(fname)
133+ if real_file then dofile(real_file) end
134+ cache_handle = io.open(fname, 'w')
135+ end
136+end
128137 local make_uniq_id
129138 do
130139 local exec_count = 0
@@ -477,6 +486,7 @@ do
477486 end
478487 end
479488
489+local next_cluster_array = {}
480490 -- ノード追加
481491 local function pre_low_app_node(head, w, cmp, coef, ht, dp)
482492 -- メインの node list 更新
@@ -497,17 +507,21 @@ local function pre_low_app_node(head, w, cmp, coef, ht, dp)
497507 insert_after(head, nt, nta)
498508 set_attr(nta, attr_ruby, 2*i+1)
499509 -- glue
500- nt = node_new(id_glue)
501- local ntb = node_new(id_glue_spec);
510+ local ntb = node_new(id_glue_spec);
502511 setfield(ntb, 'width', coef[i*2+1][2*cmp+2])
503512 setfield(ntb, 'stretch_order', 0); setfield(ntb, 'stretch', 0)
504513 setfield(ntb, 'shrink_order', 0); setfield(ntb, 'shrink', 0)
514+ if i~=cmp or not next_cluster_array[w] then
515+ nt = node_new(id_glue); insert_after(head, nta, nt)
516+ else
517+ nt = next_cluster_array[w]
518+ end
505519 setfield(nt, 'subtype', 0); setfield(nt, 'spec', ntb)
506520 set_attr(nt, attr_ruby, 2*i+2)
507- insert_after(head, nta, nt)
508521 end
509522 tex.setattribute('global', attr_ruby, -0x7FFFFFFF)
510523 setfield(w, 'user_id', RUBY_POST)
524+ next_cluster_array[w]=nil
511525 return head, first_whatsit(node_next(nt))
512526 end
513527
@@ -558,10 +572,10 @@ do
558572 local function write_aux(wv, num)
559573 local id = has_attr(wv, attr_ruby_id)
560574 if id>0 then
561- tex.sprint(cat_lp,
562- '\\write\\@mainaux{\\string\\directlua{luatexja.ruby.old_break_info['
563- .. tostring(id) .. ']=' .. num
564- .. '}}')
575+ cache_handle:write(
576+ 'luatexja.ruby.old_break_info['
577+ .. tostring(id) .. ']=' .. num
578+ .. '\n')
565579 end
566580 end
567581
@@ -575,7 +589,7 @@ do
575589 if fn==2*cmp+2 then
576590 local hn = node_tail(wv)
577591 node_remove(wv, hn)
578- insert_after(ch, rs[#rs], hn)
592+ insert_after(ch, rs[1], hn)
579593 set_attr(hn, attr_icflag, PROCESSED)
580594 write_aux(wv, has_attr(hn, attr_ruby))-- 行中形
581595 else
@@ -583,7 +597,7 @@ do
583597 for i = 1, deg do hn = node_next(hn) end;
584598 node_remove(wv, hn)
585599 setfield(hn, 'next', nil)
586- insert_after(ch, rs[#rs], hn)
600+ insert_after(ch, rs[1], hn)
587601 set_attr(hn, attr_icflag, PROCESSED)
588602 write_aux(wv, has_attr(hn, attr_ruby))
589603 end
@@ -593,7 +607,7 @@ do
593607 -- -1 is needed except the case hn = 3,
594608 -- because a ending-line form is removed already from the list
595609 node_remove(wv, hn); setfield(hn, 'next', nil)
596- insert_after(ch, rs[#rs], hn)
610+ insert_after(ch, rs[1], hn)
597611 set_attr(hn, attr_icflag, PROCESSED)
598612 if fn == 2*cmp-1 then
599613 write_aux(wv, has_attr(hn, attr_ruby))
@@ -727,8 +741,15 @@ end
727741
728742 do
729743 local RIPOST = luatexja.stack_table_index.RIPOST
730- local function whatsit_after_callback(s, Nq, Np, bsl)
744+ local function whatsit_after_callback(s, Nq, Np)
731745 if not s and getfield(Nq.nuc, 'user_id') == RUBY_PRE then
746+ if Np then
747+ local last_glue = node_new(id_glue)
748+ set_attr(last_glue, attr_icflag, 0)
749+ insert_before(Nq.nuc, Np.first, last_glue)
750+ Np.first = last_glue
751+ next_cluster_array[Nq.nuc] = last_glue -- ルビ処理用のグルー
752+ end
732753 local nqnv = getfield(Nq.nuc, 'value')
733754 local x = node_next(node_next(nqnv))
734755 for i = 2, getfield(nqnv, 'value') do x = node_next(node_next(x)) end