OSDN Git Service

forgot to include changes in src/
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Fri, 19 Aug 2016 17:28:42 +0000 (02:28 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Fri, 19 Aug 2016 17:28:42 +0000 (02:28 +0900)
src/addons/luatexja-adjust.sty
src/ltj-adjust.lua
test/test17-priority.tex

index 019f480..6337e82 100644 (file)
 \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
index c39e48d..81a9ea8 100644 (file)
@@ -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]<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
index bc605ba..38f5771 100644 (file)
@@ -2,7 +2,6 @@
 
 \documentclass{ltjsarticle}
 \usepackage{luatexja-fontspec,luatexja-adjust,xcolor,amsmath,amssymb}
-
 \def\sq{%
   \hbox to 1\zw{\hss\fboxsep=-.5\fboxrule\fbox{%
    \hskip\dimexpr-.5\zw-.2pt\vrule width.4pt height.08\zw depth.12\zw%