\ltjenableadjust
%%% 優先順位の設定
-%%% stretch_priority = {<xkanjiskip>, <kanjiskip>, <others>}
+\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
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]<m then n,m = n+1,tmp[i][1] end
a[tmp[i][2]] = n
end
+ local o = a[-1]
priority_num[glue_sign] = n
- setmetatable(a, {__index = function () return others end })
+ setmetatable(a, {__index = function () return o end })
end
luatexja.adjust.make_priority_table = make_priority_table
end