From 39d164c88acd35d8814ef9a24fe0a610831302a7 Mon Sep 17 00:00:00 2001 From: Hironori Kitagawa Date: Sat, 20 Aug 2016 02:28:42 +0900 Subject: [PATCH] forgot to include changes in src/ --- src/addons/luatexja-adjust.sty | 18 +++++++++++++----- src/ltj-adjust.lua | 18 +++++++++++------- test/test17-priority.tex | 1 - 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/addons/luatexja-adjust.sty b/src/addons/luatexja-adjust.sty index 019f480..6337e82 100644 --- a/src/addons/luatexja-adjust.sty +++ b/src/addons/luatexja-adjust.sty @@ -111,14 +111,22 @@ \ltjenableadjust %%% 優先順位の設定 -%%% stretch_priority = {, , } +\define@key[ltj]{adjpri}{kanjiskip}{% + \directlua{luatexja.adjust.priority_table[\the\count@][1] = token.scan_int()}#1\relax} +\define@key[ltj]{adjpri}{xkanjiskip}{% + \directlua{luatexja.adjust.priority_table[\the\count@][2] = token.scan_int()}#1\relax} +\define@key[ltj]{adjpri}{others}{% + \directlua{luatexja.adjust.priority_table[\the\count@][3] = token.scan_int()}#1\relax} \define@key[ltj]{japaram}{stretch_priority}{% - \directlua{luatexja.adjust.make_priority_table(1,#1)}\relax -} + \begingroup\count@=1 \setkeys[ltj]{adjpri}{#1}\relax + \directlua{luatexja.adjust.make_priority_table(1)}\endgroup} \define@key[ltj]{japaram}{shrink_priority}{% - \directlua{luatexja.adjust.make_priority_table(2,#1)}\relax + \begingroup\count@=2 \setkeys[ltj]{adjpri}{#1}\relax + \directlua{luatexja.adjust.make_priority_table(2)}\endgroup} +\ltjsetparameter{% + stretch_priority={kanjiskip=-40, xkanjiskip=-30, others=50}, + shrink_priority={kanjiskip=-40, xkanjiskip=-30, others=50}, } -\ltjsetparameter{stretch_priority={-3,-4,5}, shrink_priority={-3,-4,5}} %%------------------ all done diff --git a/src/ltj-adjust.lua b/src/ltj-adjust.lua index c39e48d..81a9ea8 100644 --- a/src/ltj-adjust.lua +++ b/src/ltj-adjust.lua @@ -61,24 +61,28 @@ local priority_num = { 0, 0 } local at2pr = { {}, {} } local at2pr_st, at2pr_sh = at2pr[1], at2pr[2] do + local priority_table = {{},{}} + luatexja.adjust.priority_table = priority_table local tmp = {} local function cmp(a,b) return a[1]>b[1] end -- 大きいほうが先! - local function make_priority_table(glue_sign, xsk, ksk, others) + local function make_priority_table(glue_sign) for i,_ in pairs(tmp) do tmp[i]=nil end for i=-2,2 do tmp[#tmp+1] = { i, FROM_JFM+i } end - tmp[#tmp+1] = { xsk, XKANJI_SKIP } - tmp[#tmp+1] = { xsk, XKANJI_SKIP_JFM } - tmp[#tmp+1] = { ksk, KANJI_SKIP } - tmp[#tmp+1] = { ksk, KANJI_SKIP_JFM } - tmp[#tmp+1] = { others, -1 } + local pt = priority_table[glue_sign] + tmp[#tmp+1] = { pt[2]/10, XKANJI_SKIP } + tmp[#tmp+1] = { pt[2]/10, XKANJI_SKIP_JFM } + tmp[#tmp+1] = { pt[1]/10, KANJI_SKIP } + tmp[#tmp+1] = { pt[1]/10, KANJI_SKIP_JFM } + tmp[#tmp+1] = { pt[3]/10, -1 } table.sort(tmp, cmp) local a, m, n = at2pr[glue_sign], 10000000, 0 for i=1,#tmp do if tmp[i][1]