OSDN Git Service

new syntax in JFM: end_stretch = {-0.5, 0.5}
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sun, 31 Jul 2016 10:57:49 +0000 (19:57 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sun, 31 Jul 2016 10:57:49 +0000 (19:57 +0900)
src/jfm-ujis.lua
src/ltj-adjust.lua
src/ltj-jfont.lua
test/jfm-hang.lua
test/test17-priority.pdf
test/test17-priority.tex

index a0d1675..72c1e9c 100644 (file)
@@ -92,7 +92,7 @@ luatexja.jfont.define_jfm {
       align = 'left', left = 0.0, down = 0.0,
       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
       align = 'left', left = 0.0, down = 0.0,
       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
--- 3 は.75, 2, 4 は0, あとは0.5
+         -- 3 は.75, 2, 4 は0, あとは0.5
         [0] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
         [1] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
         [3] = { 0.75, 0.0, 0.25, priority=1, ratio=1./3, kanjiskip_stretch=1 },
         [0] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
         [1] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
         [3] = { 0.75, 0.0, 0.25, priority=1, ratio=1./3, kanjiskip_stretch=1 },
index 7f5562f..8ffc07c 100644 (file)
@@ -103,12 +103,6 @@ local function get_total_stretched(p, line)
    end
    for i=4,0,-1 do if total_st[i*65536]~=0 then total_st.order=i; break end; end
    for i=4,0,-1 do if total_sh[i*65536]~=0 then total_sh.order=i; break end; end
    end
    for i=4,0,-1 do if total_st[i*65536]~=0 then total_st.order=i; break end; end
    for i=4,0,-1 do if total_sh[i*65536]~=0 then total_sh.order=i; break end; end
-   print('gf', (gs==0) and ' ' or (gs==1 and '+' or '-') .. gf )
-   print('**STRETCH')
-   for i,v in pairs(total_st) do print(i, v); end
-   print('**shrink')
-   for i,v in pairs(total_sh) do print(i, v); end
-   print('****** END ******')
    if gs==0 then
       return 0, gf
    else 
    if gs==0 then
       return 0, gf
    else 
@@ -117,7 +111,6 @@ local function get_total_stretched(p, line)
 end
 
 local function clear_stretch(p, ic, name)
 end
 
 local function clear_stretch(p, ic, name)
-   print('clear', ic)
    for q in node_traverse_id(id_glue, getlist(p)) do
       local f = get_attr_icflag(q)
       if (f == ic) or ((ic ==KANJI_SKIP) and (f == KANJI_SKIP_JFM))
    for q in node_traverse_id(id_glue, getlist(p)) do
       local f = get_attr_icflag(q)
       if (f == ic) or ((ic ==KANJI_SKIP) and (f == KANJI_SKIP_JFM))
@@ -144,6 +137,7 @@ local function set_stretch(p, after, before, ic, name)
 end
 
 -- step 1: 行末に kern を挿入(句読点,中点用)
 end
 
 -- step 1: 行末に kern を挿入(句読点,中点用)
+local abs = math.abs
 local ltjd_glyph_from_packed = ltjd.glyph_from_packed
 local function aw_step1(p, total, ntr)
    local head = getlist(p)
 local ltjd_glyph_from_packed = ltjd.glyph_from_packed
 local function aw_step1(p, total, ntr)
    local head = getlist(p)
@@ -164,54 +158,39 @@ local function aw_step1(p, total, ntr)
       xc = ltjd_glyph_from_packed(x)
       while getid(xc) == id_whatsit do xc = node_next(xc) end -- これはなんのために?
    else
       xc = ltjd_glyph_from_packed(x)
       while getid(xc) == id_whatsit do xc = node_next(xc) end -- これはなんのために?
    else
-     return total, false-- それ以外は対象外.
+      return total, false-- それ以外は対象外.
    end
    end
-   local xkst = ltjf_font_metric_table[getfont(xc)]
-     .char_type[has_attr(xc, attr_jchar_class) or 0]['end_stretch'] or 0
-   local xksh = ltjf_font_metric_table[getfont(xc)]
-     .char_type[has_attr(xc, attr_jchar_class) or 0]['end_shrink'] or 0
-   local xkni = ltjf_font_metric_table[getfont(xc)]
-     .char_type[has_attr(xc, attr_jchar_class) or 0]['end_natural_inhibit']
-
-   print(total, xkst, xksh, ntr)
-   if total>=xkst and xkst>0 then
-      local kn = node_new(id_kern)
-      setfield(kn, 'kern', xkst); set_attr(kn, attr_icflag, FROM_JFM)
-      insert_after(head, x, kn)
-      return total - xkst, true
-   elseif total<=-xksh and xksh<0 then
-      local kn = node_new(id_kern)
-      setfield(kn, 'kern', -xksh); set_attr(kn, attr_icflag, FROM_JFM)
-      insert_after(head, x, kn)
-      return total + xksh, true
-   else --    
-      local str = -(total-xkst)/total_sh[65536*total_sh.order] -- end_stretch を入れたときの glue_set (shrink)
-      local shr = (xksh+total)/total_st[65536*total_st.order] -- end_shrink を入れたときの glue_set (stretch)
-      print(xkni, str, ntr, shr)
-      if xkni then
-        if str<shr then 
-            local kn = node_new(id_kern)
-            setfield(kn, 'kern', xkst); set_attr(kn, attr_icflag, FROM_JFM)
-            insert_after(head, x, kn)
-           return total- xkst, true
-        else
-            local kn = node_new(id_kern)
-            setfield(kn, 'kern', -xksh); set_attr(kn, attr_icflag, FROM_JFM)
-            insert_after(head, x, kn)
-            return total + xksh, true  
-        end
+   local eadt = ltjf_font_metric_table[getfont(xc)]
+      .char_type[has_attr(xc, attr_jchar_class) or 0].end_adjust
+   if not eadt then 
+      return total, false
+   end
+   local eadt_ratio = {}
+   for i, v in ipairs(eadt) do
+      local t = total - v
+      if t>0 then
+        eadt_ratio[i] = {i, t/total_st[65536*total_st.order], t}
       else
       else
-        return total, false   
+        eadt_ratio[i] = {i, t/total_sh[65536*total_sh.order], t}
       end
    end
       end
    end
+   table.sort(eadt_ratio, function (a,b) return abs(a[2])<abs(b[2]) end)
+   --print('min', eadt[eadt_ratio[1][1]], eadt_ratio[1][3])
+   if eadt[eadt_ratio[1][1]]~=0 then
+      local kn = node_new(id_kern)
+      setfield(kn, 'kern', eadt[eadt_ratio[1][1]]); set_attr(kn, attr_icflag, FROM_JFM)
+      insert_after(head, x, kn)
+      return eadt_ratio[1][3], true
+   else
+      return total, false
+   end
 end
 
 -- step 2: 行中の glue を変える
 local function aw_step2(p, total, added_flag)
    local name = (total>0) and 'stretch' or 'shrink'
    local res = total_stsh[(total>0) and 1 or 2]
 end
 
 -- step 2: 行中の glue を変える
 local function aw_step2(p, total, added_flag)
    local name = (total>0) and 'stretch' or 'shrink'
    local res = total_stsh[(total>0) and 1 or 2]
-   print('STEP2', total)
-   if (total == 0) or res.order>0 then 
+   if total==0 or res.order > 0 then 
       -- もともと伸縮の必要なしか,残りの伸縮量は無限大
       if added_flag then -- 行末に kern 追加したので,それによる補正
         local f = node_hpack(getlist(p), getfield(p, 'width'), 'exactly')
       -- もともと伸縮の必要なしか,残りの伸縮量は無限大
       if added_flag then -- 行末に kern 追加したので,それによる補正
         local f = node_hpack(getlist(p), getfield(p, 'width'), 'exactly')
@@ -233,10 +212,9 @@ local function aw_step2(p, total, added_flag)
       setfield(p, 'glue_sign', getfield(f, 'glue_sign'))
       node_free(f)
    else
       setfield(p, 'glue_sign', getfield(f, 'glue_sign'))
       node_free(f)
    else
-      total = total - res[-1]; print('のこり', total)
+      total = total - res[-1];
       for i = 1, #priority_table do
         local v = priority_table[i]
       for i = 1, #priority_table do
         local v = priority_table[i]
-        print('total vs v', total, res[v], v)
          if total <= res[v] then
             for j = i+1,#priority_table do
                clear_stretch(p, priority_table[j], name)
          if total <= res[v] then
             for j = i+1,#priority_table do
                clear_stretch(p, priority_table[j], name)
index 207d0e0..1ae35b1 100644 (file)
@@ -61,6 +61,7 @@ function define_jfm(t)
    elseif type(t.zw)~='number' or type(t.zh)~='number' then
       defjfm_res= nil; return
    end
    elseif type(t.zw)~='number' or type(t.zh)~='number' then
       defjfm_res= nil; return
    end
+   t.version = (type(t.version)=='number') and t.version or 1
    t.char_type = {}; t.chars = {}
    for i,v in pairs(t) do
       if type(i) == 'number' then -- char_type
    t.char_type = {}; t.chars = {}
    for i,v in pairs(t) do
       if type(i) == 'number' then -- char_type
@@ -103,6 +104,28 @@ function define_jfm(t)
         if type(v.down)~='number' then
            v.down = 0.0
         end
         if type(v.down)~='number' then
            v.down = 0.0
         end
+        if t.version>=2 then
+           if v.end_stretch then defjfm_res= nil; return end
+           if v.end_shrink  then defjfm_res= nil; return end
+           if v.end_adjust then
+              if type(v.end_adjust)~='table' then
+                 v.end_adjust = nil
+              else
+                 table.sort(v.end_adjust)
+              end
+           end
+        else
+           v.end_adjust = nil
+           if v.end_stretch and v.end_stretch~=0.0 then 
+              v.end_adjust = (v.end_adjust or {}) 
+              v.end_adjust[#(v.end_adjust)+1] = v.end_stretch
+           end
+           if v.end_shrink and v.end_ahrink~=0.0 then 
+              v.end_adjust = (v.end_adjust or {}) 
+              v.end_adjust[#(v.end_adjust)+1] = -v.end_shrink
+           end
+           if v.end_adjust then v.end_adjust[#(v.end_adjust)+1] = 0.0 end
+        end
         v.kern = v.kern or {}; v.glue = v.glue or {}
         for j,x in pairs(v.glue) do
            if v.kern[j] then defjfm_res= nil; return end
         v.kern = v.kern or {}; v.glue = v.glue or {}
         for j,x in pairs(v.glue) do
            if v.kern[j] then defjfm_res= nil; return end
index 185218e..792c1b4 100644 (file)
@@ -2,76 +2,91 @@
 -- jfm-ujis.lua から派生
 -- jlreq では行末の句読点の直後に二分空きがある
 
 -- jfm-ujis.lua から派生
 -- jlreq では行末の句読点の直後に二分空きがある
 
+
 luatexja.jfont.define_jfm {
 luatexja.jfont.define_jfm {
-   dir = 'yoko',
+   dir = 'yoko', version = 2,
    zw = 1.0, zh = 1.0,
    zw = 1.0, zh = 1.0,
-
+   kanjiskip =  { 0.0, 0.25, 0 },
+   xkanjiskip = { 0.25, 0.25, .125 },
    [0] = {
       align = 'left', left = 0.0, down = 0.0,
       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
    [0] = {
       align = 'left', left = 0.0, down = 0.0,
       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
-        [6] = {0, 0, 0},
-        [2] = {0, 0, 0},
-        [102] = {0, 0, 0},
-        [4] = {0, 0, 0},
-        [1] = { 0.5 , 0.0, 0.5  },
-        [3] = { 0.25, 0.0, 0.25, 1 }
+        [1] = { 0.5 , 0.0, 0.5, ratio=1, kanjiskip_stretch=1 },
+        [2] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [102] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [3] = { 0.25, 0.0, 0.25, priority=1, ratio=1 },
+        [4] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [6] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [7] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [8] = { 0, 0, 0, kanjiskip_shrink=1 },
       }
    },
 
    [1] = { -- 開き括弧類
       chars = {
       }
    },
 
    [1] = { -- 開き括弧類
       chars = {
-        '‘', '“', '〈', '《', '「', '『', '【', '〔', '〖', 
+        '‘', '“', '〈', '《', '「', '『', '【', '〔', '〖',
         '〘', '〝', '(', '[', '{', '⦅'
       },
       align = 'right', left = 0.0, down = 0.0,
       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
         '〘', '〝', '(', '[', '{', '⦅'
       },
       align = 'right', left = 0.0, down = 0.0,
       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
-        [6] = {0, 0, 0},
-        [2] = {0, 0, 0},
-        [102] = {0, 0, 0},
-        [4] = {0, 0, 0},
-        [3] = { 0.25, 0.0, 0.25, 1 }
+-- 3 のみ四分,あとは0
+         [0] = { 0, 0, 0, kanjiskip_shrink=1 },
+         [1] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [2] = { 0, 0, 0, kanjiskip_shrink=1, kanjiskip_stretch=1 },
+        [102] = { 0, 0, 0, kanjiskip_shrink=1, kanjiskip_stretch=1 },
+        [3] = { 0.25, 0.0, 0.25, priority=1 },
+        [4] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [5] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [6] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [7] = { 0, 0, 0, kanjiskip_shrink=1 },
+         [8] = { 0, 0, 0, kanjiskip_shrink=1 },
       }
    },
 
    [2] = { -- 閉じ括弧類
       chars = {
       }
    },
 
    [2] = { -- 閉じ括弧類
       chars = {
-        '’', '”', '〉', '》', '」', '』', '】', '〕', 
-        '〗', '〙', '〟', ')', ']', '}', '⦆'
+        '’', '”', '〉', '》', '」', '』', '】', '〕',
+        '〗', '〙', '〟', ')', ']', '}', '⦆'
       },
       align = 'left', left = 0.0, down = 0.0,
       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
       },
       align = 'left', left = 0.0, down = 0.0,
       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
+      end_adjust = { 0, 0.5 },
       glue = {
       glue = {
-        [0] = { 0.5 , 0.0, 0.5  },
-        [1] = { 0.5 , 0.0, 0.5  },
-        [3] = { 0.25, 0.0, 0.25, 1 },
-        [5] = { 0.5 , 0.0, 0.5  },
-        [6] = { 0.5 , 0.0, 0.5  },
-        [7] = { 0.5 , 0.0, 0.5  },
-        [8] = { 0.5 , 0.0, 0.5  },
+     -- 3 は四分, 2, 4, 9 は0, あとは0.5
+        [0] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
+        [1] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
+         [2] = { 0, 0, 0, kanjiskip_shrink=1},
+         [102] = { 0, 0, 0, kanjiskip_shrink=1},
+        [3] = { 0.25, 0.0, 0.25, priority=1, ratio=1 },
+         [4] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [5] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
+        [6] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
+        [7] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
+        [8] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
       }
    },
 
    [102] = { -- 読点類
       chars = {
       }
    },
 
    [102] = { -- 読点類
       chars = {
-        '、', ',*',
+        '、', ',*'
       },
       align = 'left', left = 0.0, down = 0.0,
       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
       },
       align = 'left', left = 0.0, down = 0.0,
       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
-      end_shrink = 0.5, -- 「詰める」補正の時,ぶら下げ組
-      end_stretch = 0.5, -- 「空ける」補正のとき,全角取り
+      end_adjust = { -0.5, 0, 0.5 }, -- ぶら下げ,半角取り,全角取り
       glue = {
       glue = {
-        [0] = { 0.5 , 0.0, 0.5  },
-        [1] = { 0.5 , 0.0, 0.5  },
-        [3] = { 0.25, 0.0, 0.25, 1 },
-          -- 第4成分は優先度(-2 -- +2),省略時は0.
-          -- -2 -- +2 の整数値以外の値の場合の動作は未定義
-          -- (エラーチェックサボっているだけ)
-        [5] = { 0.5 , 0.0, 0.5  },
-        [6] = { 0.5 , 0.0, 0.5  },
-        [7] = { 0.5 , 0.0, 0.5  },
-        [8] = { 0.5 , 0.0, 0.5  },
+     -- 3 は四分, 2, 4, 9 は0, あとは0.5
+        [0] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
+        [1] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
+         [2] = { 0, 0, 0, kanjiskip_shrink=1},
+         [102] = { 0, 0, 0, kanjiskip_shrink=1},
+        [3] = { 0.25, 0.0, 0.25, priority=1, ratio=1 },
+         [4] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [5] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
+        [6] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
+        [7] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
+        [8] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
       }
    },
 
       }
    },
 
@@ -79,18 +94,19 @@ luatexja.jfont.define_jfm {
       chars = {'・', ':', ';'},
       align = 'middle', left = 0.0, down = 0.0,
       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
       chars = {'・', ':', ';'},
       align = 'middle', left = 0.0, down = 0.0,
       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
-      end_stretch = 0.25,
+      end_adjust = { 0.25 },
       glue = {
       glue = {
-        [0] = { 0.25, 0.0, 0.25, 1 },
-        [1] = { 0.25, 0.0, 0.25, 1 },
-        [2] = { 0.25, 0.0, 0.25, 1 },
-        [102] = { 0.25, 0.0, 0.25, 1 },
-        [3] = { 0.5 , 0.0, 0.5 , 1 },
-        [4] = { 0.25, 0.0, 0.25, 1 },
-        [5] = { 0.25, 0.0, 0.25, 1 },
-        [6] = { 0.25, 0.0, 0.25, 1 },
-        [7] = { 0.25, 0.0, 0.25, 1 },
-        [8] = { 0.25, 0.0, 0.25, 1 },
+-- 3 のみ 0.5,あとは0.25
+        [0] = { 0.25, 0.0, 0.25, priority=1, ratio=1 },
+        [1] = { 0.25, 0.0, 0.25, priority=1, ratio=1 },
+        [2] = { 0.25, 0.0, 0.25, priority=1, ratio=1 },
+        [102] = { 0.25, 0.0, 0.25, priority=1, ratio=1 },
+        [3] = { 0.5 , 0.0, 0.5 , priority=1 },
+        [4] = { 0.25, 0.0, 0.25, priority=1, ratio=1 },
+        [5] = { 0.25, 0.0, 0.25, priority=1, ratio=1 },
+        [6] = { 0.25, 0.0, 0.25, priority=1, ratio=1 },
+        [7] = { 0.25, 0.0, 0.25, priority=1, ratio=1 },
+        [8] = { 0.25, 0.0, 0.25, priority=1, ratio=1 },
       }
    },
 
       }
    },
 
@@ -98,30 +114,31 @@ luatexja.jfont.define_jfm {
       chars = {'。', '.'},
       align = 'left', left = 0.0, down = 0.0,
       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
       chars = {'。', '.'},
       align = 'left', left = 0.0, down = 0.0,
       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
-      end_shrink = 0.5,
-      end_stretch = 0.5,
+      end_adjust = { -0.5, 0.5 }, -- ぶら下げ,全角取り
+      -- (luatexja-adjust 下では半角取りを認めない)
       glue = {
       glue = {
-        [0] = { 0.5 , 0.0, 0.0  },
-        [1] = { 0.5 , 0.0, 0.0  },
-        [3] = { 0.75, 0.0, 0.25, 1 },
-        [5] = { 0.5 , 0.0, 0.0  },
-        [6] = { 0.5 , 0.0, 0.0  },
-        [7] = { 0.5 , 0.0, 0.0  },
-        [8] = { 0.5 , 0.0, 0.0  },
+         -- 3 は.75, 2, 4 は0, あとは0.5
+        [0] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
+        [1] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
+        [3] = { 0.75, 0.0, 0.25, priority=1, ratio=1./3, kanjiskip_stretch=1 },
+        [5] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
+        [6] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
+        [7] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
+        [8] = { 0.5 , 0.0, 0.5, ratio=0, kanjiskip_stretch=1 },
       }
    },
 
    [5] = { -- ダッシュ
       }
    },
 
    [5] = { -- ダッシュ
-      chars = { '—', '―', '‥', '…' },
+      chars = { '—', '―', '‥', '…', '〳', '〴', '〵', },
       align = 'left', left = 0.0, down = 0.0,
       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
       align = 'left', left = 0.0, down = 0.0,
       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
-        [6] = {0, 0, 0},
-        [2] = {0, 0, 0},
-        [102] = {0, 0, 0},
-        [4] = {0, 0, 0},
-        [1] = { 0.5 , 0.0, 0.5  },
-        [3] = { 0.25, 0.0, 0.25, 1 }
+        [1] = { 0.5 , 0.0, 0.5, ratio=1, kanjiskip_stretch=1 },
+        [2] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [102] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [3] = { 0.25, 0.0, 0.25, priority=1, ratio=1 },
+        [4] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [6] = { 0, 0, 0, kanjiskip_shrink=1 },
       },
       kern = {
         [5] = 0.0
       },
       kern = {
         [5] = 0.0
@@ -129,56 +146,58 @@ luatexja.jfont.define_jfm {
    },
 
    [6] = { -- 感嘆符・疑問符
    },
 
    [6] = { -- 感嘆符・疑問符
-      chars = { '?', '!' },
+      chars = { '?', '!', '‼', '⁇', '⁈', '⁉', },
       align = 'left', left = 0.0, down = 0.0,
       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
       align = 'left', left = 0.0, down = 0.0,
       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
-        [6] = {0, 0, 0},
-        [2] = {0, 0, 0},
-        [102] = {0, 0, 0},
-        [4] = {0, 0, 0},
-        [0] = { 0.5 , 0.0, 0.5  },
-        [1] = { 0.5 , 0.0, 0.5  },
-        [3] = { 0.25, 0.0, 0.25, 1 },
-        [7] = { 0.5 , 0.0, 0.5  },
+         [0] = { 0.5 , 0.0, 0.5, ratio=1, kanjiskip_stretch=1 },
+        [1] = { 0.5 , 0.0, 0.5, ratio=1, kanjiskip_stretch=1 },
+        [2] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [102] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [3] = { 0.75, 0.0, 0.25, priority=1, ratio=1 },
+        [4] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [6] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [7] = { 0.5 , 0.0, 0.5, ratio=1, kanjiskip_stretch=1 },
+        [8] = { 0, 0, 0, kanjiskip_shrink=1 },
       },
       kern = {
       },
       kern = {
-        [5] = 0.0,
-        [8] = 0.0
+        [5] = 0.0
       }
    },
 
    [7] = { -- 半角カナ
       chars = {
       }
    },
 
    [7] = { -- 半角カナ
       chars = {
-        '。', '「', '」', '、', '・', 'ヲ', 'ァ', 'ィ', 'ゥ', 
-        'ェ', 'ォ', 'ャ', 'ュ', 'ョ', 'ッ', 'ー', 'ア', 'イ', 
-        'ウ', 'エ', 'オ', 'カ', 'キ', 'ク', 'ケ', 'コ', 'サ', 
-        'シ', 'ス', 'セ', 'ソ', 'タ', 'チ', 'ツ', 'テ', 'ト', 
-        'ナ', 'ニ', 'ヌ', 'ネ', 'ノ', 'ハ', 'ヒ', 'フ', 'ヘ', 
-        'ホ', 'マ', 'ミ', 'ム', 'メ', 'モ', 'ヤ', 'ユ', 'ヨ', 
+        '。', '「', '」', '、', '・', 'ヲ', 'ァ', 'ィ', 'ゥ',
+        'ェ', 'ォ', 'ャ', 'ュ', 'ョ', 'ッ', 'ー', 'ア', 'イ',
+        'ウ', 'エ', 'オ', 'カ', 'キ', 'ク', 'ケ', 'コ', 'サ',
+        'シ', 'ス', 'セ', 'ソ', 'タ', 'チ', 'ツ', 'テ', 'ト',
+        'ナ', 'ニ', 'ヌ', 'ネ', 'ノ', 'ハ', 'ヒ', 'フ', 'ヘ',
+        'ホ', 'マ', 'ミ', 'ム', 'メ', 'モ', 'ヤ', 'ユ', 'ヨ',
         'ラ', 'リ', 'ル', 'レ', 'ロ', 'ワ', 'ン', '゙', '゚',
         'ラ', 'リ', 'ル', 'レ', 'ロ', 'ワ', 'ン', '゙', '゚',
-        "AJ1-516", "AJ1-517", "AJ1-518", "AJ1-519", "AJ1-520", "AJ1-521", "AJ1-522", 
-        "AJ1-523", "AJ1-524", "AJ1-525", "AJ1-526", "AJ1-527", "AJ1-528", "AJ1-529", 
-        "AJ1-530", "AJ1-531", "AJ1-532", "AJ1-533", "AJ1-534", "AJ1-535", "AJ1-536", 
-        "AJ1-537", "AJ1-538", "AJ1-539", "AJ1-540", "AJ1-541", "AJ1-542", "AJ1-543", 
-        "AJ1-544", "AJ1-545", "AJ1-546", "AJ1-547", "AJ1-548", "AJ1-549", "AJ1-550", 
-        "AJ1-551", "AJ1-552", "AJ1-553", "AJ1-554", "AJ1-555", "AJ1-556", "AJ1-557", 
-        "AJ1-558", "AJ1-559", "AJ1-560", "AJ1-561", "AJ1-562", "AJ1-563", "AJ1-564", 
-        "AJ1-565", "AJ1-566", "AJ1-567", "AJ1-568", "AJ1-569", "AJ1-570", "AJ1-571", 
-        "AJ1-572", "AJ1-573", "AJ1-574", "AJ1-575", "AJ1-576", "AJ1-577", "AJ1-578", 
-        "AJ1-579", "AJ1-580", "AJ1-581", "AJ1-582", "AJ1-583", "AJ1-584", "AJ1-585", 
-        "AJ1-586", "AJ1-587", "AJ1-588", "AJ1-589", "AJ1-590", "AJ1-591", "AJ1-592", 
+        "AJ1-516", "AJ1-517", "AJ1-518", "AJ1-519", "AJ1-520", "AJ1-521", "AJ1-522",
+        "AJ1-523", "AJ1-524", "AJ1-525", "AJ1-526", "AJ1-527", "AJ1-528", "AJ1-529",
+        "AJ1-530", "AJ1-531", "AJ1-532", "AJ1-533", "AJ1-534", "AJ1-535", "AJ1-536",
+        "AJ1-537", "AJ1-538", "AJ1-539", "AJ1-540", "AJ1-541", "AJ1-542", "AJ1-543",
+        "AJ1-544", "AJ1-545", "AJ1-546", "AJ1-547", "AJ1-548", "AJ1-549", "AJ1-550",
+        "AJ1-551", "AJ1-552", "AJ1-553", "AJ1-554", "AJ1-555", "AJ1-556", "AJ1-557",
+        "AJ1-558", "AJ1-559", "AJ1-560", "AJ1-561", "AJ1-562", "AJ1-563", "AJ1-564",
+        "AJ1-565", "AJ1-566", "AJ1-567", "AJ1-568", "AJ1-569", "AJ1-570", "AJ1-571",
+        "AJ1-572", "AJ1-573", "AJ1-574", "AJ1-575", "AJ1-576", "AJ1-577", "AJ1-578",
+        "AJ1-579", "AJ1-580", "AJ1-581", "AJ1-582", "AJ1-583", "AJ1-584", "AJ1-585",
+        "AJ1-586", "AJ1-587", "AJ1-588", "AJ1-589", "AJ1-590", "AJ1-591", "AJ1-592",
         "AJ1-593", "AJ1-594", "AJ1-595", "AJ1-596", "AJ1-597", "AJ1-598",
       },
       align = 'left', left = 0.0, down = 0.0,
         "AJ1-593", "AJ1-594", "AJ1-595", "AJ1-596", "AJ1-597", "AJ1-598",
       },
       align = 'left', left = 0.0, down = 0.0,
-      width = 0.5, height = 0.88, depth = 0.12, italic=0.0,      
+      width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
       glue = {
-        [6] = {0, 0, 0},
-        [2] = {0, 0, 0},
-        [102] = {0, 0, 0},
-        [4] = {0, 0, 0},
-        [1] = { 0.5 , 0.0, 0.5  },
-        [3] = { 0.25, 0.0, 0.25, 1 }
+        [1] = { 0.5 , 0.0, 0.5, ratio=1, kanjiskip_stretch=1 },
+        [2] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [102] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [3] = { 0.25, 0.0, 0.25, priority=1, ratio=1 },
+        [4] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [6] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [7] = { 0, 0, 0, kanjiskip_shrink=1 },
+         [8] = { 0, 0, 0, kanjiskip_shrink=1 },
       }
    },
 
       }
    },
 
@@ -192,7 +211,7 @@ luatexja.jfont.define_jfm {
         '┨', '┩', '┪', '┫', '┬', '┭', '┮', '┯',
         '┰', '┱', '┲', '┳', '┴', '┵', '┶', '┷',
         '┸', '┹', '┺', '┻', '┼', '┽', '┾', '┿',
         '┨', '┩', '┪', '┫', '┬', '┭', '┮', '┯',
         '┰', '┱', '┲', '┳', '┴', '┵', '┶', '┷',
         '┸', '┹', '┺', '┻', '┼', '┽', '┾', '┿',
-        '╀', '╁', '╂', '╃', '╄', '╅', '╆', '╇', 
+        '╀', '╁', '╂', '╃', '╄', '╅', '╆', '╇',
         '╈', '╉', '╊', '╋', '╌', '╍', '╎', '╏',
         '═', '║', '╒', '╓', '╔', '╕', '╖', '╗',
         '╘', '╙', '╚', '╛', '╜', '╝', '╞', '╟',
         '╈', '╉', '╊', '╋', '╌', '╍', '╎', '╏',
         '═', '║', '╒', '╓', '╔', '╕', '╖', '╗',
         '╘', '╙', '╚', '╛', '╜', '╝', '╞', '╟',
@@ -204,23 +223,24 @@ luatexja.jfont.define_jfm {
       align = 'left', left = 0.0, down = 0.0,
       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
       align = 'left', left = 0.0, down = 0.0,
       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
-        [6] = {0, 0, 0},
-        [2] = {0, 0, 0},
-        [102] = {0, 0, 0},
-        [4] = {0, 0, 0},
-        [1] = { 0.5 , 0.0, 0.5  },
-        [3] = { 0.25, 0.0, 0.25, 1 }
+        [1] = { 0.5 , 0.0, 0.5, ratio=1, kanjiskip_stretch=1 },
+        [2] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [102] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [3] = { 0.25, 0.0, 0.25, priority=1, ratio=1 },
+        [4] = { 0, 0, 0, kanjiskip_shrink=1 },
+        [6] = { 0, 0, 0, kanjiskip_shrink=1 },
       },
       kern = {
         [8] = 0.0
       }
    },
 
       },
       kern = {
         [8] = 0.0
       }
    },
 
+
    [99] = { -- box末尾
       chars = {'boxbdd', 'parbdd'},
       glue = {
    [99] = { -- box末尾
       chars = {'boxbdd', 'parbdd'},
       glue = {
-        [3] = { 0.25, 0.0, 0.25, 1 },
+        [3] = { 0.25, 0.0, 0.25, priority=1 },
       }
    },
 
       }
    },
 
-}
\ No newline at end of file
+}
index 2fe367b..36faa49 100644 (file)
Binary files a/test/test17-priority.pdf and b/test/test17-priority.pdf differ
index 063e636..b498c02 100644 (file)
   \textcolor{cyan!50!white}{\copy\gridbox}\hskip-20\zw\copy0\vrule\par
 }
 
   \textcolor{cyan!50!white}{\copy\gridbox}\hskip-20\zw\copy0\vrule\par
 }
 
-
+\ltjdisableadjust
 \long\def\testbox#1{%
 \long\def\testbox#1{%
-  \textcolor{red!80!black}{\ltjenableadjust\setbox0=\vbox{\hsize=20\zw\parfillskip0pt#1}\outbox{ON}}\par
+  \textcolor{red!80!black}{\ltjenableadjust
+    \setbox0=\vbox{\hsize=20\zw\parfillskip0pt#1}\ltjdisableadjust\outbox{ON}}\par
   \textcolor{black!90!white}{%
     \ltjdisableadjust\setbox0=\vbox{\hsize=20\zw\parfillskip0pt#1}\outbox{OFF}}\par\medskip
 }
 
 \parindent0pt
 \begin{document}
   \textcolor{black!90!white}{%
     \ltjdisableadjust\setbox0=\vbox{\hsize=20\zw\parfillskip0pt#1}\outbox{OFF}}\par\medskip
 }
 
 \parindent0pt
 \begin{document}
-\jfontspec[JFM=hang]{ipam.ttf}
+\jfontspec[YokoFeatures={JFM=hang}]{ipam.ttf}
 
 \ltjsetparameter{kanjiskip=.0\zw plus .4pt minus .4pt}
 {\tt kanjiskip: \ltjgetparameter{kanjiskip}
 
 \ltjsetparameter{kanjiskip=.0\zw plus .4pt minus .4pt}
 {\tt kanjiskip: \ltjgetparameter{kanjiskip}
@@ -87,18 +88,48 @@ xkanjiskip: \ltjgetparameter{xkanjiskip}}
 日本では\pTeX,p\LaTeX が使われている。
 }
 \testbox{%
 日本では\pTeX,p\LaTeX が使われている。
 }
 \testbox{%
+あいうえおかきくけこさしすせそたちつて・
+}
+
+\newpage
+行末の句点
+\typeout{行末の句点}
+
+\testbox{%
 あいうえおかきくけこさしすせそたちつて.
 }
 \testbox{%
 あいうえおかきくけこさしすせそたちつて.
 }
 \testbox{%
+あいうえおかきくけこさしすせそたちつ\vrule width .25\zw て.
+}
+\testbox{%
 あいうえおかきくけこさしすせそたちつ\vrule width .5\zw て.
 }
 \testbox{%
 あいうえおかきくけこさしすせそたちつ\vrule width .5\zw て.
 }
 \testbox{%
+あいうえおかきくけこさしすせそたちつ\vrule width .75\zw て.
+}
+\testbox{%
 あいうえおかきくけこさしすせそたちつ\vrule width 1\zw て.
 }
 あいうえおかきくけこさしすせそたちつ\vrule width 1\zw て.
 }
+
+行末の読点
+\typeout{行末の読点}
+
 \testbox{%
 \testbox{%
-あいうえおかきくけこさしすせそたちつて・
+あいうえおかきくけこさしすせそたちつて,
+}
+\testbox{%
+あいうえおかきくけこさしすせそたちつ\vrule width .25\zw て,
+}
+\testbox{%
+あいうえおかきくけこさしすせそたちつ\vrule width .5\zw て,
+}
+\testbox{%
+あいうえおかきくけこさしすせそたちつ\vrule width .75\zw て,
+}
+\testbox{%
+あいうえおかきくけこさしすせそたちつ\vrule width 1\zw て,
 }
 
 \newpage
 
 }
 
 \newpage
 
-\end{document}
\ No newline at end of file
+\end{document}