From 4cbb894fd7b6ede9de822c8306e16bab34dc8209 Mon Sep 17 00:00:00 2001 From: Hironori Kitagawa Date: Fri, 19 Aug 2016 17:16:01 +0900 Subject: [PATCH] luatexja-adjust.sty: {stretch,shrink}_priority keys in \ltjsetparameter --- src/addons/luatexja-adjust.sty | 12 +++++++++--- src/ltj-adjust.lua | 4 +--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/addons/luatexja-adjust.sty b/src/addons/luatexja-adjust.sty index 6967e21..019f480 100644 --- a/src/addons/luatexja-adjust.sty +++ b/src/addons/luatexja-adjust.sty @@ -109,10 +109,16 @@ \ltx@ifnextchar[{\@@ltjenableadjust}{\@@ltjenableadjust[lineend,priority]}}%] \ltjenableadjust -% there is also a key for \ltjsetparameter, for same effect -\define@boolkey[ltj]{japaram}{adjust}[true]{% - \ifltj@japaram@adjust\ltjenableadjust\else\ltjdisableadjust\fi\relax + +%%% 優先順位の設定 +%%% stretch_priority = {, , } +\define@key[ltj]{japaram}{stretch_priority}{% + \directlua{luatexja.adjust.make_priority_table(1,#1)}\relax +} +\define@key[ltj]{japaram}{shrink_priority}{% + \directlua{luatexja.adjust.make_priority_table(2,#1)}\relax } +\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 151b00b..c39e48d 100644 --- a/src/ltj-adjust.lua +++ b/src/ltj-adjust.lua @@ -59,6 +59,7 @@ end local priority_num = { 0, 0 } local at2pr = { {}, {} } +local at2pr_st, at2pr_sh = at2pr[1], at2pr[2] do local tmp = {} local function cmp(a,b) return a[1]>b[1] end -- 大きいほうが先! @@ -79,15 +80,12 @@ do priority_num[glue_sign] = n setmetatable(a, {__index = function () return others end }) end - make_priority_table(1, -3, -4, 5) - make_priority_table(2, -3, -4, 5) luatexja.adjust.make_priority_table = make_priority_table end -- box 内で伸縮された glue の合計値を計算 local total_stsh = {{},{}} -local at2pr_st, at2pr_sh = at2pr[1], at2pr[2] local total_st, total_sh = total_stsh[1], total_stsh[2] local get_total_stretched do -- 2.11.0