OSDN Git Service

luatexja-adjust.sty: {stretch,shrink}_priority keys in \ltjsetparameter
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Fri, 19 Aug 2016 08:16:01 +0000 (17:16 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Fri, 19 Aug 2016 08:16:01 +0000 (17:16 +0900)
src/addons/luatexja-adjust.sty
src/ltj-adjust.lua

index 6967e21..019f480 100644 (file)
    \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 = {<xkanjiskip>, <kanjiskip>, <others>}
+\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
index 151b00b..c39e48d 100644 (file)
@@ -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