OSDN Git Service

行末文字の位置調整も追加.
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Fri, 28 Sep 2012 09:55:41 +0000 (18:55 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Fri, 28 Sep 2012 09:55:41 +0000 (18:55 +0900)
src/jfm-ujis.lua
src/ltj-adjust.lua
test/jfm-hang.lua
test/test17-priority.pdf
test/test17-priority.tex

index d2cd13b..2470579 100644 (file)
@@ -1,6 +1,7 @@
 -- -*- coding: utf-8 -*-
 -- jfm-ujis.lua: LuaTeX-ja 標準 JFM
 -- based on upnmlminr-h.tfm (a metric in UTF/OTF package used by upTeX).
+-- JIS X 4051:2004 では,行末の句読点や中点はベタ
 
 luatexja.jfont.define_jfm {
    dir = 'yoko',
@@ -10,8 +11,12 @@ 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 = {
+        [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 }
+        [3] = { 0.25, 0.0, 0.25, 1 }
       }
    },
 
@@ -23,21 +28,44 @@ luatexja.jfont.define_jfm {
       align = 'right', left = 0.0, down = 0.0,
       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
-        [3] = { 0.25, 0.0, 0.25 }
+        [6] = {0, 0, 0},
+        [2] = {0, 0, 0},
+        [102] = {0, 0, 0},
+        [4] = {0, 0, 0},
+        [3] = { 0.25, 0.0, 0.25, 1 }
       }
    },
 
    [2] = { -- 閉じ括弧類
       chars = {
-        'â\80\99', 'â\80\9d', 'ã\80\81', 'ã\80\89', 'ã\80\8b', 'ã\80\8d', 'ã\80\8f', 'ã\80\91', 'ã\80\95', 
-        'ã\80\97', 'ã\80\99', 'ã\80\9f', 'ï¼\89', 'ï¼\8c*', 'ï¼½', 'ï½\9d', 'ï½ ', 
+        '’', '”', '〉', '》', '」', '』', '】', '〕', 
+        '〗', '〙', '〟', ')', ']', '}', '⦆', 
       },
       align = 'left', left = 0.0, down = 0.0,
       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
         [0] = { 0.5 , 0.0, 0.5  },
         [1] = { 0.5 , 0.0, 0.5  },
-        [3] = { 0.25, 0.0, 0.25 },
+        [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  },
+      }
+   },
+
+   [102] = { -- 読点類
+      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,
+      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  },
@@ -49,16 +77,18 @@ 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,
+      --end_stretch = 0.25,
       glue = {
-        [0] = { 0.25, 0.0, 0.25 },
-        [1] = { 0.25, 0.0, 0.25 },
-        [2] = { 0.25, 0.0, 0.25 },
-        [3] = { 0.5 , 0.0, 0.5  },
-        [4] = { 0.25, 0.0, 0.25 },
-        [5] = { 0.25, 0.0, 0.25 },
-        [6] = { 0.25, 0.0, 0.25 },
-        [7] = { 0.25, 0.0, 0.25 },
-        [8] = { 0.25, 0.0, 0.25 },
+        [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 },
       }
    },
 
@@ -66,10 +96,12 @@ 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,
+      --end_shrink = 0.5,
+      --end_stretch = 0.5,
       glue = {
         [0] = { 0.5 , 0.0, 0.0  },
         [1] = { 0.5 , 0.0, 0.0  },
-        [3] = { 0.75, 0.0, 0.25 },
+        [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  },
@@ -82,8 +114,12 @@ 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 = {
+        [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 }
+        [3] = { 0.25, 0.0, 0.25, 1 }
       },
       kern = {
         [5] = 0.0
@@ -95,9 +131,13 @@ 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 = {
+        [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 },
+        [3] = { 0.25, 0.0, 0.25, 1 },
         [7] = { 0.5 , 0.0, 0.5  },
       },
       kern = {
@@ -131,8 +171,12 @@ 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 = {
+        [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 }
+        [3] = { 0.25, 0.0, 0.25, 1 }
       }
    },
 
@@ -158,8 +202,12 @@ 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 = {
+        [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 }
+        [3] = { 0.25, 0.0, 0.25, 1 }
       },
       kern = {
         [8] = 0.0
@@ -169,7 +217,7 @@ luatexja.jfont.define_jfm {
    [99] = { -- box末尾
       chars = {'boxbdd', 'parbdd'},
       glue = {
-        [3] = { 0.25, 0.0, 0.25 },
+        [3] = { 0.25, 0.0, 0.25, 1 },
       }
    },
 
index d2ba3aa..ad7596e 100644 (file)
@@ -9,10 +9,20 @@ luatexbase.provides_module({
 })
 module('luatexja.adjust', package.seeall)
 
+luatexja.load_module('jfont');     local ltjf = luatexja.jfont
+
+local id_glyph = node.id('glyph')
+local id_kern = node.id('kern')
 local id_hlist = node.id('hlist')
 local id_glue  = node.id('glue')
 local id_glue_spec = node.id('glue_spec')
+local has_attr = node.has_attribute
+local set_attr = node.set_attribute
 local attr_icflag = luatexbase.attributes['ltj@icflag']
+local attr_jchar_class = luatexbase.attributes['ltj@charclass']
+local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
+
+local ltjf_font_metric_table = ltjf.font_metric_table
 
 local PACKED = 2
 local FROM_JFM = 6
@@ -92,6 +102,81 @@ local function set_stretch(p, after, before, ic, name)
    end
 end
 
+-- step 1: 行末に kern を挿入(句読点,中点用)
+local function aw_step1(p, res, total)
+   local x = node.tail(p.head); if not x then return false end
+   local x = node.prev(x)     ; if not x then return false end
+   -- 本当の行末の node を格納
+   if x.id == id_glue and x.subtype == 15 then 
+      -- 段落最終行のときは,\penalty10000 \parfillskip が入るので,
+      -- その前の node が本来の末尾文字となる
+      x = node.prev(node.prev(x)) 
+   end
+
+   local xc
+   if x.id == id_glyph and has_attr(x, attr_curjfnt) == x.font then
+      -- 和文文字
+      xc = x
+   elseif x.id == id_hlist and get_attr_icflag(x) == PACKED then
+      -- packed JAchar
+      xc = x.head
+   else
+     return false-- それ以外は対象外.
+   end
+   local xk = ltjf_font_metric_table -- 
+     [xc.font].size_cache.char_type[has_attr(xc, attr_jchar_class) or 0]
+     ['end_' .. res.name] or 0
+     print(res.name, total, xk, unicode.utf8.char(xc.char))
+
+   if xk>0 and total>=xk then
+      print("ADDED")
+      total = total - xk
+      local kn = node.new(id_kern)
+      kn.kern = (res.name=='shrink' and -1 or 1) * xk
+      set_attr(kn, attr_icflag, FROM_JFM)
+      node.insert_after(p.head, x, kn)
+      return true
+   else return false
+   end
+end
+
+-- step 2: 行中の glue を変える
+local function aw_step2(p, res, total, added_flag)
+   if total == 0 then -- もともと伸縮の必要なし
+      if added_flag then -- 行末に kern 追加したので,それによる補正
+        local f = node.hpack(p.head, p.width, 'exactly')
+        f.head, p.glue_set, p.glue_sign, p.glue_order 
+           = nil, f.glue_set, f.glue_sign, f.glue_order
+        node.free(f); return
+      end
+   elseif total <= res[0] then -- 和文処理グルー以外で足りる
+      for _,v in pairs(priority_table) do clear_stretch(p, v, res.name) end
+      local f = node.hpack(p.head, p.width, 'exactly')
+      f.head, p.glue_set, p.glue_sign, p.glue_order 
+         = nil, f.glue_set, f.glue_sign, f.glue_order
+      node.free(f)
+   else
+      total, i = total - res[0], 1
+      while i <= #priority_table do
+         local v = priority_table[i]
+         if total <= res[v] then
+            for j = i+1,#priority_table do
+               clear_stretch(p, priority_table[j], res.name)
+            end
+            set_stretch(p, total, res[v], v, res.name)
+            i = #priority_table + 9 -- ループから抜けさせたいため
+         end
+         total, i= total - res[v], i+1
+      end
+      if i == #priority_table + 10 or added_flag then
+        local f = node.hpack(p.head, p.width, 'exactly')
+        f.head, p.glue_set, p.glue_sign, p.glue_order 
+           = nil, f.glue_set, f.glue_sign, f.glue_order
+        node.free(f)
+      end
+   end
+end
+
 
 function adjust_width(head) 
    if not head then return head end
@@ -106,31 +191,8 @@ function adjust_width(head)
                total = total + v
             end
          end; total = tex.round(total * res.glue_set)
-         if total <= res[0] then -- 和文処理グルー以外で足りる
-            for _,v in pairs(priority_table) do clear_stretch(p, v, res.name) end
-            local f = node.hpack(p.head, p.width, 'exactly')
-            f.head, p.glue_set, p.glue_sign, p.glue_order 
-               = nil, f.glue_set, f.glue_sign, f.glue_order
-            node.free(f)
-         else
-            total = total - res[0]
-            for i = 1, #priority_table do
-               local v = priority_table[i]
-               if total <= res[v] then
-                  for j = i+1,#priority_table do
-                     clear_stretch(p, priority_table[j], res.name)
-                  end
-                  set_stretch(p, total, res[v], v, res.name)
-                  local f = node.hpack(p.head, p.width, 'exactly')
-                  f.head, p.glue_set, p.glue_sign, p.glue_order 
-                     = nil, f.glue_set, f.glue_sign, f.glue_order
-                  node.free(f)
-                  --print(p.glue_set, p.glue_sign, p.glue_order)
-                  return head
-               end
-               total = total - res[v]
-            end
-         end
+         local added_flag = aw_step1(p, res, total)
+         aw_step2(p, res, total, added_flag)
       end
    end
    return head
index a88a058..185218e 100644 (file)
+-- -*- coding: utf-8 -*-
+-- jfm-ujis.lua から派生
+-- jlreq では行末の句読点の直後に二分空きがある
+
 luatexja.jfont.define_jfm {
    dir = 'yoko',
    zw = 1.0, zh = 1.0,
-   
+
    [0] = {
       align = 'left', left = 0.0, down = 0.0,
-      width = 'prop', height = 0.88, depth = 0.12, italic=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] = { -- 開き括弧類
+      chars = {
+        '‘', '“', '〈', '《', '「', '『', '【', '〔', '〖', 
+        '〘', '〝', '(', '[', '{', '⦅'
+      },
+      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 }
+      }
    },
-   [1] = {
-      chars = { 0x3042 },
+
+   [2] = { -- 閉じ括弧類
+      chars = {
+        '’', '”', '〉', '》', '」', '』', '】', '〕', 
+        '〗', '〙', '〟', ')', ']', '}', '⦆', 
+      },
       align = 'left', left = 0.0, down = 0.0,
-      width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
-      glue = { [3] = { 0.25, 0.0, 0.25 } },
-      kern = { [8] = -0.5 }
+      width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
+      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  },
+      }
+   },
+
+   [102] = { -- 読点類
+      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, -- 「空ける」補正のとき,全角取り
+      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  },
+      }
    },
-   [2] = {
-      chars = { 0x3044 },
+
+   [3] = { -- 中点類
+      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,
+      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 },
+      }
+   },
+
+   [4] = { -- 句点類
+      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,
+      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  },
+      }
+   },
+
+   [5] = { -- ダッシュ
+      chars = { '—', '―', '‥', '…' },
       align = 'left', left = 0.0, down = 0.0,
       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
-      glue = { [3] = { 0.25, 0.25, 0.25 } },
+      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 }
+      },
+      kern = {
+        [5] = 0.0
+      }
    },
-   [3] = {
-      chars = { 0x3048 },
+
+   [6] = { -- 感嘆符・疑問符
+      chars = { '?', '!' },
       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  },
+      },
+      kern = {
+        [5] = 0.0,
+        [8] = 0.0
+      }
    },
-   [4] = {
-      chars = { 0x304A },
+
+   [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-593", "AJ1-594", "AJ1-595", "AJ1-596", "AJ1-597", "AJ1-598",
+      },
       align = 'left', left = 0.0, down = 0.0,
-      width = 1.0, height = 0.88, depth = 0.12, italic=0.3,
+      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},
+        [1] = { 0.5 , 0.0, 0.5  },
+        [3] = { 0.25, 0.0, 0.25, 1 }
+      }
    },
-   [8] = {
-      chars = { 'lineend' },
+
+   [8] = { -- 罫線類.
+      chars = {
+        '─', '━', '│', '┃', '┄', '┅', '┆', '┇',
+        '┈', '┉', '┊', '┋', '┌', '┍', '┎', '┏',
+        '┐', '┑', '┒', '┓', '└', '┕', '┖', '┗',
+        '┘', '┙', '┚', '┛', '├', '┝', '┞', '┟',
+        '┠', '┡', '┢', '┣', '┤', '┥', '┦', '┧',
+        '┨', '┩', '┪', '┫', '┬', '┭', '┮', '┯',
+        '┰', '┱', '┲', '┳', '┴', '┵', '┶', '┷',
+        '┸', '┹', '┺', '┻', '┼', '┽', '┾', '┿',
+        '╀', '╁', '╂', '╃', '╄', '╅', '╆', '╇', 
+        '╈', '╉', '╊', '╋', '╌', '╍', '╎', '╏',
+        '═', '║', '╒', '╓', '╔', '╕', '╖', '╗',
+        '╘', '╙', '╚', '╛', '╜', '╝', '╞', '╟',
+        '╠', '╡', '╢', '╣', '╤', '╥', '╦', '╧',
+        '╨', '╩', '╪', '╫', '╬', '╭', '╮', '╯',
+        '╰', '╱', '╲', '╳', '╴', '╵', '╶', '╷',
+        '╸', '╹', '╺', '╻', '╼', '╽', '╾', '╿',
+      },
       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 }
+      },
+      kern = {
+        [8] = 0.0
+      }
+   },
+
+   [99] = { -- box末尾
+      chars = {'boxbdd', 'parbdd'},
+      glue = {
+        [3] = { 0.25, 0.0, 0.25, 1 },
+      }
+   },
+
+}
\ No newline at end of file
index 06c5c81..f6beb9c 100644 (file)
Binary files a/test/test17-priority.pdf and b/test/test17-priority.pdf differ
index f92e41b..4cd1427 100644 (file)
@@ -1,7 +1,7 @@
 %#!lualatex
 
-\documentclass{article}
-\usepackage{luatexja,luacode,xcolor}
+\documentclass{ltjsarticle}
+\usepackage{luatexja-fontspec,luacode,xcolor}
 \RequireLuaTeXjaSubmodule{adjust}
 
 \def\sq{%
 
 \parindent0pt
 \begin{document}
+\jfontspec[JFM=hang]{ipam.ttf}
+
+\ltjsetparameter{kanjiskip=.0\zw plus .4pt minus .4pt}
 {\tt kanjiskip: \ltjgetparameter{kanjiskip}
 
 \ltjsetparameter{xkanjiskip=.25\zw plus .25\zw minus .125\zw}
 xkanjiskip: \ltjgetparameter{xkanjiskip}}
 
+このテストでは,行末の句読点・中点類の位置調整を有効にした
+\texttt{jfm-hang.lua}を用いている.
+\begin{itemize}
+\item 句読点は,調整量に合わせて,ぶら下げ,二分取り,全角取りの3種類から選択される.
+\item 中点類は,行末に四分空きを追加することのみ対応.
+詰める際の「直前の四分空きも取る」は未実装,
+\item 行末文字の位置調整は,glueによる調整の負担量が少なくなるように行われる.
+なお,この位置調整で調整の方向が変わることはない.
+
+例えば,「三分伸ばす」調整が必要な,句点で終わる行があった場合,句点を全
+      角取りにするとglueの負担合計は「六分詰める」となり,調整量の絶対値
+      は減るが,方向が「伸ばす」から「詰める」こととなる.よってこのよう
+      な場合,句点は二分取りのままである.
+\end{itemize}
+
 \testbox{%
 ◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆
 %あいうえおかきくけこさしすせそたちつてと
@@ -43,7 +61,7 @@ xkanjiskip: \ltjgetparameter{xkanjiskip}}
 }
 
 \testbox{%
-あいうえおかきA B C Dこさ\texttt{DO i=1,10}『
+あいうえおかきA M M Dこさ\texttt{DO i=1,10}『
 }
 
 \testbox{%
@@ -56,7 +74,7 @@ xkanjiskip: \ltjgetparameter{xkanjiskip}}
 
 \def\pTeX{p\kern-.2em\TeX}
 \testbox{%
-日本で\pTeX,p\LaTeX がよく使われている。
+日本で\pTeX,p\LaTeX がよく使われている。
 }
 
 中点類の空き詰めは括弧類より優先
@@ -64,4 +82,25 @@ xkanjiskip: \ltjgetparameter{xkanjiskip}}
 \testbox{%
 あいうえおかきくけ・こさしすせそたち「「あ
 }
+
+句読点類・中点類の後ろ空き
+
+\testbox{%
+日本では\pTeX,p\LaTeX が使われている。
+}
+\testbox{%
+あいうえおかきくけこさしすせそたちつて.
+}
+\testbox{%
+あいうえおかきくけこさしすせそたちつ\vrule width .5\zw て.
+}
+\testbox{%
+あいうえおかきくけこさしすせそたちつ\vrule width 1\zw て.
+}
+\testbox{%
+あいうえおかきくけこさしすせそたちつて・
+}
+
+\newpage
+
 \end{document}
\ No newline at end of file